summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2022-08-24 17:05:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-24 17:48:17 +0000
commit0054d395a55c60470f5747647a8a7988530d1a5f (patch)
treeb06a6a2705099d065c8e564d70cfe4d2753fd1a5 /SConstruct
parent11eb8bde753a498ec42775f89210d4c6ecbd5c2e (diff)
downloadmongo-0054d395a55c60470f5747647a8a7988530d1a5f.tar.gz
SERVER-48203 add precious and link-type install actions to ninja
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct49
1 files changed, 46 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct
index 04211f9eaa8..ee90c0b22e9 100755
--- a/SConstruct
+++ b/SConstruct
@@ -197,7 +197,7 @@ add_option(
add_option(
'install-action',
choices=([*install_actions.available_actions] + ['default']),
- default='default',
+ default='hardlink',
help=
'select mechanism to use to install files (advanced option to reduce disk IO and utilization)',
nargs=1,
@@ -1631,8 +1631,6 @@ unknown_vars = env_vars.UnknownVariables()
if unknown_vars:
env.FatalError("Unknown variables specified: {0}", ", ".join(list(unknown_vars.keys())))
-if get_option('install-action') != 'default' and get_option('ninja') != "disabled":
- env.FatalError("Cannot use non-default install actions when generating Ninja.")
install_actions.setup(env, get_option('install-action'))
@@ -5336,6 +5334,51 @@ if get_option('ninja') != 'disabled':
return dependencies
env['NINJA_REGENERATE_DEPS'] = ninja_generate_deps
+ if env.GetOption('install-action') == 'hardlink':
+ if env.TargetOSIs('windows'):
+ install_cmd = "cmd.exe /c mklink /h $out $in 1>nul"
+ else:
+ install_cmd = "ln $in $out"
+
+ elif env.GetOption('install-action') == 'symlink':
+
+ # macOS's ln and Windows mklink command do not support relpaths
+ # out of the box so we will precompute during generation in a
+ # custom handler.
+ def symlink_install_action_function(_env, node):
+ # should only be one output and input for this case
+ output_file = _env.NinjaGetOutputs(node)[0]
+ input_file = _env.NinjaGetDependencies(node)[0]
+ try:
+ relpath = os.path.relpath(input_file, os.path.dirname(output_file))
+ except ValueError:
+ relpath = os.path.abspath(input_file)
+
+ return {
+ "outputs": [output_file],
+ "rule": "INSTALL",
+ "inputs": [input_file],
+ "implicit": _env.NinjaGetDependencies(node),
+ "variables": {"precious": node.precious, "relpath": relpath},
+ }
+
+ env.NinjaRegisterFunctionHandler("installFunc", symlink_install_action_function)
+
+ if env.TargetOSIs('windows'):
+ install_cmd = "cmd.exe /c mklink $out $relpath 1>nul"
+ else:
+ install_cmd = "ln -s $relpath $out"
+
+ else:
+ if env.TargetOSIs('windows'):
+ # The /b option here will make sure that windows updates the mtime
+ # when copying the file. This allows to not need to use restat for windows
+ # copy commands.
+ install_cmd = "cmd.exe /c copy /b $in $out 1>NUL"
+ else:
+ install_cmd = "install $in $out"
+
+ env.NinjaRule("INSTALL", install_cmd, description="Installed $out", pool="install_pool")
if env.TargetOSIs("windows"):
# This is a workaround on windows for SERVER-48691 where the line length