Skip to content

Commit

Permalink
Merge branch '1-make-scons-build-great-again' into 'master'
Browse files Browse the repository at this point in the history
Resolve "make scons build great again"

Closes #1

See merge request softwarecenter/tasking-framework!1
  • Loading branch information
彭婷 committed Sep 15, 2020
2 parents 3be1a0d + 448f3a4 commit cc48759
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 5 deletions.
9 changes: 7 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[submodule "contrib/scons-build-tools"]
path = contrib/scons-build-tools
url = [email protected]:softwarecenter/scons-build-tools.git
[submodule "contrib/googletest-fused"]
path = contrib/googletest-fused
url = [email protected]:softwarecenter/googletest-fused.git
[submodule "contrib/outpost-core"]
path = contrib/outpost-core
url = [email protected]:DLR-RY/outpost-core.git
branch = master
url = [email protected]:pengting/outpost-core.git
48 changes: 48 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

import os

Import('envGlobal')

envGlobal.Append(CPPPATH=[os.path.abspath('.') ])

# Build GoogleTest
googletest = os.path.join(envGlobal['BASEPATH'], 'contrib/googletest-fused')
envGlobal.Append(CPPPATH=[
#os.path.abspath('%s' % googletest),
googletest,
])

env = envGlobal.Clone()
env['CXXFLAGS_language'] = ['-std=c++98']

env.RemoveFromList('CCFLAGS_warning', [
'-Wconversion',
'-Wundef',
'-Wmissing-declarations'])
env.RemoveFromList('CXXFLAGS_warning', '-Wold-style-cast')

files = env.Glob('%s/*.cc' % googletest)
objects = []
for file in files:
objects.append(env.Object(file))
envGlobal.Append(objects={'googletest': objects})

libraryGmock = env.StaticLibrary('gtest', objects)
envGlobal.Install('$BUILDPATH/lib', libraryGmock)
envGlobal.Append(LIBS=['gtest'])

#SConscript(
# os.path.join(envGlobal['BASEPATH'], 'contrib/outpost-core/modules/SConscript.library'),
# exports='envGlobal')

SConscript(
os.path.join(envGlobal['BASEPATH'], 'src/SConscript'),
exports='envGlobal')

SConscript(
os.path.join(envGlobal['BASEPATH'], 'test/SConscript'),
exports='envGlobal')

env = envGlobal.Clone()

63 changes: 63 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python

import os

vars = Variables('custom.py')
vars.Add(BoolVariable('coverage', 'Set to build for coverage analysis', 0))
vars.Add('append_buildpath', 'manual append to buildpath', '')

## Define project paths --------------------------------------------------------
root_path = os.path.abspath('.')
outpost_path = [os.path.join(root_path, 'contrib/outpost-core')]
print(outpost_path)
build_path = os.path.join(root_path, 'build')

envGlobal = Environment(
CXXFLAGS=["-std=c++11", "--debug"],
toolpath=[os.path.join(root_path, 'contrib/scons-build-tools/site_tools')],
tools=['compiler_hosted_gcc',
'settings_buildpath',
'utils_buildformat',
'utils_buildsize'],
variables=vars,
BASEPATH=os.path.abspath('.'),
OS='posix',
PLATFORM='outpost',
GTEST_SUPPORT_NEEDED='no',
ENV=os.environ)
print(envGlobal['OS'])
print(envGlobal['toolpath'])

Help(vars.GenerateHelpText(envGlobal))

buildfolder = os.path.join(root_path, 'build')

if envGlobal['coverage']:
envGlobal.Tool('compiler_hosted_gcc_coverage')
envGlobal.Tool('settings_buildpath')
envGlobal['BUILDPATH'] = os.path.abspath(os.path.join(buildfolder, module, 'test/coverage'))
else:
envGlobal.Tool('compiler_hosted_gcc')
envGlobal.Tool('settings_buildpath')
envGlobal['BUILDPATH'] = os.path.abspath(os.path.join(buildfolder, 'test/unittest'))

if envGlobal['append_buildpath']:
envGlobal['BUILDPATH'] = os.path.abspath(os.path.join(buildfolder, envGlobal['append_buildpath'] + '/' ))

envGlobal['BASEPATH'] = root_path
envGlobal['ROOTPATH'] = root_path
envGlobal['IPCPATH'] = root_path
#envGlobal['BUILDPATH'] = os.path.join(build_path, variant_dir)
envGlobal['BUILDPATH'] = build_path
envGlobal['BINPATH'] = os.path.join(envGlobal['BUILDPATH'], 'bin')
envGlobal['LIBINSTALLPATH'] = os.path.join(envGlobal['BUILDPATH'], 'lib')
envGlobal['LIBPATH'] = envGlobal['LIBINSTALLPATH']

subSConscripts = [
'contrib/outpost-core/modules/SConscript.library',
'SConscript',
]
for subSConscript in subSConscripts:
SConscript(subSConscript, exports='envGlobal', duplicate = 0)

env = envGlobal.Clone()
1 change: 1 addition & 0 deletions contrib/googletest-fused
Submodule googletest-fused added at 850ecc
2 changes: 1 addition & 1 deletion contrib/outpost-core
Submodule outpost-core updated from 7ed81a to fd307e
1 change: 1 addition & 0 deletions contrib/scons-build-tools
Submodule scons-build-tools added at 06d970
2 changes: 1 addition & 1 deletion src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ elif envGlobal['PLATFORM'] == 'outpost':
envGlobal.Append(objects={'tasking': files})

if 'FORMAT' in envGlobal:
print "Format source files."
print("Format source files.")
os.system('clang-format -style=file -i *.cpp ../include/*.h ../arch/*/*.cpp ../arch/*/*.h')

library = env.StaticLibrary(target = 'tasking', source = files)
Expand Down
2 changes: 1 addition & 1 deletion test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env = envGlobal.Clone()

files = env.Glob('*.cpp')

env.Append(LIBS=['tasking', 'gtest', 'pthread'])
env.Append(LIBS=['tasking', 'gtest', 'pthread', 'outpost_rtos'])

if env['PLATFORM'] == 'custom' and 'test' in COMMAND_LINE_TARGETS:
print('Unit tests can not run without a platform specific implementation!')
Expand Down

0 comments on commit cc48759

Please sign in to comment.