Compare commits

...

6 commits

Author SHA1 Message Date
Qyriad 3a11a23965 meson: perl bindings: ld64 doesn't have soname Qyriad 2024-04-01 13:42:15 -06:00
Qyriad 8f1cc1b8c9 meson: perl bindings: final touches? 2024-04-01 12:44:18 -06:00
Qyriad 70b9d12c08 meson: perl bindings: seems to work?
Change-Id: I2ee77e8ccf177dcad8964ee034a6f321fa71b615
2024-04-01 11:48:33 -06:00
Qyriad 5587050da8 meson: perl bindings: ah include_directories() has an is_system kwarg
Change-Id: Ibf5a6e6d99a7cf1a65f1161a0c58387f74349d17
2024-04-01 11:48:33 -06:00
Qyriad 1db9b85d56 meson: towards perl bindings
Change-Id: I0f70f4de70ca058440e8f1be6f75833cafa47de7
2024-04-01 11:48:33 -06:00
Qyriad 08a3747ac1 meson: implement perl bindings
previous compile commands:
rm -f Makefile.config && cd . && ./config.status --quiet --file=Makefile.config
xsubpp lib/Nix/Store.xs -output lib/Nix/Store.cc
g++ -o lib/Nix/Store.o -c lib/Nix/Store.cc   -g -Wall -std=c++2a -I ../src -O3 -fPIC -g -I/nix/store/gwlgqkn49r4hjyx6xazg0ihi780w0smn-libsodium-1.0.18-dev/include -std=c++2a -I/nix/store/zgya4cmmf4pqn4d2nfzvn1wcy4lj6yq2-nix-2.90.0-dev/include/nix -I/nix/store/rk5xpm1vmkqzk90wabxpjdq10l016bnv-perl-5.38.2/lib/perl5/5.38.2/x86_64-linux-thread-multi/CORE -D_FILE_OFFSET_BITS=64 -Wno-unknown-warning-option -Wno-unused-variable -Wno-literal-suffix -Wno-reserved-user-defined-literal -Wno-duplicate-decl-specifier -Wno-pointer-bool-conversion  -MMD -MF lib/Nix/.Store.o.dep -MP
g++ -o /home/qyriad/code/lix/.w/maint/meson/perl/lib/Nix/Store.so -shared  -Wl,--no-copy-dt-needed-entries lib/Nix/Store.o -L/nix/store/hqx3yzc2whzvwnnckmmfh17m0mv3drx2-libsodium-1.0.18/lib -lsodium -L/nix/store/dw9b72sr6b8kcj1wvzh5479xnh3c0hgz-nix-2.90.0/lib -lnixstore -lnixutil -Wl,-soname=Store.so

Change-Id: Ie1bfb0aa784e6136a82d518a652d0ae60c4b047a
2024-04-01 11:48:33 -06:00
5 changed files with 165 additions and 10 deletions

View file

@ -316,6 +316,6 @@ in stdenv.mkDerivation (finalAttrs: {
meta.platforms = lib.platforms.unix;
passthru.perl-bindings = pkgs.callPackage ./perl {
inherit fileset stdenv;
inherit fileset stdenv buildWithMeson;
};
})

View file

