2015-04-07 20:16:22 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
2015-05-22 17:51:06 +00:00
|
|
|
######## GLOBALS #########
|
2015-05-24 20:07:12 +00:00
|
|
|
MAINPREFIX = "z"
|
|
|
|
PREFIX = "ace_"
|
2015-05-22 17:51:06 +00:00
|
|
|
##########################
|
2015-04-07 20:16:22 +00:00
|
|
|
|
|
|
|
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):
|
2015-05-24 20:07:12 +00:00
|
|
|
if not os.path.exists(os.path.join(addonspath, "{}{}.pbo".format(PREFIX,module))):
|
2015-04-07 20:16:22 +00:00
|
|
|
return True
|
2015-05-24 20:07:12 +00:00
|
|
|
return mod_time(os.path.join(addonspath, module)) > mod_time(os.path.join(addonspath, "{}{}.pbo".format(PREFIX,module)))
|
2015-04-07 20:16:22 +00:00
|
|
|
|
2015-04-14 17:52:30 +00:00
|
|
|
def check_for_obsolete_pbos(addonspath, file):
|
2015-05-24 20:07:12 +00:00
|
|
|
module = file[len(PREFIX):-4]
|
2015-04-14 17:52:30 +00:00
|
|
|
if not os.path.exists(os.path.join(addonspath, module)):
|
|
|
|
return True
|
|
|
|
return False
|
2015-04-07 20:16:22 +00:00
|
|
|
|
|
|
|
def main():
|
2015-04-09 19:37:54 +00:00
|
|
|
print("""
|
|
|
|
####################
|
|
|
|
# ACE3 Debug Build #
|
|
|
|
####################
|
|
|
|
""")
|
2015-04-07 20:16:22 +00:00
|
|
|
|
|
|
|
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
|
2015-04-14 17:52:30 +00:00
|
|
|
removed = 0
|
2020-08-27 15:44:18 +00:00
|
|
|
|
2015-04-14 17:52:30 +00:00
|
|
|
for file in os.listdir(addonspath):
|
|
|
|
if os.path.isfile(file):
|
|
|
|
if check_for_obsolete_pbos(addonspath, file):
|
|
|
|
removed += 1
|
|
|
|
print(" Removing obsolete file => " + file)
|
|
|
|
os.remove(file)
|
2020-08-27 15:44:18 +00:00
|
|
|
print("")
|
|
|
|
|
2015-04-07 20:16:22 +00:00
|
|
|
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
|
2015-04-09 19:37:54 +00:00
|
|
|
print(" Skipping {}.".format(p))
|
2015-04-07 20:16:22 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
print("# Making {} ...".format(p))
|
|
|
|
|
|
|
|
try:
|
|
|
|
subprocess.check_output([
|
|
|
|
"makepbo",
|
|
|
|
"-NUP",
|
2015-05-24 20:07:12 +00:00
|
|
|
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
|
2015-04-07 20:16:22 +00:00
|
|
|
p,
|
2015-05-24 20:07:12 +00:00
|
|
|
"{}{}.pbo".format(PREFIX,p)
|
2015-04-07 20:16:22 +00:00
|
|
|
], stderr=subprocess.STDOUT)
|
|
|
|
except:
|
|
|
|
failed += 1
|
|
|
|
print(" Failed to make {}.".format(p))
|
|
|
|
else:
|
|
|
|
made += 1
|
|
|
|
print(" Successfully made {}.".format(p))
|
|
|
|
|
|
|
|
print("\n# Done.")
|
2015-04-14 17:52:30 +00:00
|
|
|
print(" Made {}, skipped {}, removed {}, failed to make {}.".format(made, skipped, removed, failed))
|
2015-04-07 20:16:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|