Initial test merger script setup.

This commit is contained in:
Relintai 2023-12-17 15:19:10 +01:00
parent 9de06eb989
commit 22e0d9a7e7
5 changed files with 167 additions and 0 deletions

82
misc/merger/join.py Normal file
View File

@ -0,0 +1,82 @@
#!/usr/bin/python
#
# Copyright (c) 2023-present Péter Magyar
# Copyright (c) 2020 Krzysztof Gabis
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import sys
import argparse
import re
import os
template_args = {}
input_path = ""
def process_command(name, value):
if name == "ARG":
print("Appending arg: " + value)
return template_args[value]
elif name == "FILE":
file_path = os.path.join(input_path, value)
print("Appending file: " + value)
with open(file_path, "r") as file:
res = "#line 1 \"" + value + "\"\n"
res += file.read()
res += "#line 0"
return res
def process_template(template):
regex = r"{{([A-Z]*):([\w./]*)}}"
matches = re.finditer(regex, template, re.MULTILINE)
for _, match in enumerate(matches, start=1):
res = process_command(match.group(1), match.group(2))
template = template.replace(match.group(0), res)
return template
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--template", required=True)
parser.add_argument("--path", required=True)
parser.add_argument("--output", required=True)
args, unknown = parser.parse_known_args()
global input_path
input_path = args.path
if len(unknown) % 2 != 0:
print("Uneven number or template args")
return 1
for i in range(0, len(unknown), 2):
arg = unknown[i]
if arg.startswith("--"):
template_args[arg[2:]] = unknown[i + 1]
with open(args.template, "r") as f:
output = process_template(f.read())
with open(args.output, "w") as f:
f.write(output)
print("OK")
if __name__ == "__main__":
main()

8
misc/merger/join.sh Executable file
View File

@ -0,0 +1,8 @@
mkdir -p out
cd ..
cd ..
python misc/merger/join.py --template misc/merger/pmcore.h.inl --path . --output misc/merger/out/pmcore.h
python misc/merger/join.py --template misc/merger/pmcore.cpp.inl --path . --output misc/merger/out/pmcore.cpp

View File

@ -0,0 +1,13 @@
#ifndef PANDEMONIUM_MINIMAL_CORE_H
#include "pmcore.h"
#endif
{{FILE:core/bind/core_bind.cpp}}
{{FILE:core/bind/logger_bind.cpp}}

34
misc/merger/pmcore.h.inl Normal file
View File

@ -0,0 +1,34 @@
#ifndef PANDEMONIUM_MINIMAL_CORE_H
#define PANDEMONIUM_MINIMAL_CORE_H
// https://github.com/Relintai/pandemonium_engine_minimal
/*
Copyright (c) 2022-present Péter Magyar.
Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md).
Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
{{FILE:core/bind/core_bind.h}}
{{FILE:core/bind/logger_bind.h}}
#endif

30
misc/merger/settings Normal file
View File

@ -0,0 +1,30 @@
platform
-fno-rtti -std=gnu++14 -O2 -pipe -fpie -fno-exceptions -Wall -Wno-misleading-indentation -Wshadow-local
NO_SAFE_CAST
DEBUG_ENABLED
NDEBUG
TOUCH_ENABLED
ALSA_ENABLED
PULSEAUDIO_ENABLED
_REENTRANT
JOYDEV_ENABLED
UDEV_ENABLED
X11_ENABLED
UNIX_ENABLED
OPENGL_ENABLED
GLES_ENABLED
_FILE_OFFSET_BITS=64
GLAD_ENABLED
GLES_OVER_GL
HAVE_MNTENT
-Imodules/freetype/freetype/include -Imodules/png/libpng -Idrivers/gl_context/glad -Icore/thirdparty/zlib -Iplatform/x11 -I.
g++ -o bin/pandemonium.x11.opt.debug.64 -no-pie -T platform/x11/pck_embed.legacy.ld -static-libgcc -static-libstdc++
platform/x11/pandemonium_x11.x11.opt.debug.64.o platform/x11/context_gl_x11.x11.opt.debug.64.o platform/x11/crash_handler_x11.x11.opt.debug.64.o platform/x11/os_x11.x11.opt.debug.64.o platform/x11/key_mapping_x11.x11.opt.debug.64.o platform/x11/joypad_linux.x11.opt.debug.64.o platform/x11/power_x11.x11.opt.debug.64.o platform/x11/detect_prime.x11.opt.debug.64.o platform/x11/libudev-so_wrap.x11.opt.debug.64.o main/libmain.x11.opt.debug.64.a modules/libmodules.x11.opt.debug.64.a platform/libplatform.x11.opt.debug.64.a drivers/libdrivers.x11.opt.debug.64.a scene/libscene.x11.opt.debug.64.a servers/libservers.x11.opt.debug.64.a core/libcore.x11.opt.debug.64.a modules/freetype/libfreetype_builtin.x11.opt.debug.64.a
-lXcursor -lXinerama -lXext -lXrandr -lXrender -lX11 -lXi -lGL -lpthread -ldl