Path: blob/master/modules/text_server_adv/gdextension_build/methods.py
10278 views
def disable_warnings(self):1# 'self' is the environment2if self["platform"] == "windows" and not self["use_mingw"]:3# We have to remove existing warning level defines before appending /w,4# otherwise we get: "warning D9025 : overriding '/W3' with '/w'"5WARN_FLAGS = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/W0"]6self["CCFLAGS"] = [x for x in self["CCFLAGS"] if x not in WARN_FLAGS]7self["CFLAGS"] = [x for x in self["CFLAGS"] if x not in WARN_FLAGS]8self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if x not in WARN_FLAGS]9self.AppendUnique(CCFLAGS=["/w"])10else:11self.AppendUnique(CCFLAGS=["-w"])121314def prepare_timer():15import atexit16import time1718def print_elapsed_time(time_at_start: float):19time_elapsed = time.time() - time_at_start20time_formatted = time.strftime("%H:%M:%S", time.gmtime(time_elapsed))21time_centiseconds = round((time_elapsed % 1) * 100)22print(f"[Time elapsed: {time_formatted}.{time_centiseconds}]")2324atexit.register(print_elapsed_time, time.time())252627def make_icu_data(target, source, env):28dst = target[0].srcnode().abspath29with open(dst, "w", encoding="utf-8", newline="\n") as g:30g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")31g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")32g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")33g.write("#ifndef _ICU_DATA_H\n")34g.write("#define _ICU_DATA_H\n")35g.write('#include "unicode/utypes.h"\n')36g.write('#include "unicode/udata.h"\n')37g.write('#include "unicode/uversion.h"\n')3839with open(source[0].srcnode().abspath, "rb") as f:40buf = f.read()4142g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")43g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')44for i in range(len(buf)):45g.write("\t" + str(buf[i]) + ",\n")4647g.write("};\n")48g.write("#endif")495051def write_macos_plist(target, binary_name, identifier, name):52import os5354os.makedirs(f"{target}/Resource/", exist_ok=True)55with open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n") as f:56f.write(f"""\57<?xml version="1.0" encoding="UTF-8"?>58<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">59<plist version="1.0">60<dict>61<key>CFBundleExecutable</key>62<string>{binary_name}</string>63<key>CFBundleIdentifier</key>64<string>{identifier}</string>65<key>CFBundleInfoDictionaryVersion</key>66<string>6.0</string>67<key>CFBundleName</key>68<string>{name}</string>69<key>CFBundlePackageType</key>70<string>FMWK</string>71<key>CFBundleShortVersionString</key>72<string>1.0.0</string>73<key>CFBundleSupportedPlatforms</key>74<array>75<string>MacOSX</string>76</array>77<key>CFBundleVersion</key>78<string>1.0.0</string>79<key>LSMinimumSystemVersion</key>80<string>10.14</string>81</dict>82</plist>83""")848586