@@ -17,11 +17,17 @@ SCons construction environment can be customized in sconscript.local script.
1717"""
1818
1919import os
20+ from os .path import join as pjoin
2021import platform
2122
2223def subdictionary (d , keyset ):
2324 return dict (kv for kv in d .items () if kv [0 ] in keyset )
2425
26+ def getsyspaths (* names ):
27+ pall = sum ((os .environ .get (n , '' ).split (os .pathsep ) for n in names ), [])
28+ rv = [p for p in pall if os .path .exists (p )]
29+ return rv
30+
2531# copy system environment variables related to compilation
2632DefaultEnvironment (ENV = subdictionary (os .environ , '''
2733 PATH CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
@@ -39,21 +45,52 @@ env.EnsureSConsVersion(0, 98, 1)
3945# Customizable compile variables
4046vars = Variables ('sconsvars.py' )
4147
42- vars .Add (PathVariable (
43- 'prefix' ,
44- 'installation prefix directory' ,
45- '/usr/local' ))
46- vars .Update (env )
47- vars .Add (PathVariable (
48- 'libdir' ,
49- 'installation directory for compiled library [prefix/lib]' ,
50- env ['prefix' ] + '/lib' ,
51- PathVariable .PathAccept ))
52- vars .Add (PathVariable (
53- 'includedir' ,
54- 'installation directory for C++ header files [prefix/include]' ,
55- env ['prefix' ] + '/include' ,
56- PathVariable .PathAccept ))
48+ if 'CONDA_PREFIX' in os .environ :
49+ # building for a conda environment
50+ vars .Add (PathVariable (
51+ 'prefix' ,
52+ 'installation prefix directory' ,
53+ os .environ ['CONDA_PREFIX' ]))
54+ vars .Update (env )
55+ if platform .system ().lower () == "windows" :
56+ vars .Add (PathVariable (
57+ 'libdir' ,
58+ 'installation directory for compiled library [prefix/Library/lib]' ,
59+ pjoin (env ['prefix' ],'Library' , 'Lib' ),
60+ PathVariable .PathAccept ))
61+ vars .Add (PathVariable (
62+ 'includedir' ,
63+ 'installation directory for C++ header files [prefix/Library/include]' ,
64+ pjoin (env ['prefix' ],'Library' , 'include' ),
65+ PathVariable .PathAccept ))
66+ else :
67+ vars .Add (PathVariable (
68+ 'libdir' ,
69+ 'installation directory for compiled library [prefix/lib]' ,
70+ pjoin (env ['prefix' ], 'Lib' ),
71+ PathVariable .PathAccept ))
72+ vars .Add (PathVariable (
73+ 'includedir' ,
74+ 'installation directory for C++ header files [prefix/include]' ,
75+ pjoin (env ['prefix' ], 'include' ),
76+ PathVariable .PathAccept ))
77+ else :
78+ vars .Add (PathVariable (
79+ 'prefix' ,
80+ 'installation prefix directory' ,
81+ '/usr/local' ))
82+ vars .Update (env )
83+ vars .Add (PathVariable (
84+ 'libdir' ,
85+ 'installation directory for compiled library [prefix/lib]' ,
86+ env ['prefix' ] + '/lib' ,
87+ PathVariable .PathAccept ))
88+ vars .Add (PathVariable (
89+ 'includedir' ,
90+ 'installation directory for C++ header files [prefix/include]' ,
91+ env ['prefix' ] + '/include' ,
92+ PathVariable .PathAccept ))
93+
5794vars .Add (EnumVariable (
5895 'build' ,
5996 'compiler settings' ,
@@ -71,6 +108,26 @@ vars.Add(BoolVariable(
71108vars .Update (env )
72109env .Help (MY_SCONS_HELP % vars .GenerateHelpText (env ))
73110
111+ if platform .system ().lower () == "windows" :
112+ # See https://scons.org/faq.html#Linking_on_Windows_gives_me_an_error
113+ env ['ENV' ]['TMP' ] = os .environ ['TMP' ]
114+ # the CPPPATH directories are checked by scons dependency scanner
115+ cpppath = getsyspaths ('CPLUS_INCLUDE_PATH' , 'CPATH' )
116+ env .AppendUnique (CPPPATH = cpppath )
117+ # Insert LIBRARY_PATH explicitly because some compilers
118+ # ignore it in the system environment.
119+ env .PrependUnique (LIBPATH = getsyspaths ('LIBRARY_PATH' ))
120+ if 'CONDA_PREFIX' in os .environ :
121+ env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ],'include' ))
122+ env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ],'Library' ,'include' ))
123+ env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ],'Library' ,'lib' ))
124+ # This disable automated versioned named e.g. libboost_date_time-vc142-mt-s-x64-1_73.lib
125+ # so we can use conda-installed libraries
126+ env .AppendUnique (CPPDEFINES = 'BOOST_ALL_NO_LIB' )
127+ # Prevent the generation of an import lib (.lib) in addition to the dll
128+ # Unused as we are using as static library for windows
129+ # env.AppendUnique(no_import_lib=1)
130+
74131builddir = env .Dir ('build/%s-%s' % (env ['build' ], platform .machine ()))
75132
76133Export ('env' )
0 commit comments