Blame antlr4-project.spec

2f3030
# NOTE: The JavaScript runtime library includes a bundled copy of an obsolete
2f3030
# version of Torben Hasse's require.js.  If somebody who knows about JavaScript
2f3030
# will do something about that, we can include that runtime as well.  For now,
2f3030
# it is omitted.
2f3030
#
2f3030
# NOTE: A PHP runtime is available as a separate project:
2f3030
# https://github.com/antlr/antlr-php-runtime/
2f3030
2f3030
%global swiftarches x86_64 aarch64
2f3030
%global swiftdir    %{_prefix}/lib/swift/linux
2f3030
2f3030
Name:           antlr4-project
2f3030
Version:        4.8
e9b94a
Release:        5%{?dist}
2f3030
Summary:        Parser generator (ANother Tool for Language Recognition)
2f3030
2f3030
License:        BSD
2f3030
URL:            http://www.antlr.org/
2f3030
Source0:        https://github.com/antlr/antlr4/archive/%{version}/antlr4-%{version}.tar.gz
2f3030
# Work around a "code too large" error while compiling a generated file
2f3030
# https://github.com/antlr/antlr4/pull/2739
2f3030
Patch0:         antlr4-unicode-properties.patch
2f3030
# Fix mono errors due to ambiguous references
2f3030
# Upstream is not yet ready to move to newer mono versions.
2f3030
Patch1:         antlr4-mono-ambiguous.patch
899526
# Fix some javadoc problems
899526
Patch2:         antlr4-javadoc.patch
2f3030
2f3030
BuildRequires:  cmake
2f3030
BuildRequires:  gcc-c++
2f3030
BuildRequires:  help2man
60bae7
BuildRequires:  make
2f3030
BuildRequires:  maven-local
2f3030
BuildRequires:  mvn(com.ibm.icu:icu4j)
2f3030
BuildRequires:  mvn(com.webguys:string-template-maven-plugin)
2f3030
BuildRequires:  mvn(org.abego.treelayout:org.abego.treelayout.core)
2f3030
BuildRequires:  mvn(org.antlr:antlr3-maven-plugin)
2f3030
BuildRequires:  mvn(org.antlr:antlr4-maven-plugin)
2f3030
BuildRequires:  mvn(org.antlr:antlr-runtime)
2f3030
BuildRequires:  mvn(org.antlr:ST4)
2f3030
BuildRequires:  mvn(org.apache.felix:maven-bundle-plugin)
2f3030
BuildRequires:  mvn(org.apache.maven:maven-core)
2f3030
BuildRequires:  mvn(org.apache.maven:maven-plugin-api)
2f3030
BuildRequires:  mvn(org.apache.maven.plugins:maven-plugin-plugin)
2f3030
BuildRequires:  mvn(org.apache.maven.plugins:maven-source-plugin)
2f3030
BuildRequires:  mvn(org.apache.maven.plugin-tools:maven-plugin-annotations)
2f3030
BuildRequires:  mvn(org.codehaus.mojo:build-helper-maven-plugin)
2f3030
BuildRequires:  mvn(org.codehaus.plexus:plexus-compiler-api)
2f3030
BuildRequires:  mvn(org.glassfish:javax.json)
2f3030
BuildRequires:  mvn(org.sonatype.plexus:plexus-build-api)
2f3030
BuildRequires:  pkgconfig(uuid)
2f3030
BuildRequires:  python3-devel
60bae7
BuildRequires:  %{py3_dist setuptools}
2f3030
2f3030
%global _desc %{expand:
2f3030
ANTLR (ANother Tool for Language Recognition) is a powerful parser
2f3030
generator for reading, processing, executing, or translating structured
2f3030
text or binary files.  It is widely used to build languages, tools, and
2f3030
frameworks.  From a grammar, ANTLR generates a parser that can build
2f3030
and walk parse trees.}
2f3030
2f3030
%description %_desc
2f3030
2f3030
%package     -n antlr4-runtime-test-annotations
2f3030
Summary:        ANTLR runtime test annotations
2f3030
BuildArch:      noarch
2f3030
2f3030
%description -n antlr4-runtime-test-annotations %_desc
2f3030
2f3030
This package provides runtime library test annotations used by Java
2f3030
ANTLR parsers.
2f3030
2f3030
%package     -n antlr4-runtime-test-annotation-processors
2f3030
Summary:        ANTLR runtime test annotation processors
2f3030
BuildArch:      noarch
2f3030
Requires:       antlr4-runtime-test-annotations = %{version}-%{release}
2f3030
2f3030
%description -n antlr4-runtime-test-annotation-processors %_desc
2f3030
2f3030
This package provides runtime library test annotation processors used by
2f3030
Java ANTLR parsers.
2f3030
2f3030
%package     -n antlr4-runtime
2f3030
Summary:        ANTLR runtime
2f3030
BuildArch:      noarch
2f3030
2f3030
%description -n antlr4-runtime %_desc
2f3030
2f3030
This package provides the runtime library used by Java ANTLR parsers.
2f3030
2f3030
%package     -n antlr4
2f3030
Summary:        Parser generator (ANother Tool for Language Recognition)
2f3030
BuildArch:      noarch
2f3030
Requires:       antlr4-runtime = %{version}-%{release}
2f3030
Requires:       mvn(com.sun:tools)
2f3030
2f3030
%description -n antlr4 %_desc
2f3030
2f3030
This package provides the ANTLR parser generator.
2f3030
2f3030
%package     -n antlr4-maven-plugin
2f3030
Summary:        ANTLR plugin for Apache Maven
2f3030
BuildArch:      noarch
2f3030
Requires:       antlr4 = %{version}-%{release}
2f3030
2f3030
%description -n antlr4-maven-plugin %_desc
2f3030
2f3030
This package provides a plugin for Apache Maven which can be used to
2f3030
generate ANTLR parsers during project build.
2f3030
2f3030
%package     -n antlr4-javadoc
2f3030
Summary:        Java API documentation for antlr4
2f3030
BuildArch:      noarch
2f3030
2f3030
%description -n antlr4-javadoc %_desc
2f3030
2f3030
This package contains Java API documentation for antlr4.
2f3030
2f3030
%package     -n antlr4-doc
2f3030
Summary:        ANTLR4 documentation
2f3030
BuildArch:      noarch
2f3030
2f3030
%description -n antlr4-doc %_desc
2f3030
2f3030
This package contains ANTLR4 documentation.
2f3030
2f3030
%package     -n antlr4-cpp-runtime
2f3030
Summary:        ANTLR runtime for C++
2f3030
2f3030
%description -n antlr4-cpp-runtime %_desc
2f3030
2f3030
This package provides the runtime library used by C++ ANTLR parsers.
2f3030
2f3030
%package     -n antlr4-cpp-runtime-devel
2f3030
Summary:        Header files for programs that use C++ ANTLR parsers
2f3030
Requires:       antlr4-cpp-runtime%{?_isa} = %{version}-%{release}
2f3030
2f3030
%description -n antlr4-cpp-runtime-devel %_desc
2f3030
2f3030
This package provides header files for programs that use C++ ANTLR
2f3030
parsers.
2f3030
2f3030
%ifarch %go_arches
2f3030
%global goipath github.com/antlr/antlr4/runtime/Go/antlr
2f3030
2f3030
%package     -n golang-antlr4-runtime-devel
2f3030
Summary:        ANTLR runtime for Go
2f3030
BuildArch:      noarch
2f3030
BuildRequires:  go-rpm-macros
2f3030
2f3030
%description -n golang-antlr4-runtime-devel %_desc
2f3030
2f3030
This package provides the runtime library used by Go ANTLR parsers.
2f3030
%endif
2f3030
2f3030
%ifarch %mono_arches
2f3030
%package     -n mono-antlr4-runtime
2f3030
Summary:        ANTLR runtime for C\# (mono)
2f3030
License:        MIT
2f3030
BuildArch:      noarch
2f3030
BuildRequires:  mono-devel
2f3030
2f3030
%description -n mono-antlr4-runtime %_desc
2f3030
2f3030
This package provides the runtime library used by C\# (mono) ANTLR
2f3030
parsers.
2f3030
%endif
2f3030
2f3030
%package     -n python3-antlr4-runtime
2f3030
Summary:        ANTLR runtime for Python 3
2f3030
BuildArch:      noarch
2f3030
2f3030
# This can be removed when F31 reaches EOL
2f3030
Obsoletes:      antlr4-python3-runtime < 1:4.8-1
2f3030
Provides:       antlr4-python3-runtime = 1:%{version}-%{release}
2f3030
2f3030
%description -n python3-antlr4-runtime %_desc
2f3030
2f3030
This package provides the runtime library used by Python 3 ANTLR parsers.
2f3030
2f3030
%ifarch %swiftarches
2f3030
%package     -n swift-antlr4-runtime
2f3030
Summary:        ANTLR runtime for swift
2f3030
BuildRequires:  swift-lang
2f3030
2f3030
%description -n swift-antlr4-runtime %_desc
2f3030
2f3030
This package provides the runtime library used by swift ANTLR parsers.
2f3030
%endif
2f3030
2f3030
%prep
2f3030
%autosetup -n antlr4-%{version} -p1
2f3030
find -name \*.jar -delete
2f3030
2f3030
# Update for recent stringtemplate versions
2f3030
sed -i 's,\\>,>,g' tool/resources/org/antlr/v4/tool/templates/unicodedata.st
2f3030
2f3030
# sonatype-oss-parent is deprecated in Fedora
2f3030
%pom_remove_parent
2f3030
ab5383
# Xmvn javadoc mojo is in use
ab5383
%pom_remove_plugin -r :maven-javadoc-plugin
ab5383
2f3030
# Missing test deps: org.seleniumhq.selenium:selenium-java
2f3030
%pom_disable_module runtime-testsuite
2f3030
%pom_disable_module tool-testsuite
2f3030
2f3030
# Missing test dep:
2f3030
# io.takari.maven.plugins:takari-plugin-testing
2f3030
%pom_remove_dep -r :takari-plugin-testing
2f3030
2f3030
# Missing plugin
2f3030
# io.takari.maven.plugins:takari-lifecycle-plugin
2f3030
%pom_remove_plugin -r :takari-lifecycle-plugin
2f3030
2f3030
# Don't bundle dependencies
2f3030
%pom_remove_plugin :maven-shade-plugin tool
2f3030
2f3030
# Need some javax.json classes
2f3030
%pom_add_dep javax.json:javax.json-api tool
2f3030
2f3030
# Replace dep on deprecated maven-project with maven-core
2f3030
%pom_change_dep org.apache.maven:maven-project:2.2.1 org.apache.maven:maven-core:3.6.1 antlr4-maven-plugin
2f3030
2f3030
# Replace dep on maven-jdk-tools-wrapper with dep on tools.jar
2f3030
%pom_change_dep :maven-jdk-tools-wrapper com.sun:tools runtime-testsuite/processors
2f3030
2f3030
%mvn_package :antlr4-master antlr4-runtime
2f3030
2f3030
# Change library install directory on 64-bit platforms
2f3030
if [ "%{_lib}" != "lib" ]; then
2f3030
  sed -i 's/DESTINATION lib/&64/' runtime/Cpp/runtime/CMakeLists.txt
