1 # vi:filetype=python:expandtab:tabstop=2:shiftwidth=2
4 #sys.path.append('tool')
6 #----------------------------------------------------------
7 # Required runtime environment
8 #----------------------------------------------------------
10 # FIXME: I remember lyx requires higher version of python?
11 EnsurePythonVersion(1, 5)
12 # Please use at least 0.96.91 (not 0.96.1)
13 EnsureSConsVersion(0, 96, 91)
15 #----------------------------------------------------------
17 #----------------------------------------------------------
19 # some global settings
20 PACKAGE_VERSION
= '2.3.0'
22 default_build_mode
= 'debug'
25 PACKAGE_BUGREPORT
= 'picca@synchrotron-soleil.fr'
27 PACKAGE_TARNAME
= 'hkl'
28 PACKAGE_STRING
= '%s %s' % (PACKAGE_NAME
, PACKAGE_VERSION
)
30 dirs_common
= ['src', 'test', 'doc']
32 #----------------------------------------------------------
33 # platform dependent settings
34 #----------------------------------------------------------
37 platform_name
= 'win32'
39 elif os
.name
== 'posix' and sys
.platform
!= 'cygwin':
40 platform_name
= sys
.platform
41 #dirs_platform = ['binding/python', 'src/gui']
44 #---------------------------------------------------------
46 #----------------------------------------------------------
47 option_file
= 'config-' + platform_name
+ '.py'
49 opts
= Options(option_file
)
51 # debug or release build
52 EnumOption('mode', 'Building method', default_build_mode
, allowed_values
= ('debug', 'release')),
53 BoolOption('profile', 'Whether or not enable profiling', False),
55 BoolOption('test', 'Build and run the unit test', True),
56 PathOption('cppunit_lib_path', 'Path to cppunit library directory', None),
57 PathOption('cppunit_inc_path', 'Path to cppunit includes directory', None),
60 #---------------------------------------------------------
61 # Setting up environment
62 #---------------------------------------------------------
63 env
= Environment(toolpath
= ['tool'], tools
= ['default', 'doxygen'], options
= opts
)
65 # create the build directory
66 build_dir
= os
.path
.join(env
['mode'], platform_name
)
67 if not os
.path
.isdir(build_dir
):
68 os
.makedirs(build_dir
)
70 # -h will print out help info
71 Help(opts
.GenerateHelpText(env
))
73 #add the default cxxflags and ldflags depending on the platform
79 if platform_name
== 'linux2':
82 elif platform_name
== 'win32':
83 cflags
+= ['/GX', '/MD', '/GR']
84 cxxflags
+= ['/GX', '/MD', '/GR']
86 #add the debug flag if needed
88 if env
.has_key('mode'):
91 if platform_name
== 'win32':
94 elif platform_name
== 'linux2':
95 cflags
+= ['-g', '-O0']
96 cxxflags
+= ['-g', '-O0']
97 elif mode
== 'release':
98 cppdefines
+= ['NDEBUG']
99 if platform_name
== 'linux2':
102 elif platform_name
== 'win32':
106 env
.AppendUnique(CFLAGS
= cflags
)
107 env
.AppendUnique(CXXFLAGS
= cxxflags
)
108 env
.AppendUnique(CPPDEFINES
= cppdefines
)
109 env
.AppendUnique(LINKFLAGS
= linkflags
)
111 # Create a builder for tests
112 def builder_unit_test(target
, source
, env
):
113 app
= str(source
[0].abspath
)
114 if os
.spawnl(os
.P_WAIT
, app
, app
) == 0:
115 open(str(target
[0]),'w').write("PASSED\n")
119 bld
= Builder(action
= builder_unit_test
)
120 env
.Append(BUILDERS
= {'Test' : bld
})
121 opts
.Save(option_file
, env
)
123 #----------------------------------------------------------
125 #----------------------------------------------------------
127 #put the SConsignFile in one place
128 sconsign_file
= os
.path
.join(build_dir
, '.sconsign')
129 env
.SConsignFile(sconsign_file
)
131 #no default target add manually
133 dirs
= dirs_common
+ dirs_platform
135 file = os
.path
.join(dir, 'SConscript')
136 env
.SConscript(file, build_dir
= os
.path
.join(build_dir
, dir), duplicate
= 0, exports
= 'env')