Generate a build.ninja file which explicitly sets DESTDIR to $BUILD_ROOT/install using either escaping (i.e. DESTDIR=\$BUILD_ROOT/install) or single-quoting (i.e. DESTDIR='$BUILD_ROOT/install'). For instance:
python buildscripts/scons.py CCFLAGS='-gsplit-dwarf' --variables-files=etc/scons/developer_versions.vars --disable-warnings-as-errors --link-model=dynamic --opt=off VARIANT_DIR=ninja DESTDIR=\$BUILD_ROOT/install --variables-files=etc/scons/mongodbtoolchain_stable_clang.vars --ninja --modules= --install-mode=hygienic ICECC=icecc CCACHE=ccache NINJA_PREFIX=build-mongo NINJA_SUFFIX=ninja generate-ninja
After the file is generated, the SCONS invocation recorded in build.ninja and the contents of resmoke.ini both appear correct:
SCONS_INVOCATION = /home/ubuntu/python-env/mongo-python3/bin/python "buildscripts/scons.py" $ "CCFLAGS=-gsplit-dwarf" "--variables-files=etc/scons/developer_versions.vars" $ "--disable-warnings-as-errors" "--link-model=dynamic" "--opt=off" "VARIANT_DIR=ninja" $ "DESTDIR=\$BUILD_ROOT/install" $ "--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars" "--ninja" "--modules=" $ "--install-mode=hygienic" "ICECC=icecc" "CCACHE=ccache" "NINJA_PREFIX=build-mongo" $ "NINJA_SUFFIX=ninja" __NINJA_NO=1 $out
[resmoke] install_dir = build/install/bin
However, if you now build the server using ninja, it will cause the resmoke.ini file to become corrupted:
[resmoke] install_dir = \\/install/bin
This will prevent any resmoke tests from being run:
buildscripts/resmoke.py run jstests/noPassthrough/change_stream_sharded_startafter_invalidate.js ... [j0] Starting mongod on port 20000... 'PATH=/home/ubuntu/mongo-dev/mongo:/data/multiversion:/home/ubuntu/mongo-dev/mongo/\\/install/bin:/home/ubuntu/python-env/mongo-python3/bin:/home/ubuntu/.nvm/versions/node/v16.4.0/bin:/opt/go/bin:/home/ubuntu/mongo/build/install/bin ... [j0] Failed to start mongod on port 20000: [Errno 2] No such file or directory: '/home/ubuntu/mongo-dev/mongo/\\\\/install/bin/mongod': '/home/ubuntu/mongo-dev/mongo/\\\\/install/bin/mongod'
If build.ninja is subsequently auto-regenerated due to any changes in SConstruct or Sconscript files, the build.ninja file will itself become similarly corrupted:
SCONS_INVOCATION = /home/ubuntu/python-env/mongo-python3/bin/python "buildscripts/scons.py" $ "CCFLAGS=-gsplit-dwarf" "--variables-files=etc/scons/developer_versions.vars" $ "--disable-warnings-as-errors" "--link-model=dynamic" "--opt=off" "VARIANT_DIR=ninja" $ "DESTDIR=\\/install" "--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars" $ "--ninja" "--modules=" "--install-mode=hygienic" "ICECC=icecc" "CCACHE=ccache" $ "NINJA_PREFIX=build-mongo" "NINJA_SUFFIX=ninja" __NINJA_NO=1 $out