@ -3,6 +3,9 @@
, perl, perlPackages
, autoconf-archive, autoreconfHook, pkg-config
, nix, curl, bzip2, xz, boost, libsodium, darwin
, meson
, ninja
, buildWithMeson ? false,
}:
perl.pkgs.toPerlModule (stdenv.mkDerivation {
@ -10,24 +13,32 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation {
src = fileset.toSource {
root = ../.;
fileset = fileset.unions [
fileset = fileset.unions ([
../.version
./lib
] ++ lib.optionals (!buildWithMeson) [
./MANIFEST
../m4
../mk
./MANIFEST
./Makefile
./Makefile.config.in
./configure.ac
./lib
./local.mk
];
] ++ lib.optionals buildWithMeson [
./meson.build
./meson.options
]);
};
nativeBuildInputs =
[ autoconf-archive
autoreconfHook
pkg-config
];
nativeBuildInputs = [
pkg-config
] ++ lib.optionals (!buildWithMeson) [
autoconf-archive
autoreconfHook
] ++ lib.optionals buildWithMeson [
meson
ninja
];
buildInputs =
[ nix
@ -42,6 +53,9 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation {
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
# Nix likes to set this to "plain".
mesonBuildType = "debugoptimized";
enableParallelBuilding = true;
postUnpack = "sourceRoot=$sourceRoot/perl";

59
perl/lib/Nix/meson.build Normal file
View file

@ -0,0 +1,59 @@
store_xs_cpp = custom_target(
input : 'Store.xs',
output : 'Store.cc',
command : [
xsubpp,
'@INPUT@',
'-output',
'@OUTPUT@',
],
build_by_default : true,
)
soname_args = []
if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
soname_args = ['-Wl,-soname=Store.so']
endif
perl_libstore = shared_module(
'Store',
store_xs_cpp,
# This library does NOT get the normal libsuffix. it's just `Store.so`, not `libStore.so`.
# XXX(Qyriad): is this also true on macOS?
name_prefix : '',
dependencies : [
libstore,
sodium,
perl_include,
],
link_args : [
# Nix doesn't provide a pkg-config file for libutil.
'-lnixutil',
soname_args,
],
install : true,
install_dir : perl_libdir / 'auto/Nix/Store',
)
config_pm = configure_file(
input : 'Config.pm.in',
output : 'Config.pm',
configuration : {
'PACKAGE_VERSION': meson.project_version(),
},
)
nix_perl_sources = files(
'Store.pm',
'Manifest.pm',
'SSH.pm',
'CopyClosure.pm',
'Utils.pm',
)
install_data(
nix_perl_sources,
config_pm,
install_dir : perl_libdir / 'Nix',
preserve_path : true,
)

74
perl/meson.build Normal file
View file

@ -0,0 +1,74 @@
project('lix-perl', 'cpp',
version : run_command('bash', '-c', 'echo -n $(cat ../.version)$VERSION_SUFFIX', check : true).stdout().strip(),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'debug=true',
# FIXME(Qyriad): should this be -O2? The main nix build was switched to -O2 in 3c5234430
'optimization=3',
],
)
fs = import('fs')
prefix = get_option('prefix')
libdir = get_option('libdir')
if not fs.is_absolute(libdir)
libdir = prefix / libdir
endif
host_system = host_machine.cpu_family() + '-' + host_machine.system()
cxx = meson.get_compiler('cpp')
# Really version 5.8.0, but Perl's version string is of the form
# "This is perl 5, version 38, subversion 2", for 5.38.2, so as far
# as Meson is concerned, the version of Perl we need is 8 or greater.
perl = find_program('perl', version : '>=8')
curl = find_program('curl')
bzip2 = find_program('bzip2')
xz = find_program('xz')
# "compiler to convert Perl XS code into C code"
xsubpp = find_program('xsubpp')
perl_version = run_command(
perl,
'-e',
'use Config; print $Config{version};',
capture : true,
check : true,
).stdout()
perl_arch_name = run_command(
perl,
'-e',
'use Config; print $Config{archname};',
capture : true,
check : true,
).stdout()
perl_libdir = f'@libdir@/perl5/site_perl/@perl_version@/@perl_arch_name@'
perl_incdir = run_command(
perl,
'-e',
'use Config; print $Config{archlibexp};',
capture : true,
check : true,
).stdout() + '/CORE'
perl_include = declare_dependency(
# This must have is_system : true, or #include "config.h" will get perl's config.h
# instead of Nix's.
include_directories : include_directories(perl_incdir, is_system : true),
)
sodium = dependency('libsodium', 'sodium', required : true)
if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
add_project_link_arguments('-Wl,--no-copy-dt-needed-entries', language : 'cpp')
endif
libstore = dependency('nixstore', 'nix-store', required : true)
subdir('lib/Nix')

8
perl/meson.options Normal file
View file

@ -0,0 +1,8 @@
# vim: filetype=meson
option('perl-dbi', type : 'string',
description : 'path to the Perl DBI module',
)
option('perl-dbd-sqlite', type : 'string',
description : 'path to the Perl DBD::SQLite module',
)