aboutsummaryrefslogtreecommitdiff
path: root/deps/SCsub
blob: 441ec93005816262f42a38b9bbc18f07e10f576c (plain) (blame)
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env python
import os

Import("env")

def build_lexy(env):
    env.Append(CPPDEFINES=["LEXY_HAS_UNICODE_DATABASE=1"])
    lexy_env = env.Clone()

    # Require C++20
    if lexy_env.get("is_msvc", False):
        lexy_env.Append(CXXFLAGS=["/std:c++20"])

        lexy_env.Append(CXXFLAGS=["/WX", "/W3", "/D", "_CRT_SECURE_NO_WARNINGS"])
        if not lexy_env.get("use_clang_cl"):
            lexy_env.Append(CXXFLAGS=["/wd5105"])
    else:
        lexy_env.Append(CXXFLAGS=["-std=c++20"])

        lexy_env.Append(CXXFLAGS=["-pedantic-errors", "-Werror", "-Wall", "-Wextra", "-Wconversion", "-Wsign-conversion"])
        if lexy_env["CXX"] == "clang++":
            lexy_env.Append(CXXFLAGS=["-Wno-shift-op-parentheses", "-Wno-parentheses-equality"])
        else:
            lexy_env.Append(CXXFLAGS=[
                "-Wno-parentheses", "-Wno-unused-local-typedefs", "-Wno-array-bounds" #, "-Wno-maybe-uninitialized", "-Wno-restrict"
            ])

    include_path = "lexy/include"
    source_path = "lexy/src"
    lexy_env.Append(CPPPATH=[[lexy_env.Dir(p) for p in [source_path, include_path]]])
    sources = env.GlobRecursive("*.cpp", [source_path])
    env.lexy_sources = sources

    library_name = "liblexy_file" + env["LIBSUFFIX"]
    library = lexy_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
    Default(library)

    include_dir = lexy_env.Dir(include_path)
    source_dir = lexy_env.Dir(source_path)
    env.Append(CPPPATH=[include_dir])
    if env.get("is_msvc", False):
        env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
    else:
        env.Append(CXXFLAGS=["-isystem", include_dir])
    env.Append(CXXFLAGS=[""])
    env.Append(LIBPATH=[source_dir])
    env.Prepend(LIBS=[library_name])

def build_dryad(env):
    include_path = "dryad/include"
    include_dir = env.Dir(include_path)
    env.dryad = {}
    env.dryad["INCPATH"] = [include_dir]
    env.Append(CPPPATH=env.dryad["INCPATH"])
    if env.get("is_msvc", False):
        env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
    else:
        env.Append(CXXFLAGS=["-isystem", include_dir])

    env.exposed_includes += env.dryad["INCPATH"]

def build_fmt(env):
    fmt_env = env.Clone()

    # Require C++20
    if fmt_env.get("is_msvc", False):
        fmt_env.Append(CXXFLAGS=["/std:c++20"])

        fmt_env.Append(CXXFLAGS=["/WX", "/W3", "/D", "_CRT_SECURE_NO_WARNINGS"])
    else:
        fmt_env.Append(CXXFLAGS=["-std=c++20"])

        fmt_env.Append(CXXFLAGS=[
            "-Werror", "-Wall", "-Wextra", "-pedantic", "-Wconversion", "-Wundef"
        ])
        if fmt_env["CXX"] == "clang++":
            fmt_env.Append(CXXFLAGS=[
                "-Wweak-vtables", "-Wshadow",
                "-Wno-gnu-zero-variadic-macro-arguments"
            ])
        else:
            fmt_env.Append(CXXFLAGS=[
                "-Wsign-conversion", "-Wold-style-cast",
                "-Wundef", "-Wredundant-decls", "-Wwrite-strings",
                "-Wpointer-arith", "-Wcast-qual", "-Wformat=2",
                "-Wmissing-include-dirs", "-Wcast-align", "-Wctor-dtor-privacy",
                "-Wdisabled-optimization", "-Winvalid-pch", "-Woverloaded-virtual",
                "-Wconversion", "-Wundef", "-Wno-ctor-dtor-privacy", "-Wno-format-nonliteral",
                "-Wno-dangling-else", "-Wno-unused-local-typedefs", "-Wdouble-promotion",
                "-Wtrampolines", "-Wzero-as-null-pointer-constant", "-Wuseless-cast",
                "-Wvector-operation-performance", "-Wsized-deallocation", "-Wshadow",
                "-Wshift-overflow=2", "-Wnull-dereference", "-Wduplicated-cond"
            ])

    include_path = "fmt/include"
    source_path = "fmt/src"
    paths = [include_path, source_path]
    fmt_env.Append(CPPPATH=[[fmt_env.Dir(p) for p in paths]])
    sources = env.GlobRecursive("*.cc", paths, "fmt.cc")
    env.lexy_sources = sources

    library_name = "libfmt" + env["LIBSUFFIX"]
    library = fmt_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
    Default(library)

    include_dir = fmt_env.Dir(include_path)
    source_dir = fmt_env.Dir(source_path)

    env.fmt = {}
    env.fmt["INCPATH"] = [include_dir]

    env.Append(CPPPATH=env.fmt["INCPATH"])
    if env.get("is_msvc", False):
        env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
    else:
        env.Append(CXXFLAGS=["-isystem", include_dir])
    env.Append(CXXFLAGS=[""])
    env.Append(LIBPATH=[fmt_env.Dir(source_path)])
    env.Prepend(LIBS=[library_name])

    env.exposed_includes += env.fmt["INCPATH"]

def build_range_v3(env):
    include_path = "range-v3/include"
    sources = env.GlobRecursive("*.cpp", [include_path])
    env.range_v3_sources = sources

    include_dir = env.Dir(include_path)

    env.range_v3 = {}
    env.range_v3["INCPATH"] = [include_dir]

    env.Append(CPPPATH=env.range_v3["INCPATH"])
    if env.get("is_msvc", False):
        env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
    else:
        env.Append(CXXFLAGS=["-isystem", include_dir])

    env.exposed_includes += env.range_v3["INCPATH"]

def build_vmcontainer(env):
    vmcontainer_env = env.Clone()

    include_path = "vmcontainer/lib/include"
    source_path = "vmcontainer/lib/src"
    paths = [include_path, source_path]
    vmcontainer_env.Append(CPPPATH=[[vmcontainer_env.Dir(p) for p in paths]])
    sources = env.GlobRecursive("*.cpp", paths)
    env.vmcontainer_sources = sources

    library_name = "libvmcontainer" + env["LIBSUFFIX"]
    library = vmcontainer_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
    Default(library)

    include_dir = vmcontainer_env.Dir(include_path)

    env.vmcontainer = {}
    env.vmcontainer["INCPATH"] = [include_dir]

    env.Append(CPPPATH=env.vmcontainer["INCPATH"])
    if env.get("is_msvc", False):
        env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
    else:
        env.Append(CXXFLAGS=["-isystem", include_dir])
    env.Append(CXXFLAGS=[""])
    env.Append(LIBPATH=[vmcontainer_env.Dir(source_path)])
    env.Prepend(LIBS=[library_name])

    env.exposed_includes += env.vmcontainer["INCPATH"]

build_dryad(env)
build_fmt(env)
build_lexy(env)
build_range_v3(env)
build_vmcontainer(env)