2020-07-27 17:13:05 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import glob
|
|
|
|
import re
|
|
|
|
|
|
|
|
if sys.version_info < (3,):
|
|
|
|
def isbasestring(s):
|
|
|
|
return isinstance(s,basestring)
|
|
|
|
else:
|
|
|
|
def isbasestring(s):
|
|
|
|
return isinstance(s, (str,bytes))
|
|
|
|
|
|
|
|
def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""):
|
|
|
|
|
|
|
|
if isbasestring(filetype):
|
|
|
|
dir_path = self.Dir('.').abspath
|
|
|
|
filetype = sorted(glob.glob(dir_path+"/"+filetype))
|
|
|
|
|
|
|
|
for path in filetype:
|
|
|
|
target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path )
|
|
|
|
if shared:
|
|
|
|
target_name+='.os'
|
|
|
|
sources.append( self.SharedObject( target=target_name, source=path ) )
|
|
|
|
else:
|
|
|
|
target_name+='.o'
|
|
|
|
sources.append( self.StaticObject( target=target_name, source=path ) )
|
|
|
|
pass
|
|
|
|
|
2022-02-14 18:53:33 +01:00
|
|
|
def isAbsolutePath(key, dirname, env):
|
|
|
|
assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,)
|
|
|
|
|
2022-12-05 01:49:38 +01:00
|
|
|
## Environment variables
|
2022-02-14 18:53:33 +01:00
|
|
|
env_vars = Variables(
|
|
|
|
args=ARGUMENTS
|
|
|
|
)
|
|
|
|
env_vars.Add('prefix',
|
|
|
|
help='Installation target location of build results and headers',
|
|
|
|
default='/usr/local/',
|
|
|
|
validator=isAbsolutePath
|
|
|
|
)
|
|
|
|
|
2022-12-05 01:49:38 +01:00
|
|
|
## Environment setup
|
|
|
|
|
2022-02-14 18:53:33 +01:00
|
|
|
env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=['#source/forstio','#source','#','#driver'],
|
2021-12-24 20:17:43 +01:00
|
|
|
CXX='clang++',
|
2021-12-29 19:49:20 +01:00
|
|
|
CPPDEFINES=['SAW_UNIX'],
|
2021-12-18 17:26:14 +01:00
|
|
|
CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
|
2022-06-06 01:22:36 +02:00
|
|
|
LIBS=[])
|
2020-07-27 17:13:05 +02:00
|
|
|
env.__class__.add_source_files = add_kel_source_files
|
2022-11-19 16:29:45 +01:00
|
|
|
env.Tool('compilation_db');
|
|
|
|
env.cdb = env.CompilationDatabase('compile_commands.json');
|
|
|
|
|
2020-07-27 17:13:05 +02:00
|
|
|
|
2021-06-18 00:17:18 +02:00
|
|
|
env.objects = []
|
2020-07-27 17:13:05 +02:00
|
|
|
env.sources = []
|
|
|
|
env.headers = []
|
2021-06-18 00:17:18 +02:00
|
|
|
|
|
|
|
env.tls_sources = []
|
|
|
|
env.tls_headers = []
|
2020-07-27 17:13:05 +02:00
|
|
|
|
2021-05-30 00:46:07 +02:00
|
|
|
env.driver_sources = []
|
|
|
|
env.driver_headers = []
|
|
|
|
|
2020-07-27 17:13:05 +02:00
|
|
|
Export('env')
|
2020-08-25 19:51:45 +02:00
|
|
|
SConscript('driver/SConscript')
|
2022-05-27 16:02:58 +02:00
|
|
|
SConscript('source/forstio/SConscript')
|
2020-08-21 18:38:24 +02:00
|
|
|
|
|
|
|
# Tests
|
|
|
|
SConscript('test/SConscript')
|
|
|
|
|
2020-07-27 17:13:05 +02:00
|
|
|
env.Alias('test', env.test_program)
|
2020-08-20 19:02:24 +02:00
|
|
|
|
2020-08-21 18:39:49 +02:00
|
|
|
# Clang format part
|
|
|
|
env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')})
|
2022-12-05 01:49:38 +01:00
|
|
|
env.Append(BUILDERS={'ClangTidyFix' : Builder(action = 'clang-tidy -extra-arg-before=-xc++ --fix $SOURCE -- -std=c++17 -DSAW_UNIX -Isource')})
|
2020-08-21 18:39:49 +02:00
|
|
|
env.format_actions = []
|
|
|
|
def format_iter(env,files):
|
|
|
|
for f in files:
|
2022-12-05 01:49:38 +01:00
|
|
|
env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f)));
|
|
|
|
pass
|
|
|
|
|
|
|
|
env.tidy_actions = []
|
|
|
|
def tidy_iter(env,files):
|
2022-12-06 19:21:20 +01:00
|
|
|
string_of_files = "";
|
2022-12-05 01:49:38 +01:00
|
|
|
for f in files:
|
2022-12-06 19:21:20 +01:00
|
|
|
if(f != "/home/keldu/workspace/forstio/source/forstio/async.tmpl.h" ):
|
|
|
|
string_of_files = string_of_files + " " + f;
|
|
|
|
# env.tidy_actions.append(env.AlwaysBuild(env.ClangTidyFix(target=f+"-clang-tidy-fix",source=f)));
|
|
|
|
print(string_of_files);
|
2020-08-21 18:39:49 +02:00
|
|
|
pass
|
|
|
|
|
2021-05-30 00:46:07 +02:00
|
|
|
format_iter(env,env.sources + env.driver_sources + env.headers + env.driver_headers)
|
2022-12-06 19:21:20 +01:00
|
|
|
tidy_iter(env,env.sources + env.driver_sources + env.headers + env.driver_headers)
|
2020-08-21 18:39:49 +02:00
|
|
|
|
2022-12-05 01:49:38 +01:00
|
|
|
env.Alias('format', env.format_actions);
|
|
|
|
env.Alias('tidy', env.tidy_actions);
|
2020-08-23 15:47:14 +02:00
|
|
|
|
2022-11-19 16:29:45 +01:00
|
|
|
env.Alias('cdb', env.cdb);
|
2022-05-27 16:02:58 +02:00
|
|
|
env.Alias('all', ['format', 'library', 'test'])
|
2022-09-17 17:05:19 +02:00
|
|
|
env.Default('all')
|
2020-08-28 16:59:25 +02:00
|
|
|
|
2022-02-14 18:53:33 +01:00
|
|
|
env.Install('$prefix/lib/', [env.library_shared, env.library_static])
|
|
|
|
env.Install('$prefix/include/forstio/', [env.headers])
|
|
|
|
env.Install('$prefix/include/forstio/tls/', [env.tls_headers])
|
2021-06-18 00:17:18 +02:00
|
|
|
|
2022-02-14 18:53:33 +01:00
|
|
|
env.Install('$prefix/include/forstio/test/', [env.test_headers])
|
|
|
|
env.Alias('install', '$prefix')
|