Skip to content

Commit

Permalink
Merge pull request NixOS#9 from Ericson2314/meson-improvements
Browse files Browse the repository at this point in the history
Meson improvements
  • Loading branch information
polar authored Jul 26, 2021
2 parents 9c60e6a + e6b5b06 commit b2c9b76
Show file tree
Hide file tree
Showing 31 changed files with 407 additions and 366 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Makefile.config
perl/Makefile.config

# /
/build
/aclocal.m4
/autom4te.cache
/precompiled-headers.h.gch
Expand Down
43 changes: 27 additions & 16 deletions dependencies/aws-sdk-cpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,43 @@

# Look for aws-cpp-sdk, an optional dependency
#--------------------------------------------------
if get_option('with_s3')
s3_deps = [
dependency('aws-cpp-sdk-core', required: get_option('with_s3')),
dependency('aws-cpp-sdk-s3', required: get_option('with_s3')),
dependency('aws-cpp-sdk-transfer', required: get_option('with_s3'))
]

has_s3client = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h')
have_s3 = true
foreach d : s3_deps
have_s3 = have_s3 and d.found()
endforeach

aws_version = meson.get_compiler('cpp').get_define(
'AWS_SDK_VERSION_STRING',
prefix : '#include <aws/core/VersionConfig.h>'
).strip('"').split('.')
aws_sdk_cpp_dep = declare_dependency(dependencies : s3_deps)

config_h.set(
'ENABLE_S3',
have_s3.to_int(),
description : 'Whether to enable S3 support via aws-sdk-cpp.')

if have_s3

aws_sdk_cpp_dep = declare_dependency(
dependencies : [
dependency('aws-cpp-sdk-core'),
dependency('aws-cpp-sdk-s3'),
dependency('aws-cpp-sdk-transfer')])
has_s3client = cpp.check_header(
'aws/s3/S3Client.h',
dependencies: aws_sdk_cpp_dep,
)

if has_s3client
config_h.set(
'HAVE_AWS_S3_S3CLIENT_H', 1,
description : 'Whether to enable S3 support via aws-sdk-cpp.')
endif

aws_version = cpp.get_define(
'AWS_SDK_VERSION_STRING',
prefix : '#include <aws/core/VersionConfig.h>',
dependencies: aws_sdk_cpp_dep,
).strip('"').split('.')

config_h.set(
'AWS_VERSION_MAJOR', aws_version[0],
description : 'Major version of aws-sdk-cpp.')
Expand All @@ -36,9 +52,4 @@ if get_option('with_s3')
'AWS_VERSION_PATCH', aws_version[2],
description : 'Patch version of aws-sdk-cpp.')

else
aws_sdk_cpp_dep = dependency('', required: false)
config_h.set(
'ENABLE_S3', 0,
description : 'Whether to enable S3 support via aws-sdk-cpp.')
endif
6 changes: 1 addition & 5 deletions dependencies/bdw-gc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

# Look for Boehm garbage collector, an optional dependency
#--------------------------------------------------
if get_option('enable_gc')
gc_dep = dependency('bdw-gc')
else
gc_dep = dependency('', required: false)
endif
gc_dep = dependency('bdw-gc', required: get_option('enable_gc'))


config_h.set(
Expand Down
3 changes: 2 additions & 1 deletion dependencies/boost/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
boost_mod_list = [
'system',
'context',
'thread']
'thread',
]


