summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorTausif Rahman <tausif.rahman@mongodb.com>2022-06-29 17:59:30 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-29 20:57:10 +0000
commit0dd56eb0358262ee0af4d2b172ec53c62ebb0233 (patch)
treec6a8add6ac099a4c73837074cace788daa018281 /site_scons
parent22f51064e1697fc94518b4bae8b6beb7c5b10bd7 (diff)
downloadmongo-0dd56eb0358262ee0af4d2b172ec53c62ebb0233.tar.gz
SERVER-66938 Drastically simplify command to generate ninja files
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/mongo/build_profiles.py92
-rw-r--r--site_scons/site_tools/ninja.py7
2 files changed, 98 insertions, 1 deletions
diff --git a/site_scons/mongo/build_profiles.py b/site_scons/mongo/build_profiles.py
new file mode 100644
index 00000000000..37a2520c879
--- /dev/null
+++ b/site_scons/mongo/build_profiles.py
@@ -0,0 +1,92 @@
+"""Dictionary to store available build profiles."""
+from dataclasses import dataclass
+from typing import Any, List, Optional
+import mongo.generators as mongo_generators
+
+
+@dataclass
+class BuildProfile:
+ ninja: str
+ variables_files: List
+ allocator: str
+ sanitize: Optional[str]
+ link_model: str
+ dbg: str
+ opt: str
+ ICECC: Optional[str]
+ CCACHE: Optional[str]
+ NINJA_PREFIX: str
+ VARIANT_DIR: Any
+
+
+BUILD_PROFILES = {
+ # These options were the default settings before implementing build profiles.
+ "default":
+ BuildProfile(
+ ninja="disabled",
+ variables_files=[],
+ allocator="auto",
+ sanitize=None,
+ link_model="auto",
+ dbg="off",
+ opt="off",
+ ICECC=None,
+ CCACHE=None,
+ NINJA_PREFIX="build",
+ VARIANT_DIR=mongo_generators.default_variant_dir_generator,
+ ),
+ # This build has fast runtime speed & fast build time at the cost of debuggability.
+ "fast":
+ BuildProfile(
+ ninja="enabled",
+ variables_files=[
+ './etc/scons/mongodbtoolchain_stable_clang.vars',
+ './etc/scons/developer_versions.vars',
+ ],
+ allocator="auto",
+ sanitize=None,
+ link_model="dynamic",
+ dbg="off",
+ opt="on",
+ ICECC="icecc",
+ CCACHE="ccache",
+ NINJA_PREFIX="fast",
+ VARIANT_DIR="fast",
+ ),
+ # This build has fast runtime speed & debuggability at the cost of build time.
+ "opt":
+ BuildProfile(
+ ninja="enabled",
+ variables_files=[
+ './etc/scons/mongodbtoolchain_stable_clang.vars',
+ './etc/scons/developer_versions.vars',
+ ],
+ allocator="auto",
+ sanitize=None,
+ link_model="dynamic",
+ dbg="on",
+ opt="on",
+ ICECC="icecc",
+ CCACHE="ccache",
+ NINJA_PREFIX="opt",
+ VARIANT_DIR="opt",
+ ),
+ # This build leverages santizers & is the suggested build profile to use for development.
+ "san":
+ BuildProfile(
+ ninja="enabled",
+ variables_files=[
+ './etc/scons/mongodbtoolchain_stable_clang.vars',
+ './etc/scons/developer_versions.vars',
+ ],
+ allocator="system",
+ sanitize="undefined,address",
+ link_model="dynamic",
+ dbg="on",
+ opt="off",
+ ICECC="icecc",
+ CCACHE="ccache",
+ NINJA_PREFIX="san",
+ VARIANT_DIR="san",
+ ),
+}
diff --git a/site_scons/site_tools/ninja.py b/site_scons/site_tools/ninja.py
index 97b9d25665f..5c1af72db2b 100644
--- a/site_scons/site_tools/ninja.py
+++ b/site_scons/site_tools/ninja.py
@@ -1498,7 +1498,6 @@ def generate(env):
ninja_file_name = env.subst("${NINJA_PREFIX}.${NINJA_SUFFIX}")
ninja_file = env.Ninja(target=ninja_file_name, source=[])
env.AlwaysBuild(ninja_file)
- env.Alias("$NINJA_ALIAS_NAME", ninja_file)
# TODO: API for getting the SConscripts programmatically
# exists upstream: https://github.com/SCons/scons/issues/3625
@@ -1618,6 +1617,12 @@ def generate(env):
if not exists(env):
return
+ # There is a target called generate-ninja which needs to be included
+ # with the --ninja flag in order to generate the ninja file. Because the --ninja
+ # flag is ONLY used with generate-ninja, we have combined the two by making the --ninja flag
+ # implicitly build the generate-ninja target.
+ SCons.Script.BUILD_TARGETS = SCons.Script.TargetList(env.Alias("$NINJA_ALIAS_NAME", ninja_file))
+
# Set a known variable that other tools can query so they can
# behave correctly during ninja generation.
env["GENERATING_NINJA"] = True