2016-04-26 12:36:03 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
2017-05-20 05:08:31 +02:00
|
|
|
c_null = "\x1b[00;00m"
|
|
|
|
c_red = "\x1b[31;01m"
|
|
|
|
c_blue = "\x1b[34;01m"
|
|
|
|
c_green = "\x1b[32;01m"
|
|
|
|
|
2016-04-26 12:36:03 +02:00
|
|
|
SM_INCLUDES = "includes"
|
|
|
|
SPCOMP = "./spcomp"
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
Plugins = []
|
|
|
|
for Directory in sys.argv[1:]:
|
2019-09-21 23:50:10 +02:00
|
|
|
if Directory != ".git" and Directory != "include" and Directory != "includes" and Directory != "plugins" and Directory != "secrets":
|
2016-04-26 12:36:03 +02:00
|
|
|
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"):
|
2017-08-02 22:33:40 +02:00
|
|
|
print(c_green + "# Compiling {0} ({1})".format(os.path.basename(File), Plugin) + c_null)
|
2016-04-26 12:36:03 +02:00
|
|
|
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")
|
|
|
|
|
2019-09-21 23:50:10 +02:00
|
|
|
Compiler = [SPCOMP, "-i" + SM_INCLUDES, "-i" + "include", "-i" + "secrets"]
|
2016-04-26 12:36:03 +02:00
|
|
|
if os.path.isdir(IncludePath):
|
|
|
|
Compiler.append("-i" + IncludePath)
|
|
|
|
Compiler.append(SourcePath)
|
|
|
|
Compiler.append("-o" + OutPath)
|
|
|
|
|
|
|
|
try:
|
2017-08-04 03:07:07 +02:00
|
|
|
subprocess.call(Compiler)
|
2016-04-26 12:36:03 +02:00
|
|
|
except Exception:
|
|
|
|
sys.exit(1)
|
2017-08-02 22:33:40 +02:00
|
|
|
|
|
|
|
print("")
|