2022-02-13 13:41:29 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2024-04-26 19:35:07 +02:00
|
|
|
from enum import Enum
|
2022-02-13 13:41:29 +01:00
|
|
|
|
2024-04-26 19:35:07 +02:00
|
|
|
# Colors are disabled in non-TTY environments such as pipes. This means
|
|
|
|
# that if output is redirected to a file, it won't contain color codes.
|
|
|
|
# Colors are always enabled on continuous integration.
|
|
|
|
_colorize = bool(sys.stdout.isatty() or os.environ.get("CI"))
|
2022-02-13 13:41:29 +01:00
|
|
|
|
|
|
|
|
2024-04-26 19:35:07 +02:00
|
|
|
class ANSI(Enum):
|
|
|
|
"""
|
|
|
|
Enum class for adding ansi colorcodes directly into strings.
|
|
|
|
Automatically converts values to strings representing their
|
|
|
|
internal value, or an empty string in a non-colorized scope.
|
|
|
|
"""
|
|
|
|
|
|
|
|
GRAY = "\x1b[0;30m"
|
|
|
|
RED = "\x1b[0;31m"
|
|
|
|
GREEN = "\x1b[0;32m"
|
|
|
|
YELLOW = "\x1b[0;33m"
|
|
|
|
BLUE = "\x1b[0;34m"
|
|
|
|
PURPLE = "\x1b[0;35m"
|
|
|
|
CYAN = "\x1b[0;36m"
|
|
|
|
WHITE = "\x1b[0;37m"
|
|
|
|
|
|
|
|
BOLD_GRAY = "\x1b[1;90m"
|
|
|
|
BOLD_RED = "\x1b[1;91m"
|
|
|
|
BOLD_GREEN = "\x1b[1;92m"
|
|
|
|
BOLD_YELLOW = "\x1b[1;93m"
|
|
|
|
BOLD_BLUE = "\x1b[1;94m"
|
|
|
|
BOLD_PURPLE = "\x1b[1;95m"
|
|
|
|
BOLD_CYAN = "\x1b[1;96m"
|
|
|
|
BOLD_WHITE = "\x1b[1;97m"
|
|
|
|
|
|
|
|
RESET = "\x1b[0m"
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
global _colorize
|
|
|
|
return self.value if _colorize else ""
|
|
|
|
|
|
|
|
|
|
|
|
def no_verbose(env):
|
|
|
|
colors = [ANSI.BLUE, ANSI.BOLD_BLUE, ANSI.RESET]
|
2022-02-13 13:41:29 +01:00
|
|
|
|
|
|
|
# There is a space before "..." to ensure that source file names can be
|
|
|
|
# Ctrl + clicked in the VS Code terminal.
|
2024-04-26 19:35:07 +02:00
|
|
|
compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
|
|
|
|
java_compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
|
|
|
|
compile_shared_source_message = "{0}Compiling shared {1}$SOURCE{0} ...{2}".format(*colors)
|
|
|
|
link_program_message = "{0}Linking Program {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
link_library_message = "{0}Linking Static Library {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
ranlib_library_message = "{0}Ranlib Library {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
link_shared_library_message = "{0}Linking Shared Library {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
java_library_message = "{0}Creating Java Archive {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
compiled_resource_message = "{0}Creating Compiled Resource {1}$TARGET{0} ...{2}".format(*colors)
|
|
|
|
generated_file_message = "{0}Generating {1}$TARGET{0} ...{2}".format(*colors)
|
2022-02-13 13:41:29 +01:00
|
|
|
|
2024-04-26 19:35:07 +02:00
|
|
|
env.Append(CXXCOMSTR=compile_source_message)
|
|
|
|
env.Append(CCCOMSTR=compile_source_message)
|
|
|
|
env.Append(SHCCCOMSTR=compile_shared_source_message)
|
|
|
|
env.Append(SHCXXCOMSTR=compile_shared_source_message)
|
|
|
|
env.Append(ARCOMSTR=link_library_message)
|
|
|
|
env.Append(RANLIBCOMSTR=ranlib_library_message)
|
|
|
|
env.Append(SHLINKCOMSTR=link_shared_library_message)
|
|
|
|
env.Append(LINKCOMSTR=link_program_message)
|
|
|
|
env.Append(JARCOMSTR=java_library_message)
|
|
|
|
env.Append(JAVACCOMSTR=java_compile_source_message)
|
|
|
|
env.Append(RCCOMSTR=compiled_resource_message)
|
|
|
|
env.Append(GENCOMSTR=generated_file_message)
|
2022-02-13 13:41:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
def disable_warnings(self):
|
|
|
|
# 'self' is the environment
|
|
|
|
if self["platform"] == "windows" and not self["use_mingw"]:
|
|
|
|
# We have to remove existing warning level defines before appending /w,
|
|
|
|
# otherwise we get: "warning D9025 : overriding '/W3' with '/w'"
|
|
|
|
warn_flags = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/WX"]
|
|
|
|
self.Append(CCFLAGS=["/w"])
|
|
|
|
self.Append(CFLAGS=["/w"])
|
|
|
|
self.Append(CXXFLAGS=["/w"])
|
|
|
|
self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x in warn_flags]
|
|
|
|
self["CFLAGS"] = [x for x in self["CFLAGS"] if not x in warn_flags]
|
|
|
|
self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x in warn_flags]
|
|
|
|
else:
|
|
|
|
self.Append(CCFLAGS=["-w"])
|
|
|
|
self.Append(CFLAGS=["-w"])
|
|
|
|
self.Append(CXXFLAGS=["-w"])
|
|
|
|
|
|
|
|
|
|
|
|
def make_icu_data(target, source, env):
|
|
|
|
dst = target[0].srcnode().abspath
|
2024-03-10 18:09:48 +01:00
|
|
|
with open(dst, "w", encoding="utf-8", newline="\n") as g:
|
|
|
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
|
|
g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")
|
|
|
|
g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")
|
|
|
|
g.write("#ifndef _ICU_DATA_H\n")
|
|
|
|
g.write("#define _ICU_DATA_H\n")
|
|
|
|
g.write('#include "unicode/utypes.h"\n')
|
|
|
|
g.write('#include "unicode/udata.h"\n')
|
|
|
|
g.write('#include "unicode/uversion.h"\n')
|
2022-02-13 13:41:29 +01:00
|
|
|
|
2024-03-10 18:09:48 +01:00
|
|
|
with open(source[0].srcnode().abspath, "rb") as f:
|
|
|
|
buf = f.read()
|
2022-02-13 13:41:29 +01:00
|
|
|
|
2024-03-10 18:09:48 +01:00
|
|
|
g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")
|
|
|
|
g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')
|
|
|
|
for i in range(len(buf)):
|
|
|
|
g.write("\t" + str(buf[i]) + ",\n")
|
2022-02-13 13:41:29 +01:00
|
|
|
|
2024-03-10 18:09:48 +01:00
|
|
|
g.write("};\n")
|
|
|
|
g.write("#endif")
|
2022-02-13 13:41:29 +01:00
|
|
|
|
|
|
|
|
2022-07-20 08:28:22 +02:00
|
|
|
def write_macos_plist(target, binary_name, identifier, name):
|
2023-11-11 23:01:24 +01:00
|
|
|
os.makedirs(f"{target}/Resource/", exist_ok=True)
|
2024-03-10 18:09:48 +01:00
|
|
|
with open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n") as f:
|
|
|
|
f.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
|
|
|
|
f.write(
|
|
|
|
f'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n'
|
|
|
|
)
|
|
|
|
f.write(f'<plist version="1.0">\n')
|
|
|
|
f.write(f"<dict>\n")
|
|
|
|
f.write(f"\t<key>CFBundleExecutable</key>\n")
|
|
|
|
f.write(f"\t<string>{binary_name}</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundleIdentifier</key>\n")
|
|
|
|
f.write(f"\t<string>{identifier}</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundleInfoDictionaryVersion</key>\n")
|
|
|
|
f.write(f"\t<string>6.0</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundleName</key>\n")
|
|
|
|
f.write(f"\t<string>{name}</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundlePackageType</key>\n")
|
|
|
|
f.write(f"\t<string>FMWK</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundleShortVersionString</key>\n")
|
|
|
|
f.write(f"\t<string>1.0.0</string>\n")
|
|
|
|
f.write(f"\t<key>CFBundleSupportedPlatforms</key>\n")
|
|
|
|
f.write(f"\t<array>\n")
|
|
|
|
f.write(f"\t\t<string>MacOSX</string>\n")
|
|
|
|
f.write(f"\t</array>\n")
|
|
|
|
f.write(f"\t<key>CFBundleVersion</key>\n")
|
|
|
|
f.write(f"\t<string>1.0.0</string>\n")
|
|
|
|
f.write(f"\t<key>LSMinimumSystemVersion</key>\n")
|
|
|
|
f.write(f"\t<string>10.14</string>\n")
|
|
|
|
f.write(f"</dict>\n")
|
|
|
|
f.write(f"</plist>\n")
|