From a03816ef9aa583bb16ad1282dacaad9c02b87cd7 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Thu, 10 Apr 2014 15:03:11 +0800 Subject: [PATCH 1/2] scons: seperate the BSP build with the kernel build BSPs could have their own components/ etc. If they point to the same folder, SCons would find the wrong source code to compile. --- tools/building.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/building.py b/tools/building.py index 54193fcf2f..ae9c8da6d1 100644 --- a/tools/building.py +++ b/tools/building.py @@ -192,18 +192,25 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ LINKCOMSTR = 'LINK $TARGET' ) - # board build script - objs = SConscript('SConscript', variant_dir='build', duplicate=0) Repository(Rtt_Root) + + # we need to seperate the variant_dir for BSPs and the kernels. BSPs could + # have their own components etc. If they point to the same folder, SCons + # would find the wrong source code to compile. + bsp_vdir = 'build/bsp' + kernel_vdir = 'build/kernel' + # board build script + objs = SConscript('SConscript', variant_dir=bsp_vdir, duplicate=0) # include kernel - objs.extend(SConscript(Rtt_Root + '/src/SConscript', variant_dir='build/src', duplicate=0)) + objs.extend(SConscript(Rtt_Root + '/src/SConscript', variant_dir=kernel_vdir + '/src', duplicate=0)) # include libcpu if not has_libcpu: - objs.extend(SConscript(Rtt_Root + '/libcpu/SConscript', variant_dir='build/libcpu', duplicate=0)) + objs.extend(SConscript(Rtt_Root + '/libcpu/SConscript', + variant_dir=kernel_vdir + '/libcpu', duplicate=0)) # include components objs.extend(SConscript(Rtt_Root + '/components/SConscript', - variant_dir='build/components', + variant_dir=kernel_vdir + '/components', duplicate=0, exports='remove_components')) From 81b284b316c27e8c39e8a1deabbeef31a13612bc Mon Sep 17 00:00:00 2001 From: Grissiom Date: Thu, 10 Apr 2014 15:09:20 +0800 Subject: [PATCH 2/2] scons: no need to set RTT_ROOT as Repository In SCons manual: ================= In order to inform the C compiler about the repositories, SCons will add appropriate -I flags to the compilation commands for each directory in the $CPPPATH list. So if we add the current directory to the construction environment $CPPPATH like so: env = Environment(CPPPATH = ['.']) env.Program('hello.c') Repository('/usr/repository1') Then re-executing SCons yields: % scons -Q cc -o hello.o -c -I. -I/usr/repository1 hello.c cc -o hello hello.o ================= The additional include directory is definitely not what we want. Just remove the additional Repository line. --- tools/building.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/building.py b/tools/building.py index ae9c8da6d1..61c1de743d 100644 --- a/tools/building.py +++ b/tools/building.py @@ -192,8 +192,6 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ LINKCOMSTR = 'LINK $TARGET' ) - Repository(Rtt_Root) - # we need to seperate the variant_dir for BSPs and the kernels. BSPs could # have their own components etc. If they point to the same folder, SCons # would find the wrong source code to compile.