mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 17:29:36 +01:00
Get rid of raw -D defines, always use private config files
Now that we have the private vs public distinction, we can do this
without leaking information downstream.
(cherry picked from commit 7a7fe350d5)
This commit is contained in:
parent
7e96f31753
commit
efb0feb22b
4 changed files with 75 additions and 103 deletions
|
|
@ -40,6 +40,8 @@ deps_private += gtest
|
|||
configdata = configuration_data()
|
||||
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||
|
||||
configdata.set_quoted('NIX_STORE_DIR', nix_store.get_variable('storedir'))
|
||||
|
||||
config_priv_h = configure_file(
|
||||
configuration : configdata,
|
||||
output : 'store-tests-config.hh',
|
||||
|
|
@ -89,7 +91,6 @@ this_exe = executable(
|
|||
include_directories : include_dirs,
|
||||
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
||||
link_args: linker_export_flags + ['-lrapidcheck'],
|
||||
cpp_args : [ '-DNIX_STORE_DIR="' + nix_store.get_variable('storedir') + '"' ],
|
||||
# get main from gtest
|
||||
install : true,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -154,12 +154,14 @@ endforeach
|
|||
|
||||
busybox = find_program(get_option('sandbox-shell'), required : false)
|
||||
|
||||
# This one goes in config.h
|
||||
# The path to busybox is passed as a -D flag when compiling this_library.
|
||||
# This solution is inherited from the old make buildsystem
|
||||
# TODO: do this differently?
|
||||
configdata_priv.set('HAVE_EMBEDDED_SANDBOX_SHELL', get_option('embedded-sandbox-shell').to_int())
|
||||
|
||||
if get_option('embedded-sandbox-shell')
|
||||
configdata_priv.set_quoted('SANDBOX_SHELL', '__embedded_sandbox_shell__')
|
||||
elif busybox.found()
|
||||
configdata_priv.set_quoted('SANDBOX_SHELL', busybox.full_path())
|
||||
endif
|
||||
|
||||
if get_option('embedded-sandbox-shell')
|
||||
hexdump = find_program('hexdump', native : true)
|
||||
embedded_sandbox_shell_gen = custom_target(
|
||||
|
|
@ -178,6 +180,66 @@ if get_option('embedded-sandbox-shell')
|
|||
generated_headers += embedded_sandbox_shell_gen
|
||||
endif
|
||||
|
||||
fs = import('fs')
|
||||
|
||||
prefix = get_option('prefix')
|
||||
# For each of these paths, assume that it is relative to the prefix unless
|
||||
# it is already an absolute path (which is the default for store-dir, localstatedir, and log-dir).
|
||||
path_opts = [
|
||||
# Meson built-ins.
|
||||
'datadir',
|
||||
'mandir',
|
||||
'libdir',
|
||||
'includedir',
|
||||
'libexecdir',
|
||||
# Homecooked Nix directories.
|
||||
'store-dir',
|
||||
'localstatedir',
|
||||
'log-dir',
|
||||
]
|
||||
# For your grepping pleasure, this loop sets the following variables that aren't mentioned
|
||||
# literally above:
|
||||
# store_dir
|
||||
# localstatedir
|
||||
# log_dir
|
||||
# profile_dir
|
||||
foreach optname : path_opts
|
||||
varname = optname.replace('-', '_')
|
||||
path = get_option(optname)
|
||||
if fs.is_absolute(path)
|
||||
set_variable(varname, path)
|
||||
else
|
||||
set_variable(varname, prefix / path)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
# sysconfdir doesn't get anything installed to directly, and is only used to
|
||||
# tell Nix where to look for nix.conf, so it doesn't get appended to prefix.
|
||||
sysconfdir = get_option('sysconfdir')
|
||||
if not fs.is_absolute(sysconfdir)
|
||||
sysconfdir = '/' / sysconfdir
|
||||
endif
|
||||
|
||||
# Aside from prefix itself, each of these was made into an absolute path
|
||||
# by joining it with prefix, unless it was already an absolute path
|
||||
# (which is the default for store-dir, localstatedir, and log-dir).
|
||||
configdata_priv.set_quoted('NIX_PREFIX', prefix)
|
||||
configdata_priv.set_quoted('NIX_STORE_DIR', store_dir)
|
||||
configdata_priv.set_quoted('NIX_DATA_DIR', datadir)
|
||||
configdata_priv.set_quoted('NIX_STATE_DIR', localstatedir / 'nix')
|
||||
configdata_priv.set_quoted('NIX_LOG_DIR', log_dir)
|
||||
configdata_priv.set_quoted('NIX_CONF_DIR', sysconfdir / 'nix')
|
||||
configdata_priv.set_quoted('NIX_MAN_DIR', mandir)
|
||||
|
||||
lsof = find_program('lsof', required : false)
|
||||
configdata_priv.set_quoted(
|
||||
'LSOF',
|
||||
lsof.found()
|
||||
? lsof.full_path()
|
||||
# Just look up on the PATH
|
||||
: 'lsof',
|
||||
)
|
||||
|
||||
config_priv_h = configure_file(
|
||||
configuration : configdata_priv,
|
||||
output : 'store-config-private.hh',
|
||||
|
|
@ -265,89 +327,6 @@ else
|
|||
subdir('unix')
|
||||
endif
|
||||
|
||||
fs = import('fs')
|
||||
|
||||
prefix = get_option('prefix')
|
||||
# For each of these paths, assume that it is relative to the prefix unless
|
||||
# it is already an absolute path (which is the default for store-dir, localstatedir, and log-dir).
|
||||
path_opts = [
|
||||
# Meson built-ins.
|
||||
'datadir',
|
||||
'mandir',
|
||||
'libdir',
|
||||
'includedir',
|
||||
'libexecdir',
|
||||
# Homecooked Nix directories.
|
||||
'store-dir',
|
||||
'localstatedir',
|
||||
'log-dir',
|
||||
]
|
||||
# For your grepping pleasure, this loop sets the following variables that aren't mentioned
|
||||
# literally above:
|
||||
# store_dir
|
||||
# localstatedir
|
||||
# log_dir
|
||||
# profile_dir
|
||||
foreach optname : path_opts
|
||||
varname = optname.replace('-', '_')
|
||||
path = get_option(optname)
|
||||
if fs.is_absolute(path)
|
||||
set_variable(varname, path)
|
||||
else
|
||||
set_variable(varname, prefix / path)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
# sysconfdir doesn't get anything installed to directly, and is only used to
|
||||
# tell Nix where to look for nix.conf, so it doesn't get appended to prefix.
|
||||
sysconfdir = get_option('sysconfdir')
|
||||
if not fs.is_absolute(sysconfdir)
|
||||
sysconfdir = '/' / sysconfdir
|
||||
endif
|
||||
|
||||
lsof = find_program('lsof', required : false)
|
||||
|
||||
# Aside from prefix itself, each of these was made into an absolute path
|
||||
# by joining it with prefix, unless it was already an absolute path
|
||||
# (which is the default for store-dir, localstatedir, and log-dir).
|
||||
cpp_str_defines = {
|
||||
'NIX_PREFIX': prefix,
|
||||
'NIX_STORE_DIR': store_dir,
|
||||
'NIX_DATA_DIR': datadir,
|
||||
'NIX_STATE_DIR': localstatedir / 'nix',
|
||||
'NIX_LOG_DIR': log_dir,
|
||||
'NIX_CONF_DIR': sysconfdir / 'nix',
|
||||
'NIX_MAN_DIR': mandir,
|
||||
}
|
||||
|
||||
if lsof.found()
|
||||
lsof_path = lsof.full_path()
|
||||
else
|
||||
# Just look up on the PATH
|
||||
lsof_path = 'lsof'
|
||||
endif
|
||||
cpp_str_defines += {
|
||||
'LSOF': lsof_path
|
||||
}
|
||||
|
||||
if get_option('embedded-sandbox-shell')
|
||||
cpp_str_defines += {
|
||||
'SANDBOX_SHELL': '__embedded_sandbox_shell__'
|
||||
}
|
||||
elif busybox.found()
|
||||
cpp_str_defines += {
|
||||
'SANDBOX_SHELL': busybox.full_path()
|
||||
}
|
||||
endif
|
||||
|
||||
cpp_args = []
|
||||
|
||||
foreach name, value : cpp_str_defines
|
||||
cpp_args += [
|
||||
'-D' + name + '=' + '"' + value + '"'
|
||||
]
|
||||
endforeach
|
||||
|
||||
subdir('nix-meson-build-support/export-all-symbols')
|
||||
subdir('nix-meson-build-support/windows-version')
|
||||
|
||||
|
|
@ -358,7 +337,6 @@ this_library = library(
|
|||
config_priv_h,
|
||||
dependencies : deps_public + deps_private + deps_other,
|
||||
include_directories : include_dirs,
|
||||
cpp_args : cpp_args,
|
||||
link_args: linker_export_flags,
|
||||
prelink : true, # For C++ static initializers
|
||||
install : true,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "man-pages.hh"
|
||||
#include "cli-config-private.hh"
|
||||
#include "nix/util/file-system.hh"
|
||||
#include "nix/util/current-process.hh"
|
||||
#include "nix/util/environment-variables.hh"
|
||||
|
|
|
|||
|
|
@ -39,13 +39,16 @@ configdata = configuration_data()
|
|||
configdata.set_quoted('NIX_CLI_VERSION', meson.project_version())
|
||||
|
||||
fs = import('fs')
|
||||
prefix = get_option('prefix')
|
||||
|
||||
bindir = get_option('bindir')
|
||||
if not fs.is_absolute(bindir)
|
||||
bindir = get_option('prefix') / bindir
|
||||
endif
|
||||
bindir = fs.is_absolute(bindir) ? bindir : prefix / bindir
|
||||
configdata.set_quoted('NIX_BIN_DIR', bindir)
|
||||
|
||||
mandir = get_option('mandir')
|
||||
mandir = fs.is_absolute(mandir) ? mandir : prefix / mandir
|
||||
configdata.set_quoted('NIX_MAN_DIR', mandir)
|
||||
|
||||
config_priv_h = configure_file(
|
||||
configuration : configdata,
|
||||
output : 'cli-config-private.hh',
|
||||
|
|
@ -174,16 +177,6 @@ if host_machine.system() != 'windows'
|
|||
]
|
||||
endif
|
||||
|
||||
fs = import('fs')
|
||||
prefix = get_option('prefix')
|
||||
|
||||
mandir = get_option('mandir')
|
||||
mandir = fs.is_absolute(mandir) ? mandir : prefix / mandir
|
||||
|
||||
cpp_args= [
|
||||
'-DNIX_MAN_DIR="@0@"'.format(mandir)
|
||||
]
|
||||
|
||||
include_dirs = [include_directories('.')]
|
||||
|
||||
this_exe = executable(
|
||||
|
|
@ -191,7 +184,6 @@ this_exe = executable(
|
|||
sources,
|
||||
dependencies : deps_private_subproject + deps_private + deps_other,
|
||||
include_directories : include_dirs,
|
||||
cpp_args : cpp_args,
|
||||
link_args: linker_export_flags,
|
||||
install : true,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue