mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Make build.bat a python script
This commit is contained in:
parent
37935c014d
commit
7398c7a8ed
@ -1,7 +0,0 @@
|
||||
pushd ..\addons\
|
||||
del /q /f *.pbo
|
||||
for /D %%i in (*.*) do (
|
||||
makepbo -NUP -@=z\addons\ace\%%i %%i ace_%%i.pbo
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
)
|
||||
popd
|
70
tools/build.py
Normal file
70
tools/build.py
Normal file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def mod_time(path):
|
||||
if not os.path.isdir(path):
|
||||
return os.path.getmtime(path)
|
||||
maxi = os.path.getmtime(path)
|
||||
for p in os.listdir(path):
|
||||
maxi = max(mod_time(os.path.join(path, p)), maxi)
|
||||
return maxi
|
||||
|
||||
|
||||
def check_for_changes(addonspath, module):
|
||||
if not os.path.exists(os.path.join(addonspath, "ace_{}.pbo".format(module))):
|
||||
return True
|
||||
return mod_time(os.path.join(addonspath, module)) > mod_time(os.path.join(addonspath, "ace_{}.pbo".format(module)))
|
||||
|
||||
|
||||
def main():
|
||||
print("####################")
|
||||
print("# ACE3 Debug Build #")
|
||||
print("####################\n")
|
||||
|
||||
scriptpath = os.path.realpath(__file__)
|
||||
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
||||
addonspath = os.path.join(projectpath, "addons")
|
||||
|
||||
os.chdir(addonspath)
|
||||
|
||||
made = 0
|
||||
failed = 0
|
||||
skipped = 0
|
||||
for p in os.listdir(addonspath):
|
||||
path = os.path.join(addonspath, p)
|
||||
if not os.path.isdir(path):
|
||||
continue
|
||||
if p[0] == ".":
|
||||
continue
|
||||
if not check_for_changes(addonspath, p):
|
||||
skipped += 1
|
||||
print("Skipping {}.".format(p))
|
||||
continue
|
||||
|
||||
print("# Making {} ...".format(p))
|
||||
|
||||
try:
|
||||
subprocess.check_output([
|
||||
"makepbo",
|
||||
"-NUP",
|
||||
"-@=z\\addons\\ace\\{}".format(p),
|
||||
p,
|
||||
"ace_{}.pbo".format(p)
|
||||
], stderr=subprocess.STDOUT)
|
||||
except:
|
||||
failed += 1
|
||||
print(" Failed to make {}.".format(p))
|
||||
else:
|
||||
made += 1
|
||||
print(" Successfully made {}.".format(p))
|
||||
|
||||
print("\n# Done.")
|
||||
print(" Made {}, skipped {}, failed to make {}.".format(made, skipped, failed))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue
Block a user