2f3030
fi
2f3030
2f3030
%build
2f3030
# Ensure we get the jit on arm
2f3030
%ifarch %{arm}
2f3030
export JAVA_HOME=$(ls -1d %{_jvmdir}/java-1.8.0-openjdk-aarch32*)
2f3030
%else
2f3030
export JAVA_HOME=%{_jvmdir}/java
2f3030
%endif
2f3030
2f3030
# Build for Java
2f3030
# Due to the missing takari packages, we cannot run the tests
ab5383
%mvn_build -s -f -- -Dsource=1.7
2f3030
2f3030
# Build the C++ runtime
2f3030
cd runtime/Cpp
2f3030
%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .
899526
%cmake_build
2f3030
cd -
2f3030
2f3030
# Build the Mono runtime
2f3030
%ifarch %mono_arches
2f3030
cd runtime/CSharp/runtime/CSharp
2f3030
xbuild Antlr4.mono.sln
2f3030
cd -
2f3030
%endif
2f3030
2f3030
# Build the Python 3 runtime
2f3030
cd runtime/Python3
2f3030
%py3_build
2f3030
cd -
2f3030
2f3030
%ifarch %swiftarches
2f3030
# Build the Swift runtime
2f3030
cd runtime/Swift
2f3030
# Swift insists on a space between -j and the number, so cannot use _smp_mflags
523ff6
swift build -c release %{?_smp_build_ncpus:-j %_smp_build_ncpus} \
523ff6
  -Xlinker --build-id -Xlinker --as-needed -Xlinker -z -Xlinker relro \
523ff6
  -Xlinker -z -Xlinker now
2f3030
cd -
2f3030
%endif
2f3030
2f3030
%install
2f3030
# Install for Java; cannot use %%mvn_install as it passes %%name to -n
2f3030
xmvn-install -R .xmvn-reactor -n antlr4 -d %{buildroot}
2f3030
jdir=target/site/apidocs
2f3030
[ -d .xmvn/apidocs ] && jdir=.xmvn/apidocs
2f3030
mkdir -p %{buildroot}%{_licensedir}
2f3030
if [ -d "${jdir}" ]; then
2f3030
   install -dm755 %{buildroot}%{_javadocdir}/antlr4
2f3030
   cp -pr "${jdir}"/* %{buildroot}%{_javadocdir}/antlr4
2f3030
   echo '%{_javadocdir}/antlr4' >>.mfiles-javadoc
2f3030
fi
2f3030
2f3030
%jpackage_script org.antlr.v4.Tool "" "" antlr4/antlr4:antlr3-runtime:antlr4/antlr4-runtime:stringtemplate4:treelayout antlr4 true
2f3030
2f3030
# Install the C++ runtime
899526
cd runtime/Cpp
899526
%cmake_install
2f3030
rm -f %{buildroot}%{_libdir}/libantlr4-runtime.a
899526
cd -
2f3030
2f3030
# Install the Go runtime
2f3030
%ifarch %go_arches
2f3030
mkdir -p %{buildroot}%{gopath}/src/%{goipath}
2f3030
cp -p runtime/Go/antlr/* %{buildroot}%{gopath}/src/%{goipath}
2f3030
cat > %{buildroot}%{gopath}/src/%{goipath}/.goipath << EOF
2f3030
version:%{version}-%{release}
2f3030
excluderegex:.*example.*
2f3030
EOF
2f3030
%endif
2f3030
2f3030
# Install the Mono runtime
2f3030
%ifarch %mono_arches
2f3030
mkdir -p %{buildroot}%{_monogacdir}
2f3030
gacutil -i runtime/CSharp/runtime/CSharp/Antlr4.Runtime/lib/Debug/Antlr4.Runtime.Standard.dll -f -package antlr4 -root %{buildroot}%{_prefix}/lib
2f3030
%endif
2f3030
2f3030
# Install the Python 3 runtime
2f3030
cd runtime/Python3
2f3030
%py3_install
60bae7
sed 's,#!python,#!%{python3},' bin/pygrun > %{buildroot}%{_bindir}/pygrun
2f3030
touch -r bin/pygrun %{buildroot}%{_bindir}/pygrun
2f3030
chmod 0755 %{buildroot}%{_bindir}/pygrun
2f3030
cd -
2f3030
2f3030
%ifarch %swiftarches
2f3030
# Install the Swift runtime
2f3030
cd runtime/Swift
2f3030
mkdir -p %{buildroot}%{swiftdir}/%{_arch}
2f3030
cp -p .build/release/libAntlr4.so %{buildroot}%{swiftdir}
2f3030
cp -p .build/release/Antlr4.swift{doc,module} %{buildroot}%{swiftdir}/%{_arch}
2f3030
cd -
2f3030
%endif
2f3030
2f3030
# Create man pages
2f3030
export PYTHONPATH=%{buildroot}%{python3_sitelib}
2f3030
mkdir -p %{buildroot}%{_mandir}/man1
2f3030
cd %{buildroot}%{_bindir}
2f3030
help2man -N --version-string=4.8 -h '' ./antlr4 > \
2f3030
  %{buildroot}%{_mandir}/man1/antlr4.1
2f3030
help2man -N --version-string=4.8 ./pygrun > \
2f3030
  %{buildroot}%{_mandir}/man1/pygrun.1
2f3030
cd -
2f3030
2f3030
# Clean up bits we do not want
2f3030
rm -fr %{buildroot}%{_docdir}/libantlr4
2f3030
2f3030
%files -n antlr4-runtime-test-annotations -f .mfiles-antlr4-runtime-test-annotations
2f3030
%license LICENSE.txt
2f3030
2f3030
%files -n antlr4-runtime-test-annotation-processors -f .mfiles-antlr4-runtime-test-annotation-processors
2f3030
2f3030
%files -n antlr4-runtime -f .mfiles-antlr4-runtime
2f3030
%doc README.md
2f3030
%license LICENSE.txt
2f3030
2f3030
%files -n antlr4 -f .mfiles-antlr4
2f3030
%doc CHANGES.txt contributors.txt
2f3030
%{_bindir}/antlr4
2f3030
%{_mandir}/man1/antlr4.1*
2f3030
2f3030
%files -n antlr4-maven-plugin -f .mfiles-antlr4-maven-plugin
2f3030
2f3030
%files -n antlr4-javadoc -f .mfiles-javadoc
2f3030
%license LICENSE.txt
2f3030
2f3030
%files -n antlr4-doc
2f3030
%doc doc
2f3030
%license LICENSE.txt
2f3030
2f3030
%files -n antlr4-cpp-runtime
2f3030
%doc runtime/Cpp/README.md
2f3030
%license LICENSE.txt
2f3030
%{_libdir}/libantlr4-runtime.so.%{version}
2f3030
2f3030
%files -n antlr4-cpp-runtime-devel
2f3030
%doc runtime/Cpp/cmake/Antlr4Package.md runtime/Cpp/cmake/README.md
2f3030
%{_includedir}/antlr4-runtime/
2f3030
%{_libdir}/libantlr4-runtime.so
2f3030
2f3030
%ifarch %go_arches
2f3030
%files -n golang-antlr4-runtime-devel
2f3030
%license LICENSE.txt
2f3030
%{gopath}/src/github.com/
2f3030
%endif
2f3030
2f3030
%ifarch %mono_arches
2f3030
%files -n mono-antlr4-runtime
2f3030
%doc runtime/CSharp/README.md
2f3030
%license LICENSE.txt
2f3030
%{_monodir}/antlr4/
2f3030
%{_monogacdir}/Antlr4.Runtime.Standard/
2f3030
%endif
2f3030
2f3030
%files -n python3-antlr4-runtime
2f3030
%doc runtime/Python3/README.txt
2f3030
%license LICENSE.txt
2f3030
%{_bindir}/pygrun
2f3030
%{_mandir}/man1/pygrun.1*
2f3030
%python3_sitelib/antlr4/
2f3030
%python3_sitelib/antlr4*.egg-info/
2f3030
2f3030
%ifarch %swiftarches
2f3030
%files -n swift-antlr4-runtime
2f3030
%license LICENSE.txt
2f3030
%{swiftdir}/libAntlr4.so
2f3030
%{swiftdir}/%{_arch}/Antlr4.swiftdoc
2f3030
%{swiftdir}/%{_arch}/Antlr4.swiftmodule
2f3030
%endif
2f3030
2f3030
%changelog
e9b94a
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-5
e9b94a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
e9b94a
899526
* Thu Jul 23 2020 Jerry James <loganjerry@gmail.com> - 4.8-4
899526
- Fix cmake and javadoc issues
899526
ab5383
* Tue Jul 21 2020 Mat Booth <mat.booth@redhat.com> - 4.8-3
ab5383
- Allow building against JDK 11
ab5383
cd31f4
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 4.8-2
cd31f4
- Rebuilt for Python 3.9
cd31f4
2f3030
* Tue Jan 21 2020 Jerry James <loganjerry@gmail.com> - 4.8-1
2f3030
- Initial RPM, based on old antlr4.spec