-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSConscript
More file actions
99 lines (88 loc) · 4.49 KB
/
SConscript
File metadata and controls
99 lines (88 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/env python3
import os
Import("exportEnv")
envClone = exportEnv.Clone()
# source_directories = ['core', 'higgsino', ...]
source_directories = next(os.walk('src'))[1]
if len(source_directories) == 0:
source_directories = ['./']
envClone.Append(CPPPATH = ['#/inc'])
# Determine names for trees
tree_variable_filenames = [os.path.basename(str(x)) for x in Glob('#/txt/variables/*')]
tree_variable_files = []
tree_generated_files = ['src/core/baby.cpp','inc/core/baby.hpp']
tree_generated_files_mark = []
for tree_name in tree_variable_filenames: # tree_name = 'pico'
tree_variable_files.append('txt/variables/'+tree_name)
tree_generated_files.extend([
'src/core/baby_'+tree_name+'.cpp',
'inc/core/baby_'+tree_name+'.hpp',
])
tree_generated_files_mark = ['#/'+term for term in tree_generated_files]
# Make tree generator
tree_generator_file = 'src/core/generate_baby.cxx'
tree_generator_exe = 'kernel/'+envClone['kernel']+'/run/core/generate_baby.exe'
tree_generator = envClone.Program('#/'+tree_generator_exe, Glob(tree_generator_file))
# Run tree generator
run_tree_generator = envClone.Command(tree_generated_files_mark, [], './'+tree_generator_exe+' '+' '.join(tree_variable_filenames))
envClone.Depends(run_tree_generator, tree_generator_file)
envClone.Depends(run_tree_generator, tree_variable_files)
envClone.Depends(run_tree_generator, tree_generator)
# Make libraries
libraries = {}
envClone.Append(LINKFLAGS='-L'+'lib/'+envClone['kernel'])
# Make core library
core_objects = []
# Build baby objects
for source_file in tree_generated_files:
if 'hpp' in source_file: continue
source_object = envClone.SharedObject(source_file.replace('cpp','os'), '#/'+source_file)
core_objects.append(source_object)
# Build non-baby non-reflex core objects
for lib_file in Glob("src/core/*.cpp", exclude=tree_generated_files):
source_object = envClone.SharedObject(lib_file)
core_objects.append(source_object)
# Make core library
libraryName = "DrawPicoCore"
library = envClone.SharedLibrary(target='#/lib/'+envClone['kernel']+'/'+libraryName, source=core_objects)
libraries[libraryName]= library
# Make other libraries
for source_directory in source_directories:
if source_directory == "core": continue # already made a library for core
if source_directory == "pythonbindings": continue # do this separately
libraryName = "DrawPico"+source_directory.capitalize()
source_files = set()
for lib_file in Glob("src/"+source_directory+"/*.cpp"): source_files.add(lib_file)
library = envClone.SharedLibrary(target='#/lib/'+envClone['kernel']+'/'+libraryName, source=sorted(source_files), LIBS=["DrawPicoCore"])
envClone.Depends(library, libraries["DrawPicoCore"])
libraries[libraryName]= library
#Make python bindings library
#this depends on all the others so must be done last
libraryName = "DrawPicoPythonbindings"
source_files = set()
for lib_file in Glob("src/pythonbindings/*.cpp"): source_files.add(lib_file)
allLibraryNames = []
for source_directory in source_directories:
if source_directory == "pythonbindings": continue
allLibraryNames.append("DrawPico"+source_directory.capitalize())
library = envClone.SharedLibrary(target='#/lib/'+envClone['kernel']+'/'+libraryName, source=sorted(source_files), LIBS=allLibraryNames)
for libraryName in allLibraryNames:
envClone.Depends(library, libraries[libraryName])
libraries[libraryName]= library
# Make binaries for every directory
exclude_files = [tree_generator_file] + tree_generated_files
for source_directory in source_directories: # source_directories = 'core'
for source_file in Glob("src/"+source_directory+"/*.cxx", exclude=exclude_files):
# Build object
source_object = envClone.Object(source_file)
if source_directory!='core': envClone.Depends(source_object, libraries['DrawPicoCore'])
libraryName = "DrawPico"+source_directory.capitalize()
# Make program
program = envClone.Program('#/kernel/'+envClone['kernel']+'/run/'+source_directory+'/${SOURCE.filebase}.exe', source_object, LIBS=["DrawPicoCore", libraryName, "stdc++fs"])
envClone.Depends(program, libraries["DrawPicoCore"])
envClone.Depends(program, libraries[libraryName])
# Make script that links to binary
source_basename = os.path.splitext(os.path.basename(str(source_file)))[0]
source_script_path = 'run/'+source_directory+'/'+source_basename+'.exe'
source_script_path_mark = "#/"+source_script_path
envClone.Command(source_script_path_mark, program, './scripts/make_run_scripts.py '+source_script_path)