boost_dep = dependency(
Expand Down
13 changes: 8 additions & 5 deletions dependencies/editline/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

editline_dep = cpp.find_library('editline')

if (cpp.has_header('editline.h'))
config_h.set(
'HAVE_EDITLINE_H', 1,
description : 'Define to 1 if you have the <editline.h> header file.')
else
if not (
cpp.has_header(
'editline.h',
dependencies : editline_dep))
error('Nix requires editline.h; however the header was not found.')
endif

config_h.set(
'HAVE_EDITLINE_H', 1,
description : 'Define to 1 if you have the <editline.h> header file.')

if not (
cpp.has_function(
'read_history',
Expand Down
3 changes: 3 additions & 0 deletions dependencies/sodium/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# FIXME !! sodium is seemingly a required dependency for building, but
# it isn't listed anywhere on documentation that i could find. dependency
# object needs to be added to meson.
#
# 0df69d96e02ce4c9e17bd33333c5d78313341dd3 made it required but docs were not
# updated.

# look for libsodium, a required dependency
#--------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
#-------------------------------------------------
project(
'nix',
['cpp', 'rust'],
'cpp',
meson_version : '>= 0.57.0',
default_options : [
'cpp_std=c++17',
'warning_level=3',
'optimization=3',
'debug=true'],
'debug=true'
],
version : files('.version'),
license : 'MIT')
license : 'MIT',
)


# init compiler
Expand Down Expand Up @@ -226,8 +228,8 @@ project_dirs = [
'scripts',
#'misc',
#'doc',
#'tests'
]
#'tests',
]


foreach dir : project_dirs
Expand Down
15 changes: 5 additions & 10 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ option(
'-Wno-unused-parameter',
'-Wno-variadic-macros',
'-Wdeprecated-declarations',
'-Wno-missing-field-initializers'],
'-Wno-missing-field-initializers',
],
description : 'C build flags')


Expand All @@ -42,20 +43,14 @@ option(

option(
'enable_gc',
type : 'boolean',
value : 'true',
description : 'Build nix with Boehm garbage collector')

option(
'with_libsodium',
type : 'feature',
value : 'auto',
description : 'Build nix with libsodium')
description : 'Build nix with Boehm garbage collector')

option(
'with_s3',
type : 'boolean',
value : 'false',
type : 'feature',
value : 'auto',
description : 'Build nix with s3')

option(
Expand Down
7 changes: 4 additions & 3 deletions scripts/meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Nix corepkgs build file
#============================================================================

scripts_dir = meson.current_source_dir()
scripts_inc = [include_directories('.')]


# src files
#============================================================================

scripts_data = files(
join_paths(scripts_dir, 'install-darwin-multi-user.sh'),
join_paths(scripts_dir, 'install-multi-user.sh'))
'install-darwin-multi-user.sh',
'install-multi-user.sh',
)



# targets
Expand Down
4 changes: 2 additions & 2 deletions src/build-remote/meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# build-remote build file
#============================================================================

build_remote_dir = meson.current_source_dir()
build_remote_inc = [include_directories('.')]


# src files
#============================================================================

build_remote_src = files(
join_paths(build_remote_dir, 'build-remote.cc'))
'build-remote.cc',
)


build_remote_headers = files()
19 changes: 10 additions & 9 deletions src/libcmd/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# libmain build file
#============================================================================

libcmd_dir = meson.current_source_dir()
libcmd_inc = [include_directories('.')]


Expand All @@ -28,17 +27,19 @@ libcmd_dep_list = [
#============================================================================

libcmd_src = files(
join_paths(libcmd_dir, 'command.cc'),
join_paths(libcmd_dir, 'installables.cc'),
join_paths(libcmd_dir, 'legacy.cc'),
join_paths(libcmd_dir, 'markdown.cc'))
'command.cc',
'installables.cc',
'legacy.cc',
'markdown.cc',
)


libcmd_headers = files(
join_paths(libcmd_dir, 'command.hh'),
join_paths(libcmd_dir, 'installables.hh'),
join_paths(libcmd_dir, 'legacy.hh'),
join_paths(libcmd_dir, 'markdown.hh'))
'command.hh',
'installables.hh',
'legacy.hh',
'markdown.hh',
)


# build
Expand Down
16 changes: 9 additions & 7 deletions src/libexpr/flake/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ libexpr_priomops_dir = meson.current_source_dir()
libexpr_inc += include_directories('.')

