From 4d699fe780d7594ef703fd2ec5e1fc1b5002c759 Mon Sep 17 00:00:00 2001 From: zaCade Date: Fri, 7 Dec 2018 16:49:40 +0100 Subject: [PATCH] Initialize --- .gitignore | 4 ++++ compile-all.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++ compile.py | 42 +++++++++++++++++++++++++++++++++++++++++ plugins/.gitignore | 2 ++ 4 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 compile-all.py create mode 100644 compile.py create mode 100644 plugins/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b0f1d39d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/include +/spcomp +/spcomp.exe +*.secret diff --git a/compile-all.py b/compile-all.py new file mode 100644 index 00000000..40e034c6 --- /dev/null +++ b/compile-all.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 +import os +import sys +import subprocess + +c_null = "\x1b[00;00m" +c_red = "\x1b[31;01m" +c_blue = "\x1b[34;01m" +c_green = "\x1b[32;01m" + +SM_INCLUDES = "includes" +SPCOMP = "./spcomp" + +if __name__ == "__main__": + Plugins = [] + Path, Directories, Files = next(os.walk(".")) + for Directory in Directories: + if not Directory.startswith(".") and not Directory.startswith("_") and Directory != "include" and Directory != "includes" and Directory != "plugins": + Plugins.append(Directory) + + for Plugin in Plugins: + print(c_red + "### Compiling {0}".format(Plugin) + c_null) + + SourcePath = os.path.join(Plugin, "scripting") + Path, Directories, Files = next(os.walk(SourcePath)) + for File in Files: + if File.endswith(".sp"): + print(c_green + "# Compiling {0} ({1})".format(os.path.basename(File), Plugin) + c_null) + SourcePath = os.path.join(Path, File) + IncludePath = os.path.join(Path, "include") + OutDir = "plugins" + OutPath = os.path.join(OutDir, os.path.splitext(os.path.basename(SourcePath))[0] + ".smx") + + Compiler = [SPCOMP, "-i" + SM_INCLUDES] + if os.path.isdir(IncludePath): + Compiler.append("-i" + IncludePath) + Compiler.append(SourcePath) + Compiler.append("-o" + OutPath) + + try: + err = subprocess.call(Compiler) + if err: + raise Exception() + except Exception: + sys.exit(1) + + print("") diff --git a/compile.py b/compile.py new file mode 100644 index 00000000..ffe789f3 --- /dev/null +++ b/compile.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +import os +import sys +import subprocess + +c_null = "\x1b[00;00m" +c_red = "\x1b[31;01m" +c_blue = "\x1b[34;01m" +c_green = "\x1b[32;01m" + +SM_INCLUDES = "includes" +SPCOMP = "./spcomp" + +if __name__ == "__main__": + Plugins = [] + for Directory in sys.argv[1:]: + if Directory != ".git" and Directory != "include" and Directory != "includes" and Directory != "plugins": + Plugins.append(Directory) + + for Plugin in Plugins: + SourcePath = os.path.join(Plugin, "scripting") + Path, Directories, Files = next(os.walk(SourcePath)) + for File in Files: + if File.endswith(".sp"): + print(c_green + "# Compiling {0} ({1})".format(os.path.basename(File), Plugin) + c_null) + SourcePath = os.path.join(Path, File) + IncludePath = os.path.join(Path, "include") + OutDir = "plugins" + OutPath = os.path.join(OutDir, os.path.splitext(os.path.basename(SourcePath))[0] + ".smx") + + Compiler = [SPCOMP, "-i" + SM_INCLUDES] + if os.path.isdir(IncludePath): + Compiler.append("-i" + IncludePath) + Compiler.append(SourcePath) + Compiler.append("-o" + OutPath) + + try: + subprocess.call(Compiler) + except Exception: + sys.exit(1) + + print("") diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore