Skip to content

Commit b7b6591

Browse files
authored
Merge pull request #566 from OpenVicProject/add/spdlog
Replace Logger with spdlog
2 parents e3dba06 + 2c67d98 commit b7b6591

File tree

94 files changed

+1996
-1455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1996
-1455
lines changed

.clang-format

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ IncludeCategories:
8888
Priority: 7
8989
- Regex: ^<range
9090
Priority: 8
91-
- Regex: ^"openvic-simulation/
91+
- Regex: ^<spdlog/
9292
Priority: 9
93-
- Regex: .*
93+
- Regex: ^"openvic-simulation/
9494
Priority: 10
95+
- Regex: .*
96+
Priority: 11

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030
path = deps/memory
3131
url = https://github.com/foonathan/memory
3232
ignore = dirty
33+
[submodule "deps/spdlog"]
34+
path = deps/spdlog
35+
url = https://github.com/gabime/spdlog

COPYRIGHT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Comment: plf::colony
3838
Copyright: 2019, mattreecebentley
3939
License: Zlib
4040

41+
Files: deps/spdlog/*
42+
Comment: spdlog
43+
Copyright: 2016, Gabi Melman
44+
License: Expat
45+
4146
Files: src/openvic-simulation/types/Signal.hpp
4247
Comment: sigslot
4348
Copyright: 2017, Pierre-Antoine Lacaze

deps/SCsub

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,60 @@ def build_memory(env):
111111

112112
env.exposed_includes += env.memory["INCPATH"]
113113

114+
def build_spdlog(env):
115+
import os
116+
117+
spdlog_level = "SPDLOG_LEVEL_INFO"
118+
if "SPDLOG_LEVEL" in os.environ:
119+
spdlog_level = os.environ["SPDLOG_LEVEL"].upper()
120+
if not spdlog_level.startswith("SPDLOG_LEVEL_"):
121+
spdlog_level = "SPDLOG_LEVEL_" + spdlog_level
122+
if not spdlog_level in [
123+
"SPDLOG_LEVEL_TRACE",
124+
"SPDLOG_LEVEL_DEBUG",
125+
"SPDLOG_LEVEL_INFO",
126+
"SPDLOG_LEVEL_WARN",
127+
"SPDLOG_LEVEL_ERROR",
128+
"SPDLOG_LEVEL_CRITICAL",
129+
"SPDLOG_LEVEL_OFF"
130+
]:
131+
print("SPDLOG_LEVEL can only be trace, debug, info, warn, error, critical, or off")
132+
exit(255)
133+
elif env["dev_build"]:
134+
spdlog_level = "SPDLOG_LEVEL_DEBUG"
135+
elif env["target"] == "template_release" or env["optimize"] in ["speed", "size"]:
136+
spdlog_level = "SPDLOG_LEVEL_WARN"
137+
138+
env.Append(CPPDEFINES=[("SPDLOG_ACTIVE_LEVEL", spdlog_level), "SPDLOG_FMT_EXTERNAL", "SPDLOG_COMPILED_LIB", "SPDLOG_NO_EXCEPTIONS"])
139+
if env["platform"] != "macos":
140+
env.Append(CPPDEFINES=["SPDLOG_FWRITE_UNLOCKED"])
141+
spdlog_env = env.Clone()
142+
143+
include_path = "spdlog/include"
144+
source_path = "spdlog/src"
145+
source_dir = spdlog_env.Dir(source_path)
146+
147+
env.spdlog = {}
148+
env.spdlog["INCPATH"] = [spdlog_env.Dir(include_path)]
149+
150+
spdlog_env.Append(CPPPATH=[source_dir, env.spdlog["INCPATH"]])
151+
sources = env.GlobRecursive("*.cpp", [source_path])
152+
env.spdlog_sources = sources
153+
154+
library_name = "libspdlog" + env["LIBSUFFIX"]
155+
library = spdlog_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
156+
Default(library)
157+
158+
env.Append(CPPPATH=[env.spdlog["INCPATH"]])
159+
if env.get("is_msvc", False):
160+
env.Append(CXXFLAGS=["/external:I", env.spdlog["INCPATH"][0], "/external:W0"])
161+
else:
162+
env.Append(CXXFLAGS=["-isystem", env.spdlog["INCPATH"][0]])
163+
env.Append(LIBPATH=[source_dir])
164+
env.Prepend(LIBS=[library_name])
165+
166+
env.exposed_includes += env.spdlog["INCPATH"]
167+
114168
def link_tbb(env):
115169
import sys
116170
if not env.get("is_msvc", False) and not env.get("use_mingw", False) and sys.platform != "darwin":
@@ -123,4 +177,5 @@ build_colony(env)
123177
build_function2(env)
124178
build_std_function(env)
125179
build_memory(env)
180+
build_spdlog(env)
126181
link_tbb(env)

deps/spdlog

Submodule spdlog added at f1d748e

0 commit comments

Comments
 (0)