libexpr_src += files(
join_paths(libexpr_priomops_dir, 'config.cc'),
join_paths(libexpr_priomops_dir, 'flake.cc'),
join_paths(libexpr_priomops_dir, 'flakeref.cc'),
join_paths(libexpr_priomops_dir, 'lockfile.cc'))
'config.cc',
'flake.cc',
'flakeref.cc',
'lockfile.cc',
)

libexpr_headers += files(
join_paths(libexpr_priomops_dir, 'flake.hh'),
join_paths(libexpr_priomops_dir, 'flakeref.hh'),
join_paths(libexpr_priomops_dir, 'lockfile.hh'))
'flake.hh',
'flakeref.hh',
'lockfile.hh',
)


# targets
Expand Down
63 changes: 33 additions & 30 deletions src/libexpr/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Nix lib expr build file
#============================================================================

libexpr_dir = meson.current_source_dir()
libexpr_inc = proj_inc


Expand All @@ -24,36 +23,38 @@ libexpr_dep_list = [
#============================================================================

libexpr_src = files(
join_paths(libexpr_dir, 'attr-path.cc'),
join_paths(libexpr_dir, 'attr-set.cc'),
join_paths(libexpr_dir, 'common-eval-args.cc'),
join_paths(libexpr_dir, 'eval-cache.cc'),
join_paths(libexpr_dir, 'eval.cc'),
join_paths(libexpr_dir, 'function-trace.cc'),
join_paths(libexpr_dir, 'get-drvs.cc'),
join_paths(libexpr_dir, 'json-to-value.cc'),
join_paths(libexpr_dir, 'nixexpr.cc'),
join_paths(libexpr_dir, 'primops.cc'),
join_paths(libexpr_dir, 'value-to-json.cc'),
join_paths(libexpr_dir, 'value-to-xml.cc'))
'attr-path.cc',
'attr-set.cc',
'common-eval-args.cc',
'eval-cache.cc',
'eval.cc',
'function-trace.cc',
'get-drvs.cc',
'json-to-value.cc',
'nixexpr.cc',
'primops.cc',
'value-to-json.cc',
'value-to-xml.cc',
)


libexpr_headers = files(
join_paths(libexpr_dir, 'attr-path.hh'),
join_paths(libexpr_dir, 'attr-set.hh'),
join_paths(libexpr_dir, 'common-eval-args.hh'),
join_paths(libexpr_dir, 'eval-cache.hh'),
join_paths(libexpr_dir, 'eval.hh'),
join_paths(libexpr_dir, 'eval-inline.hh'),
join_paths(libexpr_dir, 'function-trace.hh'),
join_paths(libexpr_dir, 'get-drvs.hh'),
join_paths(libexpr_dir, 'json-to-value.hh'),
join_paths(libexpr_dir, 'nixexpr.hh'),
join_paths(libexpr_dir, 'primops.hh'),
join_paths(libexpr_dir, 'symbol-table.hh'),
join_paths(libexpr_dir, 'value.hh'),
join_paths(libexpr_dir, 'value-to-json.hh'),
join_paths(libexpr_dir, 'value-to-xml.hh'))
'attr-path.hh',
'attr-set.hh',
'common-eval-args.hh',
'eval-cache.hh',
'eval.hh',
'eval-inline.hh',
'function-trace.hh',
'get-drvs.hh',
'json-to-value.hh',
'nixexpr.hh',
'primops.hh',
'symbol-table.hh',
'value.hh',
'value-to-json.hh',
'value-to-xml.hh',
)


# include directories
Expand All @@ -68,7 +69,8 @@ libexpr_inc += include_directories('.')
#---------------------------------------------------
libexpr_dirs = [
'flake',
'primops']
'primops',
]

foreach dir : libexpr_dirs
subdir(dir)
Expand Down Expand Up @@ -135,7 +137,8 @@ libexpr_lib = library(
install_dir : libdir,
include_directories : [
libexpr_inc,
proj_inc],
proj_inc,
],
cpp_args : libexpr_cxx_args,
link_args : libexpr_link_args,
dependencies : libexpr_dep_list)
Expand Down
Loading

0 comments on commit b2c9b76

Please sign in to comment.