-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSConstruct
More file actions
142 lines (112 loc) · 4.6 KB
/
SConstruct
File metadata and controls
142 lines (112 loc) · 4.6 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python
import os
BINDIR = "bin"
env = SConscript("scripts/SConstruct")
env.PrependENVPath("PATH", os.getenv("PATH"))
opts = env.SetupOptions()
opts.Add(BoolVariable("build_ovdl_tests", "Build and run the openvic dataloader tests", env.is_standalone))
opts.Add(BoolVariable("run_ovdl_tests", "Run the openvic dataloader tests", False))
opts.Add(
BoolVariable(
"build_ovdl_library",
"Build the openvic dataloader library.",
env.get("build_ovdl_library", not env.is_standalone),
)
)
opts.Add(BoolVariable("build_ovdl_headless", "Build the openvic dataloader headless executable", env.is_standalone))
opts.Add(
EnumVariable(
"compliance_type", "Type of encoding compliance to build with", "loose", ("loose", "error_replace", "error")
)
)
env.FinalizeOptions()
suffix = ".{}.{}".format(env["platform"], env["target"])
if env.dev_build:
suffix += ".dev"
if env["precision"] == "double":
suffix += ".double"
suffix += "." + env["arch"]
if env["platform"] == "windows":
if env.get("debug_crt", False):
suffix += ".mdd"
elif env.get("use_static_cpp", False):
suffix += ".mt"
else:
suffix += ".md"
if env.get("use_asan", False):
suffix += ".san"
env["suffix"] = suffix
build_dir = env.Dir("build/" + suffix.lstrip(".")).abspath.replace("\\", "/")
env["build_dir"] = build_dir
env.exposed_includes = []
SConscript("deps/SCsub", "env")
env.openvic_dataloader = {}
# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
source_path = "src/openvic-dataloader"
include_path = "include"
# Out-of-source build: variant tree holds object files only, not copies of the
# source. Compile diagnostics therefore reference original source paths.
dataloader_variant = build_dir + "/" + source_path
env.VariantDir(dataloader_variant, source_path, duplicate=False)
env.Append(CPPPATH=[[env.Dir(p) for p in [include_path, dataloader_variant, source_path]]])
sources = env.GlobRecursiveVariant("*.cpp", source_path, dataloader_variant)
env.dataloader_sources = sources
library = None
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
library_name = "libopenvic-dataloader{}{}".format(suffix, env["LIBSUFFIX"])
default_args = []
match env["compliance_type"]:
case "error_replace":
env.Append(CPPDEFINES=[("OPENVIC_DATALOADER_ENCODING_COMPLIANCE", 1)])
case "error":
env.Append(CPPDEFINES=[("OPENVIC_DATALOADER_ENCODING_COMPLIANCE", 2)])
if env["run_ovdl_tests"]:
env["build_ovdl_tests"] = True
if env["build_ovdl_tests"]:
env["build_ovdl_library"] = True
if env["build_ovdl_library"]:
library = env.StaticLibrary(target=os.path.join(BINDIR, library_name), source=sources)
default_args += [library]
env.Append(LIBPATH=[env.Dir(BINDIR)])
env.Prepend(LIBS=[library_name])
env.openvic_dataloader["LIBPATH"] = env["LIBPATH"]
env.openvic_dataloader["LIBS"] = env["LIBS"]
env.openvic_dataloader["INCPATH"] = [env.Dir(include_path)] + env.exposed_includes
headless_program = None
env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"]
if env["build_ovdl_headless"]:
headless_name = "openvic-dataloader"
headless_env = env.Clone()
headless_src = "src/headless"
headless_variant = build_dir + "/" + headless_src
headless_env.VariantDir(headless_variant, headless_src, duplicate=False)
headless_env.Append(CPPDEFINES=["OPENVIC_DATALOADER_HEADLESS"])
headless_env.Append(CPPPATH=[headless_env.Dir(headless_variant), headless_env.Dir(headless_src)])
headless_env.headless_sources = env.GlobRecursiveVariant("*.cpp", headless_src, headless_variant)
if not env["build_ovdl_library"]:
headless_env.headless_sources += sources
headless_program = headless_env.Program(
target=os.path.join(BINDIR, headless_name),
source=headless_env.headless_sources,
PROGSUFFIX=".headless" + env["PROGSUFFIX"],
)
default_args += [headless_program]
if env["build_ovdl_tests"]:
tests_env = SConscript("tests/SCsub", "env")
if env["run_ovdl_tests"]:
tests_env.RunUnitTest()
# Add compiledb if the option is set
if env.get("compiledb", False):
default_args += ["compiledb"]
Default(*default_args)
if "env" in locals():
# FIXME: This method mixes both cosmetic progress stuff and cache handling...
env.show_progress(env)
Return("env")