Skip to content

Commit c9f268c

Browse files
authored
Merge pull request #656 from OpenVicProject/add/type-safe-lib
Add type_safe as submodule
2 parents 7fb3707 + bcde279 commit c9f268c

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@
3636
[submodule "deps/xoshiro"]
3737
path = deps/xoshiro
3838
url = https://github.com/reputeless/xoshiro-cpp
39+
[submodule "deps/type_safe"]
40+
path = deps/type_safe
41+
url = https://github.com/foonathan/type_safe

COPYRIGHT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Comment: spdlog
4343
Copyright: 2016, Gabi Melman
4444
License: Expat
4545

46+
Files: deps/type_safe/*
47+
Comment: type_safe
48+
Copyright: 2016-2020, Jonathan Müller
49+
License: Expat
50+
4651
Files: deps/xoshiro/*
4752
Comment: Xoshiro-cpp
4853
Copyright: 2020, Ryo Suzuki

deps/SCsub

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,57 @@ def build_xoshiro(env):
200200
env.exposed_includes += env.xoshiro["INCPATH"]
201201

202202

203+
def build_type_safe(env):
204+
import os
205+
206+
arithmetic_policy = 1
207+
if "TYPE_SAFE_ARITHMETIC_POLICY" in os.environ:
208+
arithmetic_policy = os.environ["TYPE_SAFE_ARITHMETIC_POLICY"].upper().replace(" ", "_")
209+
if arithmetic_policy not in [
210+
"ub",
211+
"undefined_behavior",
212+
"undefined",
213+
"checked",
214+
"default",
215+
"0",
216+
"1",
217+
"2",
218+
]:
219+
print("TYPE_SAFE_ARITHMETIC_POLICY can only be undefined, checked, or default")
220+
exit(255)
221+
match arithmetic_policy:
222+
case "default":
223+
arithmetic_policy = 0
224+
case "ub", "undefined_behavior", "undefined":
225+
arithmetic_policy = 1
226+
case "checked":
227+
arithmetic_policy = 2
228+
case "0", "1", "2":
229+
arithmetic_policy = int(arithmetic_policy)
230+
elif env["dev_build"]:
231+
arithmetic_policy = 2
232+
233+
env.Append(
234+
CPPDEFINES=[
235+
("TYPE_SAFE_ENABLE_ASSERTIONS", 1 if env["target"] == "template_release" else 0),
236+
("TYPE_SAFE_ENABLE_PRECONDITION_CHECKS", 1),
237+
("TYPE_SAFE_ENABLE_WRAPPER", 1 if env["target"] == "template_release" else 0),
238+
("TYPE_SAFE_ARITHMETIC_POLICY", arithmetic_policy),
239+
]
240+
)
241+
242+
include_path = "type_safe/include"
243+
debug_assert_include_path = "type_safe/external/debug_assert"
244+
env.type_safe = {}
245+
env.type_safe["INCPATH"] = [env.Dir(include_path), env.Dir(debug_assert_include_path)]
246+
env.Append(CPPPATH=env.type_safe["INCPATH"])
247+
if env.get("is_msvc", False):
248+
env.Append(CXXFLAGS=["/external:I", env.type_safe["INCPATH"][0], "/external:W0"])
249+
else:
250+
env.Append(CXXFLAGS=["-isystem", env.type_safe["INCPATH"][0]])
251+
env.exposed_includes += env.type_safe["INCPATH"]
252+
253+
203254
def link_tbb(env):
204255
import sys
205256

@@ -216,4 +267,5 @@ build_std_function(env)
216267
build_memory(env)
217268
build_spdlog(env)
218269
build_xoshiro(env)
270+
build_type_safe(env)
219271
link_tbb(env)

deps/type_safe

Submodule type_safe added at 292e8c1

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ warn_return_any = true
99
warn_unreachable = true
1010
namespace_packages = true
1111
explicit_package_bases = true
12+
python_version = "3.10"
1213

1314
[tool.ruff]
1415
extend-include = ["SConstruct", "SCsub"]
1516
line-length = 120
16-
target-version = "py37"
17+
target-version = "py310"
1718

1819
[tool.ruff.lint]
1920
extend-select = [

0 commit comments

Comments
 (0)