mirror of
https://github.com/NixOS/nix.git
synced 2024-11-21 22:32:26 +00:00
perl: Rewrite build system using Meson
This commit is contained in:
parent
b406cf9b81
commit
fc1d9023a2
@ -1,21 +0,0 @@
|
||||
makefiles = local.mk
|
||||
|
||||
GLOBAL_CXXFLAGS += -g -Wall -std=c++2a
|
||||
|
||||
# A convenience for concurrent development of Nix and its Perl bindings.
|
||||
# Not needed in a standalone build of the Perl bindings.
|
||||
ifneq ("$(wildcard ../src)", "")
|
||||
GLOBAL_CXXFLAGS += -I ../src
|
||||
endif
|
||||
|
||||
-include Makefile.config
|
||||
|
||||
OPTIMIZE = 1
|
||||
|
||||
ifeq ($(OPTIMIZE), 1)
|
||||
GLOBAL_CXXFLAGS += -O3
|
||||
else
|
||||
GLOBAL_CXXFLAGS += -O0
|
||||
endif
|
||||
|
||||
include mk/lib.mk
|
@ -1,18 +0,0 @@
|
||||
HOST_OS = @host_os@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
SODIUM_LIBS = @SODIUM_LIBS@
|
||||
NIX_CFLAGS = @NIX_CFLAGS@
|
||||
NIX_LIBS = @NIX_LIBS@
|
||||
nixbindir = @nixbindir@
|
||||
curl = @curl@
|
||||
nixlibexecdir = @nixlibexecdir@
|
||||
nixlocalstatedir = @nixlocalstatedir@
|
||||
perl = @perl@
|
||||
perllibdir = @perllibdir@
|
||||
nixstoredir = @nixstoredir@
|
||||
nixsysconfdir = @nixsysconfdir@
|
@ -1,84 +0,0 @@
|
||||
AC_INIT(nix-perl, m4_esyscmd([bash -c "echo -n $(cat ../.version)$VERSION_SUFFIX"]))
|
||||
AC_CONFIG_SRCDIR(MANIFEST)
|
||||
AC_CONFIG_AUX_DIR(../config)
|
||||
|
||||
CFLAGS=
|
||||
CXXFLAGS=
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
AC_DEFUN([NEED_PROG],
|
||||
[
|
||||
AC_PATH_PROG($1, $2)
|
||||
if test -z "$$1"; then
|
||||
AC_MSG_ERROR([$2 is required])
|
||||
fi
|
||||
])
|
||||
|
||||
NEED_PROG(perl, perl)
|
||||
NEED_PROG(curl, curl)
|
||||
NEED_PROG(bzip2, bzip2)
|
||||
NEED_PROG(xz, xz)
|
||||
|
||||
# Test that Perl has the open/fork feature (Perl 5.8.0 and beyond).
|
||||
AC_MSG_CHECKING([whether Perl is recent enough])
|
||||
if ! $perl -e 'open(FOO, "-|", "true"); while (<FOO>) { print; }; close FOO or die;'; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([Your Perl version is too old. Nix requires Perl 5.8.0 or newer.])
|
||||
fi
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
|
||||
# Figure out where to install Perl modules.
|
||||
AC_MSG_CHECKING([for the Perl installation prefix])
|
||||
perlversion=$($perl -e 'use Config; print $Config{version};')
|
||||
perlarchname=$($perl -e 'use Config; print $Config{archname};')
|
||||
AC_SUBST(perllibdir, [${libdir}/perl5/site_perl/$perlversion/$perlarchname])
|
||||
AC_MSG_RESULT($perllibdir)
|
||||
|
||||
# Look for libsodium.
|
||||
PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"])
|
||||
|
||||
# Check for the required Perl dependencies (DBI and DBD::SQLite).
|
||||
perlFlags="-I$perllibdir"
|
||||
|
||||
AC_ARG_WITH(dbi, AC_HELP_STRING([--with-dbi=PATH],
|
||||
[prefix of the Perl DBI library]),
|
||||
perlFlags="$perlFlags -I$withval")
|
||||
|
||||
AC_ARG_WITH(dbd-sqlite, AC_HELP_STRING([--with-dbd-sqlite=PATH],
|
||||
[prefix of the Perl DBD::SQLite library]),
|
||||
perlFlags="$perlFlags -I$withval")
|
||||
|
||||
AC_MSG_CHECKING([whether DBD::SQLite works])
|
||||
if ! $perl $perlFlags -e 'use DBI; use DBD::SQLite;' 2>&5; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_FAILURE([The Perl modules DBI and/or DBD::SQLite are missing.])
|
||||
fi
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
AC_SUBST(perlFlags)
|
||||
|
||||
PKG_CHECK_MODULES([NIX], [nix-store])
|
||||
|
||||
NEED_PROG([NIX], [nix])
|
||||
|
||||
# Expand all variables in config.status.
|
||||
test "$prefix" = NONE && prefix=$ac_default_prefix
|
||||
test "$exec_prefix" = NONE && exec_prefix='${prefix}'
|
||||
for name in $ac_subst_vars; do
|
||||
declare $name="$(eval echo "${!name}")"
|
||||
declare $name="$(eval echo "${!name}")"
|
||||
declare $name="$(eval echo "${!name}")"
|
||||
done
|
||||
|
||||
rm -f Makefile.config
|
||||
ln -sfn ../mk mk
|
||||
|
||||
AC_CONFIG_FILES([])
|
||||
AC_OUTPUT
|
@ -1,47 +1,52 @@
|
||||
{ lib, fileset
|
||||
{ lib
|
||||
, fileset
|
||||
, stdenv
|
||||
, perl, perlPackages
|
||||
, autoconf-archive, autoreconfHook, pkg-config
|
||||
, nix, curl, bzip2, xz, boost, libsodium, darwin
|
||||
, perl
|
||||
, perlPackages
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
, nix
|
||||
, curl
|
||||
, bzip2
|
||||
, xz
|
||||
, boost
|
||||
, libsodium
|
||||
, darwin
|
||||
}:
|
||||
|
||||
perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
|
||||
name = "nix-perl-${nix.version}";
|
||||
|
||||
src = fileset.toSource {
|
||||
root = ../.;
|
||||
root = ./.;
|
||||
fileset = fileset.unions ([
|
||||
../.version
|
||||
../m4
|
||||
../mk
|
||||
./MANIFEST
|
||||
./Makefile
|
||||
./Makefile.config.in
|
||||
./configure.ac
|
||||
./lib
|
||||
./local.mk
|
||||
./meson.build
|
||||
./meson_options.txt
|
||||
] ++ lib.optionals finalAttrs.doCheck [
|
||||
./.yath.rc
|
||||
./t
|
||||
]);
|
||||
};
|
||||
|
||||
nativeBuildInputs =
|
||||
[ autoconf-archive
|
||||
autoreconfHook
|
||||
pkg-config
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
[ nix
|
||||
curl
|
||||
bzip2
|
||||
xz
|
||||
perl
|
||||
boost
|
||||
]
|
||||
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
||||
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
|
||||
buildInputs = [
|
||||
nix
|
||||
curl
|
||||
bzip2
|
||||
xz
|
||||
perl
|
||||
boost
|
||||
]
|
||||
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
||||
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
|
||||
|
||||
# `perlPackages.Test2Harness` is marked broken for Darwin
|
||||
doCheck = !stdenv.isDarwin;
|
||||
@ -50,12 +55,16 @@ perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: {
|
||||
perlPackages.Test2Harness
|
||||
];
|
||||
|
||||
configureFlags = [
|
||||
"--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
|
||||
"--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}"
|
||||
mesonFlags = [
|
||||
(lib.mesonOption "version" (builtins.readFile ../.version))
|
||||
(lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}")
|
||||
(lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}")
|
||||
(lib.mesonEnable "tests" finalAttrs.doCheck)
|
||||
];
|
||||
|
||||
mesonCheckFlags = [
|
||||
"--print-errorlogs"
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postUnpack = "sourceRoot=$sourceRoot/perl";
|
||||
}))
|
||||
|
59
perl/lib/Nix/meson.build
Normal file
59
perl/lib/Nix/meson.build
Normal file
@ -0,0 +1,59 @@
|
||||
# Nix-Perl Scripts
|
||||
#============================================================================
|
||||
|
||||
|
||||
|
||||
# Sources
|
||||
#-------------------------------------------------
|
||||
|
||||
nix_perl_store_xs = files('Store.xs')
|
||||
|
||||
nix_perl_scripts = files(
|
||||
'CopyClosure.pm',
|
||||
'Manifest.pm',
|
||||
'SSH.pm',
|
||||
'Store.pm',
|
||||
'Utils.pm',
|
||||
)
|
||||
|
||||
foreach f : nix_perl_scripts
|
||||
fs.copyfile(f)
|
||||
endforeach
|
||||
|
||||
|
||||
# Targets
|
||||
#---------------------------------------------------
|
||||
|
||||
nix_perl_scripts += configure_file(
|
||||
output : 'Config.pm',
|
||||
input : 'Config.pm.in',
|
||||
configuration : nix_perl_conf,
|
||||
)
|
||||
|
||||
nix_perl_store_cc = custom_target(
|
||||
'Store.cc',
|
||||
output : 'Store.cc',
|
||||
input : nix_perl_store_xs,
|
||||
command : [xsubpp, '@INPUT@', '-output', '@OUTPUT@'],
|
||||
)
|
||||
|
||||
# Build Nix::Store Library
|
||||
#-------------------------------------------------
|
||||
nix_perl_store_lib = library(
|
||||
'Store',
|
||||
sources : nix_perl_store_cc,
|
||||
name_prefix : '',
|
||||
install : true,
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : join_paths(nix_perl_install_dir, 'auto', 'Nix', 'Store'),
|
||||
dependencies : nix_perl_store_dep_list,
|
||||
)
|
||||
|
||||
|
||||
# Install Scripts
|
||||
#---------------------------------------------------
|
||||
install_data(
|
||||
nix_perl_scripts,
|
||||
install_mode : 'rw-r--r--',
|
||||
install_dir : join_paths(nix_perl_install_dir,'Nix'),
|
||||
)
|
@ -1,46 +0,0 @@
|
||||
nix_perl_sources := \
|
||||
lib/Nix/Store.pm \
|
||||
lib/Nix/Manifest.pm \
|
||||
lib/Nix/SSH.pm \
|
||||
lib/Nix/CopyClosure.pm \
|
||||
lib/Nix/Config.pm.in \
|
||||
lib/Nix/Utils.pm
|
||||
|
||||
nix_perl_modules := $(nix_perl_sources:.in=)
|
||||
|
||||
$(foreach x, $(nix_perl_modules), $(eval $(call install-data-in, $(x), $(perllibdir)/Nix)))
|
||||
|
||||
lib/Nix/Store.cc: lib/Nix/Store.xs
|
||||
$(trace-gen) xsubpp $^ -output $@
|
||||
|
||||
libraries += Store
|
||||
|
||||
Store_DIR := lib/Nix
|
||||
|
||||
Store_SOURCES := $(Store_DIR)/Store.cc
|
||||
|
||||
Store_CXXFLAGS = \
|
||||
$(NIX_CFLAGS) \
|
||||
-I$(shell perl -e 'use Config; print $$Config{archlibexp};')/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
|
||||
|
||||
Store_LDFLAGS := $(SODIUM_LIBS) $(NIX_LIBS)
|
||||
|
||||
ifdef HOST_CYGWIN
|
||||
archlib = $(shell perl -E 'use Config; print $$Config{archlib};')
|
||||
libperl = $(shell perl -E 'use Config; print $$Config{libperl};')
|
||||
Store_LDFLAGS += $(shell find ${archlib} -name ${libperl})
|
||||
endif
|
||||
|
||||
Store_ALLOW_UNDEFINED = 1
|
||||
|
||||
Store_FORCE_INSTALL = 1
|
||||
|
||||
Store_INSTALL_DIR = $(perllibdir)/auto/Nix/Store
|
||||
|
||||
clean-files += lib/Nix/Config.pm lib/Nix/Store.cc Makefile.config
|
||||
|
||||
check: all
|
||||
yath test
|
152
perl/meson.build
Normal file
152
perl/meson.build
Normal file
@ -0,0 +1,152 @@
|
||||
# Nix-Perl Meson build
|
||||
#============================================================================
|
||||
|
||||
|
||||
# init project
|
||||
#============================================================================
|
||||
project (
|
||||
'nix-perl',
|
||||
'cpp',
|
||||
meson_version : '>= 0.64.0',
|
||||
license : 'LGPL-2.1-or-later',
|
||||
)
|
||||
|
||||
# setup env
|
||||
#-------------------------------------------------
|
||||
fs = import('fs')
|
||||
nix_version = get_option('version')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
nix_perl_conf = configuration_data()
|
||||
nix_perl_conf.set('PACKAGE_VERSION', nix_version)
|
||||
|
||||
|
||||
# set error arguments
|
||||
#-------------------------------------------------
|
||||
error_args = [
|
||||
'-Wno-pedantic',
|
||||
'-Wno-non-virtual-dtor',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-variadic-macros',
|
||||
'-Wdeprecated-declarations',
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-unknown-warning-option',
|
||||
'-Wno-unused-variable',
|
||||
'-Wno-literal-suffix',
|
||||
'-Wno-reserved-user-defined-literal',
|
||||
'-Wno-duplicate-decl-specifier',
|
||||
'-Wno-pointer-bool-conversion',
|
||||
]
|
||||
|
||||
add_project_arguments(
|
||||
cpp.get_supported_arguments(error_args),
|
||||
language : 'cpp',
|
||||
)
|
||||
|
||||
|
||||
# set install directories
|
||||
#-------------------------------------------------
|
||||
prefix = get_option('prefix')
|
||||
libdir = join_paths(prefix, get_option('libdir'))
|
||||
|
||||
# Dependencies
|
||||
#============================================================================
|
||||
|
||||
# Required Programs
|
||||
#-------------------------------------------------
|
||||
xz = find_program('xz')
|
||||
xsubpp = find_program('xsubpp')
|
||||
perl = find_program('perl')
|
||||
curl = find_program('curl')
|
||||
yath = find_program('yath', required : false)
|
||||
|
||||
# Required Libraries
|
||||
#-------------------------------------------------
|
||||
bzip2_dep = dependency('bzip2')
|
||||
curl_dep = dependency('libcurl')
|
||||
libsodium_dep = dependency('libsodium')
|
||||
# nix_util_dep = dependency('nix-util')
|
||||
nix_store_dep = dependency('nix-store')
|
||||
|
||||
|
||||
# Finding Perl Headers is a pain. as they do not have
|
||||
# pkgconfig available, are not in a standard location,
|
||||
# and are installed into a version folder. Use the
|
||||
# Perl binary to give hints about perl include dir.
|
||||
#-------------------------------------------------
|
||||
perl_archname = run_command(
|
||||
perl, '-e', 'use Config; print $Config{archname};', check: true).stdout()
|
||||
perl_version = run_command(
|
||||
perl, '-e', 'use Config; print $Config{version};', check: true).stdout()
|
||||
perl_archlibexp = run_command(
|
||||
perl, '-e', 'use Config; print $Config{archlibexp};', check: true).stdout()
|
||||
perl_site_libdir = run_command(
|
||||
perl, '-e', 'use Config; print $Config{installsitearch};', check: true).stdout()
|
||||
nix_perl_install_dir = join_paths(
|
||||
libdir, 'perl5', 'site_perl', perl_version, perl_archname)
|
||||
|
||||
|
||||
# print perl hints for logs
|
||||
#-------------------------------------------------
|
||||
message('Perl archname: @0@'.format(perl_archname))
|
||||
message('Perl version: @0@'.format(perl_version))
|
||||
message('Perl archlibexp: @0@'.format(perl_archlibexp))
|
||||
message('Perl install site: @0@'.format(perl_site_libdir))
|
||||
message('Assumed Nix-Perl install dir: @0@'.format(nix_perl_install_dir))
|
||||
|
||||
# Now find perl modules
|
||||
#-------------------------------------------------
|
||||
perl_check_dbi = run_command(
|
||||
perl,
|
||||
'-e', 'use DBI; use DBD::SQLite;',
|
||||
'-I@0@'.format(get_option('dbi_path')),
|
||||
'-I@0@'.format(get_option('dbd_sqlite_path')),
|
||||
check: true
|
||||
)
|
||||
|
||||
if perl_check_dbi.returncode() == 2
|
||||
error('The Perl modules DBI and/or DBD::SQLite are missing.')
|
||||
else
|
||||
message('Found Perl Modules: DBI, DBD::SQLite.')
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# declare perl dependency
|
||||
#-------------------------------------------------
|
||||
perl_dep = declare_dependency(
|
||||
dependencies : cpp.find_library(
|
||||
'perl',
|
||||
has_headers : [
|
||||
join_paths(perl_archlibexp, 'CORE', 'perl.h'),
|
||||
join_paths(perl_archlibexp, 'CORE', 'EXTERN.h')],
|
||||
dirs : [
|
||||
join_paths(perl_archlibexp, 'CORE'),
|
||||
],
|
||||
),
|
||||
include_directories : join_paths(perl_archlibexp, 'CORE'),
|
||||
)
|
||||
|
||||
# declare dependencies
|
||||
#-------------------------------------------------
|
||||
nix_perl_store_dep_list = [
|
||||
perl_dep,
|
||||
bzip2_dep,
|
||||
curl_dep,
|
||||
libsodium_dep,
|
||||
nix_store_dep,
|
||||
]
|
||||
|
||||
# # build
|
||||
# #-------------------------------------------------
|
||||
subdir('lib/Nix')
|
||||
|
||||
if get_option('tests').enabled()
|
||||
subdir('t')
|
||||
test(
|
||||
'nix-perl-test',
|
||||
yath,
|
||||
args : [
|
||||
'-I=@0@'.format( join_paths( meson.current_build_dir(), 'lib', 'Nix') ),
|
||||
],
|
||||
)
|
||||
endif
|
32
perl/meson_options.txt
Normal file
32
perl/meson_options.txt
Normal file
@ -0,0 +1,32 @@
|
||||
# Nix-Perl build options
|
||||
#============================================================================
|
||||
|
||||
|
||||
# compiler args
|
||||
#============================================================================
|
||||
|
||||
option(
|
||||
'version',
|
||||
type : 'string',
|
||||
description : 'nix-perl version')
|
||||
|
||||
option(
|
||||
'tests',
|
||||
type : 'feature',
|
||||
value : 'disabled',
|
||||
description : 'run nix-perl tests')
|
||||
|
||||
|
||||
# Location of Perl Modules
|
||||
#============================================================================
|
||||
option(
|
||||
'dbi_path',
|
||||
type : 'string',
|
||||
value : '/usr',
|
||||
description : 'path to perl::dbi')
|
||||
|
||||
option(
|
||||
'dbd_sqlite_path',
|
||||
type : 'string',
|
||||
value : '/usr',
|
||||
description : 'path to perl::dbd-SQLite')
|
15
perl/t/meson.build
Normal file
15
perl/t/meson.build
Normal file
@ -0,0 +1,15 @@
|
||||
# Nix-Perl Tests
|
||||
#============================================================================
|
||||
|
||||
|
||||
# src
|
||||
#---------------------------------------------------
|
||||
|
||||
nix_perl_tests = files(
|
||||
'init.t',
|
||||
)
|
||||
|
||||
|
||||
foreach f : nix_perl_tests
|
||||
fs.copyfile(f)
|
||||
endforeach
|
Loading…
Reference in New Issue
Block a user