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 #----------------------------------------------------------
36 platform_name
= 'win32'
38 elif os
.name
== 'posix' and sys
.platform
!= 'cygwin':
39 platform_name
= sys
.platform
40 dirs_platform
= ['binding/python', 'src/gui']
42 #---------------------------------------------------------
44 #----------------------------------------------------------
45 option_file
= 'config-' + platform_name
+ '.py'
47 opts
= Options(option_file
)
49 # debug or release build
50 EnumOption('mode', 'Building method', default_build_mode
, allowed_values
= ('debug', 'release')),
51 BoolOption('profile', 'Whether or not enable profiling', False),
53 BoolOption('test', 'Build and run the unit test', True),
54 PathOption('cppunit_lib_path', 'Path to cppunit library directory', None),
55 PathOption('cppunit_inc_path', 'Path to cppunit includes directory', None),
58 #---------------------------------------------------------
59 # Setting up environment
60 #---------------------------------------------------------
61 env
= Environment(toolpath
= ['tool'], tools
= ['default', 'doxygen'], options
= opts
)
63 # create the build directory
64 build_dir
= os
.path
.join(env
['mode'], platform_name
)
65 if not os
.path
.isdir(build_dir
):
66 os
.makedirs(build_dir
)
68 # -h will print out help info
69 Help(opts
.GenerateHelpText(env
))
71 #add the default cxxflags and ldflags depending on the platform
75 if platform_name
== 'linux2':
77 elif platform_name
== 'win32':
78 cxxflags
+= ['/GX', '/MD', '/GR']
80 #add the debug flag if needed
82 if env
.has_key('mode'):
85 if platform_name
== 'win32':
87 elif platform_name
== 'linux2':
88 cxxflags
+= ['-g', '-O0']
89 elif mode
== 'release':
90 if platform_name
== 'linux2':
92 elif platform_name
== 'win32':
95 env
.AppendUnique(CXXFLAGS
= cxxflags
)
96 env
.AppendUnique(LINKFLAGS
= linkflags
)
98 # Create a builder for tests
99 def builder_unit_test(target
, source
, env
):
100 app
= str(source
[0].abspath
)
101 if os
.spawnl(os
.P_WAIT
, app
, app
) == 0:
102 open(str(target
[0]),'w').write("PASSED\n")
106 bld
= Builder(action
= builder_unit_test
)
107 env
.Append(BUILDERS
= {'Test' : bld
})
108 opts
.Save(option_file
, env
)
110 #----------------------------------------------------------
112 #----------------------------------------------------------
114 #put the SConsignFile in one place
115 sconsign_file
= os
.path
.join(build_dir
, '.sconsign')
116 env
.SConsignFile(sconsign_file
)
118 #no default target add manually
120 dirs
= dirs_common
+ dirs_platform
122 file = os
.path
.join(dir, 'SConscript')
123 env
.SConscript(file, build_dir
= os
.path
.join(build_dir
, dir), duplicate
= 0, exports
= 'env')