#!/usr/bin/env python 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.get("use_llvm"): 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" ]) paths = ["lexy/include", "lexy/src"] lexy_env.Append(CPPPATH=[[lexy_env.Dir(p) for p in paths]]) sources = env.GlobRecursive("*.cpp", paths) env.lexy_sources = sources library_name = "liblexy_file" + env["LIBSUFFIX"] library = lexy_env.StaticLibrary(target="lexy/src/" + library_name, source=sources) Default(library) env.Append(CPPPATH=[lexy_env.Dir("lexy/include")]) if env.get("is_msvc", False): env.Append(CXXFLAGS=["/external:I", lexy_env.Dir("lexy/include"), "/external:W0"]) else: env.Append(CXXFLAGS=["-isystem", lexy_env.Dir("lexy/include")]) env.Append(CXXFLAGS=[""]) env.Append(LIBPATH=[lexy_env.Dir("lexy/src")]) env.Prepend(LIBS=[library_name]) def build_fmt(env): fmt_env = env.Clone() if fmt_env.get("is_msvc", False): fmt_env.Append(CXXFLAGS=["/std:c++20"]) else: fmt_env.Append(CXXFLAGS=["-std=c++20"]) paths = ["fmt/include", "fmt/src"] fmt_env.Append(CPPPATH=[[fmt_env.Dir(p) for p in paths]]) sources = env.GlobRecursive("*.cc", paths, exclude=["fmt.cc"]) env.fmt_sources = sources library_name = "libfmt" + env["LIBSUFFIX"] library = fmt_env.StaticLibrary(target="fmt/src/" + library_name, source=sources) Default(library) env.Append(CPPPATH=[fmt_env.Dir("fmt/include")]) if env.get("is_msvc", False): env.Append(CXXFLAGS=["/external:I", fmt_env.Dir("fmt/include"), "/external:W0"]) else: env.Append(CXXFLAGS=["-isystem", fmt_env.Dir("fmt/include")]) env.Append(CXXFLAGS=[""]) env.Append(LIBPATH=[fmt_env.Dir("fmt/src")]) env.Prepend(LIBS=[library_name]) build_lexy(env) build_fmt(env)