# The test suite isn't normally run. It can be enabled with "--with=check". %bcond_with check # Upstream source information. %global upstream_owner AdaCore %global upstream_name langkit %global upstream_version 25.0.0 %global upstream_gittag v%{upstream_version} Name: liblktlang Version: %{upstream_version} Release: 1%{?dist} Summary: Language parser for the langkit DSL License: Apache-2.0 WITH LLVM-Exception URL: https://github.com/%{upstream_owner}/%{upstream_name} Source: %{url}/archive/%{upstream_gittag}/%{upstream_name}-%{upstream_version}.tar.gz # [Fedora-specific] Generation of standalone code not supported: no bundling. Patch: %{name}-generation-of-standalone-code-not-supported.patch BuildRequires: gcc-gnat gprbuild sed # A fedora-gnat-project-common that contains the new GPRinstall macro. BuildRequires: fedora-gnat-project-common >= 3.21 BuildRequires: langkit-devel BuildRequires: python3-devel # Build only on architectures where GPRbuild is available. ExclusiveArch: %{GPRbuild_arches} # An additional provides to help users find the package. Provides: python3-%{name} %global common_description_en \ Language parser for the langkit DSL. %description %{common_description_en} ################# ## Subpackages ## ################# %package devel Summary: Development files for the LKT parser Requires: %{name}-support%{?_isa} = %{version}-%{release} Requires: fedora-gnat-project-common Requires: gnatcoll-core-devel Requires: gnatcoll-gmp-devel Requires: gnatcoll-iconv-devel Requires: langkit-devel Requires: libprettier_ada-devel %description devel %{common_description_en} This package contains source code and linking information for developing applications that use the LKT parser. It also contains the Python API. ############# ## Prepare ## ############# %prep %autosetup -n %{upstream_name}-%{upstream_version} -p1 cd ./contrib/lkt # Generate the source code. # -- ignore undocumented nodes, following `manage.py make`. %python3 manage.py generate --library-types=relocatable --version='%{version}' \ --disable-warning=undocumented-nodes # ??? Version does not propagate into `setup.py`. sed --in-place \ --expression 's/version='\''0.1'\''/version='\''%{version}'\''/'\ build/python/setup.py # Scenario variables for GRPbuild project. %global scn_vars -XVERSION=%{version} \\\ -XBUILD_MODE=prod \\\ -XLIBRARY_TYPE=relocatable # Generate BuildRequires for the Python bindings. %generate_buildrequires %pyproject_buildrequires ########### ## Build ## ########### %build # As libltklang.gpr is generated and does not contain a Library_Version # attribute, we set the soname manually, and create a proper symbolic # link later, after running GPRinstall. %global GPRbuild_flags_soname -largs -Wl,-soname=%{name}.so.%{version} -gargs # Build the library. Use extensions and the latest Ada version (-gnatX). gprbuild %{GPRbuild_flags} %{GPRbuild_flags_soname} %{scn_vars} \ -cargs:Ada -gnatX -gargs -XSTANDALONE=no \ -P contrib/lkt/build/%{name}.gpr # Build the tools. gprbuild %{GPRbuild_flags} %{scn_vars} \ -cargs -fPIE -largs -L./lib -gargs \ -P contrib/lkt/build/mains.gpr # Build the Python binding. pushd . && cd contrib/lkt/build/python %pyproject_wheel popd ############# ## Install ## ############# %install # Install the language parsers. %{GPRinstall} %{scn_vars} --no-build-var -P contrib/lkt/build/%{name}.gpr %{GPRinstall} %{scn_vars} --mode=usage -P contrib/lkt/build/mains.gpr # Install Python API. %pyproject_install %pyproject_save_files %{name} # Now we rename the library... mv %{buildroot}%{_libdir}/%{name}.so \ %{buildroot}%{_libdir}/%{name}.so.%{version} # ...and create the symbolic link manually. ln --symbolic --no-target-directory %{name}.so.%{version} \ %{buildroot}%{_libdir}/%{name}.so # Make the generated usage project file architecture-independent. sed --regexp-extended --in-place \ '--expression=1i with "directories";' \ '--expression=/^-- This project has been generated/d' \ '--expression=s|^( *for +Source_Dirs +use +).*;$|\1(Directories.Includedir \& "/%{name}");|i' \ '--expression=s|^( *for +Library_Dir +use +).*;$|\1Directories.Libdir;|i' \ '--expression=s|^( *for +Library_ALI_Dir +use +).*;$|\1Directories.Libdir \& "/%{name}";|i' \ %{buildroot}%{_GNAT_project_dir}/%{name}.gpr # The Sed commands are: # 1: Insert a with clause before the first line to import the directories # project. # 2: Delete a comment that mentions the architecture. # 3: Replace the value of Source_Dirs with a pathname based on # Directories.Includedir. # 4: Replace the value of Library_Dir with Directories.Libdir. # 5: Replace the value of Library_ALI_Dir with a pathname based on # Directories.Libdir. ########### ## Files ## ########### %files -f %pyproject_files %license LICENSE.txt %{_libdir}/%{name}.so.%{version} %{_bindir}/lkt_parse %{_bindir}/lkt_unparse %{_bindir}/lkt_toolbox %files devel %{_GNAT_project_dir}/%{name}.gpr %{_includedir}/%{name} %dir %{_libdir}/%{name} %attr(444,-,-) %{_libdir}/%{name}/*.ali %{_libdir}/%{name}.so ############### ## Changelog ## ############### %changelog * Sun Oct 27 2024 Dennis van Raaij - 25.0.0-1 - New package.