@@ -22,6 +22,8 @@ SCons construction environment can be customized in sconscript.local script.
2222
2323import os
2424import platform
25+ from os .path import join as pjoin
26+ from SCons .Script import *
2527
2628def subdictionary (d , keyset ):
2729 return dict (kv for kv in d .items () if kv [0 ] in keyset )
@@ -31,46 +33,82 @@ DefaultEnvironment(ENV=subdictionary(os.environ, '''
3133 PATH CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
3234 LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
3335 MACOSX_DEPLOYMENT_TARGET
36+ HOME USERPROFILE HOMEDRIVE HOMEPATH APPDATA LOCALAPPDATA
3437 ''' .split ())
3538)
3639
3740# Create construction environment
3841env = DefaultEnvironment ().Clone ()
3942
40- # Variables definitions below work only with 0.98.1 or later.
43+ # Variables definitions below work only with 0.98.1 or later
4144env .EnsureSConsVersion (0 , 98 , 1 )
4245
4346# Customizable compile variables
4447vars = Variables ('sconsvars.py' )
4548
46- vars .Add (PathVariable (
47- 'prefix' ,
48- 'installation prefix directory' ,
49- '/usr/local' ))
50- vars .Update (env )
49+ # Set PATHs
50+ if 'PREFIX' in os .environ :
51+ vars .Add (PathVariable (
52+ 'prefix' ,
53+ 'installation prefix directory' ,
54+ os .environ ['PREFIX' ]))
55+ vars .Update (env )
56+ elif 'CONDA_PREFIX' in os .environ :
57+ vars .Add (PathVariable (
58+ 'prefix' ,
59+ 'installation prefix directory' ,
60+ os .environ ['CONDA_PREFIX' ]))
61+ vars .Update (env )
62+ else :
63+ vars .Add (PathVariable (
64+ 'prefix' ,
65+ 'installation prefix directory' ,
66+ '/usr/local' ))
67+ vars .Update (env )
68+
69+ if env ['PLATFORM' ] == "win32" :
70+ include_path = pjoin (env ['prefix' ], 'Library' , 'include' )
71+ lib_path = pjoin (env ['prefix' ], 'Library' , 'lib' )
72+ shared_path = pjoin (env ['prefix' ], 'Library' , 'share' )
73+
74+ # Windows programs started by SCons, such as python for cxxtestgen,
75+ # fail without these system variables.
76+ for k in ('SYSTEMROOT' , 'SYSTEMDRIVE' , 'COMSPEC' , 'PATHEXT' , 'TEMP' , 'TMP' ):
77+ if k in os .environ :
78+ env ['ENV' ][k ] = os .environ [k ]
79+ else :
80+ include_path = pjoin (env ['prefix' ], 'include' )
81+ lib_path = pjoin (env ['prefix' ], 'lib' )
82+ shared_path = pjoin (env ['prefix' ], 'share' )
83+
5184vars .Add (PathVariable (
5285 'libdir' ,
53- 'installation directory for compiled library [prefix/lib] ' ,
54- env [ 'prefix' ] + '/lib' ,
86+ 'installation directory for compiled programs ' ,
87+ lib_path ,
5588 PathVariable .PathAccept ))
5689vars .Add (PathVariable (
5790 'includedir' ,
58- 'installation directory for C++ header files [prefix/include] ' ,
59- env [ 'prefix' ] + '/include' ,
91+ 'installation directory for C++ header files' ,
92+ include_path ,
6093 PathVariable .PathAccept ))
6194vars .Add (PathVariable (
6295 'datadir' ,
63- 'installation directory for architecture independent data [prefix/share] ' ,
64- env [ 'prefix' ] + '/share' ,
96+ 'installation directory for architecture independent data' ,
97+ shared_path ,
6598 PathVariable .PathAccept ))
99+
100+ env .AppendUnique (CPPPATH = [include_path ])
101+ env .AppendUnique (LIBPATH = [lib_path ])
102+
103+ # Customizable build variables
66104vars .Add (EnumVariable (
67105 'build' ,
68106 'compiler settings' ,
69107 'fast' , allowed_values = ('fast' , 'debug' , 'develop' , 'coverage' )))
70108vars .Add (EnumVariable (
71109 'tool' ,
72110 'C++ compiler toolkit to be used' ,
73- 'default' , allowed_values = ('default' , 'intelc' )))
111+ 'default' , allowed_values = ('default' , 'clang' , 'gcc' , ' intelc' )))
74112vars .Add (BoolVariable (
75113 'enable_objcryst' ,
76114 'enable objcryst support, when installed' , None ))
@@ -83,10 +121,13 @@ vars.Add(
83121vars .Add (BoolVariable (
84122 'test_installed' ,
85123 'build tests using the installed library.' , False ))
124+
86125vars .Update (env )
126+
87127env .Help (MY_SCONS_HELP % vars .GenerateHelpText (env ))
88128
89129env ['has_objcryst' ] = None
130+
90131btags = [env ['build' ], platform .machine ()]
91132if env ['profile' ]: btags .append ('profile' )
92133builddir = env .Dir ('build/' + '-' .join (btags ))
0 commit comments