@@ -100,6 +100,20 @@ add_option('prefix',
100100 help = 'installation prefix' ,
101101)
102102
103+ add_option ('dest-dir' ,
104+ default = None ,
105+ help = 'root of installation as a subdirectory of $BUILD_DIR'
106+ )
107+
108+ add_option ('legacy-tarball' ,
109+ choices = ['true' , 'false' ],
110+ default = 'false' ,
111+ const = 'true' ,
112+ nargs = '?' ,
113+ type = 'choice' ,
114+ help = 'Build a tarball matching the old MongoDB dist targets' ,
115+ )
116+
103117add_option ('install-mode' ,
104118 choices = ['legacy' , 'hygienic' ],
105119 default = 'legacy' ,
@@ -947,9 +961,9 @@ if cacheDir[0] not in ['$', '#']:
947961 print ("Do not use relative paths with --cache-dir" )
948962 Exit (1 )
949963
950- installDir = get_option ('prefix' ).rstrip ('/' )
951- if installDir [0 ] not in ['$' , '#' ]:
952- if not os .path .isabs (installDir ):
964+ prefix = get_option ('prefix' ).rstrip ('/' )
965+ if prefix [0 ] not in ['$' , '#' ]:
966+ if not os .path .isabs (prefix ):
953967 print ("Do not use relative paths with --prefix" )
954968 Exit (1 )
955969
@@ -1029,12 +1043,33 @@ envDict = dict(BUILD_ROOT=buildDir,
10291043 BENCHMARK_LIST = '$BUILD_ROOT/benchmarks.txt' ,
10301044 CONFIGUREDIR = '$BUILD_ROOT/scons/$VARIANT_DIR/sconf_temp' ,
10311045 CONFIGURELOG = '$BUILD_ROOT/scons/config.log' ,
1032- INSTALL_DIR = installDir ,
1046+ PREFIX = get_option ( 'prefix' ) ,
10331047 CONFIG_HEADER_DEFINES = {},
10341048 LIBDEPS_TAG_EXPANSIONS = [],
10351049 )
10361050
10371051env = Environment (variables = env_vars , ** envDict )
1052+
1053+ if get_option ('dest-dir' ) is None :
1054+ destDir = env .Dir ('$BUILD_ROOT/install' )
1055+ prefix = env .Dir (get_option ('prefix' ))
1056+ if destDir != prefix :
1057+ installDir = destDir .Dir (get_option ('prefix' )[1 :])
1058+ else :
1059+ installDir = destDir
1060+ else :
1061+ destDir = get_option ('dest-dir' )
1062+ if destDir [0 ] not in ['$' , '#' ]:
1063+ if not os .path .isabs (destDir ):
1064+ print ("Do not use relative paths with --dest-dir" )
1065+ Exit (1 )
1066+ installDir = destDir
1067+
1068+ env ['INSTALL_DIR' ] = installDir
1069+ env ['DEST_DIR' ] = destDir
1070+ if get_option ('legacy-tarball' ) == 'true' :
1071+ env ['INSTALL_DIR' ] = env .Dir ('$INSTALL_DIR' ).Dir ('$SERVER_DIST_BASENAME' )
1072+
10381073del envDict
10391074
10401075for var in ['CC' , 'CXX' ]:
@@ -3633,10 +3668,65 @@ if get_option('install-mode') == 'hygienic':
36333668 env .Tool ('separate_debug' )
36343669
36353670 env .Tool ('auto_install_binaries' )
3671+ env .AddSuffixMapping ({
3672+ "$PROGSUFFIX" : env .SuffixMap (
3673+ directory = "$PREFIX_BIN_DIR" ,
3674+ default_roles = [
3675+ "runtime" ,
3676+ ]
3677+ ),
3678+
3679+ "$LIBSUFFIX" : env .SuffixMap (
3680+ directory = "$PREFIX_LIB_DIR" ,
3681+ default_roles = [
3682+ "dev" ,
3683+ ]
3684+ ),
3685+
3686+ "$SHLIBSUFFIX" : env .SuffixMap (
3687+ directory = "$PREFIX_BIN_DIR" \
3688+ if mongo_platform .get_running_os_name () == "windows" \
3689+ else "$PREFIX_LIB_DIR" ,
3690+ default_roles = [
3691+ "runtime" ,
3692+ ]
3693+ ),
3694+
3695+ ".debug" : env .SuffixMap (
3696+ directory = "$PREFIX_DEBUG_DIR" ,
3697+ default_roles = [
3698+ "debug" ,
3699+ ]
3700+ ),
3701+
3702+ ".dSYM" : env .SuffixMap (
3703+ directory = "$PREFIX_DEBUG_DIR" ,
3704+ default_roles = [
3705+ "debug"
3706+ ]
3707+ ),
3708+
3709+ ".lib" : env .SuffixMap (
3710+ directory = "$PREFIX_LIB_DIR" ,
3711+ default_roles = [
3712+ "dev"
3713+ ]
3714+ ),
3715+
3716+ ".h" : env .SuffixMap (
3717+ directory = "$PREFIX_INCLUDE_DIR" ,
3718+ default_roles = [
3719+ "dev" ,
3720+ ]
3721+ ),
3722+ })
3723+
36363724 if env ['PLATFORM' ] == 'posix' :
36373725 env .AppendUnique (
36383726 RPATH = [
3639- env .Literal ('\\ $$ORIGIN/../lib' )
3727+ # In the future when we want to improve dynamic builds
3728+ # we should set this to $PREFIX ideally
3729+ env .Literal ('\\ $$ORIGIN/../lib' ),
36403730 ],
36413731 LINKFLAGS = [
36423732 # Most systems *require* -z,origin to make origin work, but android
@@ -3957,10 +4047,6 @@ if should_dagger:
39574047 # Require everything to be built before trying to extract build dependency information
39584048 env .Requires (dependencyDb , allTargets )
39594049
3960- # We don't want installing files to cause them to flow into the cache,
3961- # since presumably we can re-install them from the origin if needed.
3962- env .NoCache (env .FindInstalledFiles ())
3963-
39644050# Declare the cache prune target
39654051cachePrune = env .Command (
39664052 target = "#cache-prune" ,
@@ -3974,6 +4060,13 @@ cachePrune = env.Command(
39744060env .AlwaysBuild (cachePrune )
39754061env .Alias ('cache-prune' , cachePrune )
39764062
4063+ if get_option ('install-mode' ) == 'hygienic' :
4064+ env .FinalizeInstallDependencies ()
4065+
4066+ # We don't want installing files to cause them to flow into the cache,
4067+ # since presumably we can re-install them from the origin if needed.
4068+ env .NoCache (env .FindInstalledFiles ())
4069+
39774070# Substitute environment variables in any build targets so that we can
39784071# say, for instance:
39794072#
0 commit comments