mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1355 from jonpas/makeRelPaths
Changed absolute make.py paths to read from variables
This commit is contained in:
@ -55,6 +55,7 @@ if sys.platform == "win32":
|
|||||||
import winreg
|
import winreg
|
||||||
|
|
||||||
######## GLOBALS #########
|
######## GLOBALS #########
|
||||||
|
project = "@ace"
|
||||||
ACE_VERSION = "3.0.0"
|
ACE_VERSION = "3.0.0"
|
||||||
arma3tools_path = ""
|
arma3tools_path = ""
|
||||||
work_drive = ""
|
work_drive = ""
|
||||||
@ -69,6 +70,7 @@ dssignfile = ""
|
|||||||
prefix = "ace"
|
prefix = "ace"
|
||||||
pbo_name_prefix = "ace_"
|
pbo_name_prefix = "ace_"
|
||||||
signature_blacklist = ["ace_server.pbo"]
|
signature_blacklist = ["ace_server.pbo"]
|
||||||
|
importantFiles = ["mod.cpp", "README.md", "AUTHORS.txt", "LICENSE", "logo_ace3_ca.paa"]
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# http://akiscode.com/articles/sha-1directoryhash.shtml
|
# http://akiscode.com/articles/sha-1directoryhash.shtml
|
||||||
@ -310,12 +312,6 @@ def print_yellow(msg):
|
|||||||
def copy_important_files(source_dir,destination_dir):
|
def copy_important_files(source_dir,destination_dir):
|
||||||
|
|
||||||
originalDir = os.getcwd()
|
originalDir = os.getcwd()
|
||||||
importantFiles = ["mod.cpp",
|
|
||||||
"README.md",
|
|
||||||
"AUTHORS.txt",
|
|
||||||
"LICENSE",
|
|
||||||
"logo_ace3_ca.paa"
|
|
||||||
]
|
|
||||||
|
|
||||||
#copy importantFiles
|
#copy importantFiles
|
||||||
try:
|
try:
|
||||||
@ -358,21 +354,21 @@ def copy_optionals_for_building(mod,pbos):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
#special server.pbo processing
|
#special server.pbo processing
|
||||||
files = glob.glob(os.path.join(release_dir, "@ace","optionals","*.pbo"))
|
files = glob.glob(os.path.join(release_dir, project, "optionals", "*.pbo"))
|
||||||
for file in files:
|
for file in files:
|
||||||
file_name = os.path.basename(file)
|
file_name = os.path.basename(file)
|
||||||
#print ("Adding the following file: {}".format(file_name))
|
#print ("Adding the following file: {}".format(file_name))
|
||||||
pbos.append(file_name)
|
pbos.append(file_name)
|
||||||
pbo_path = os.path.join(release_dir, "@ace","optionals",file_name)
|
pbo_path = os.path.join(release_dir, project, "optionals", file_name)
|
||||||
sigFile_name = file_name +"."+ key_name + ".bisign"
|
sigFile_name = file_name +"."+ key_name + ".bisign"
|
||||||
sig_path = os.path.join(release_dir, "@ace","optionals",sigFile_name)
|
sig_path = os.path.join(release_dir, project, "optionals", sigFile_name)
|
||||||
if (os.path.isfile(pbo_path)):
|
if (os.path.isfile(pbo_path)):
|
||||||
print("Moving {} for processing.".format(pbo_path))
|
print("Moving {} for processing.".format(pbo_path))
|
||||||
shutil.move(pbo_path, os.path.join(release_dir,"@ace","addons",file_name))
|
shutil.move(pbo_path, os.path.join(release_dir, project, "addons", file_name))
|
||||||
|
|
||||||
if (os.path.isfile(sig_path)):
|
if (os.path.isfile(sig_path)):
|
||||||
#print("Moving {} for processing.".format(sig_path))
|
#print("Moving {} for processing.".format(sig_path))
|
||||||
shutil.move(sig_path, os.path.join(release_dir,"@ace","addons",sigFile_name))
|
shutil.move(sig_path, os.path.join(release_dir, project, "addons", sigFile_name))
|
||||||
except:
|
except:
|
||||||
print_error("Error in moving")
|
print_error("Error in moving")
|
||||||
raise
|
raise
|
||||||
@ -386,9 +382,9 @@ def copy_optionals_for_building(mod,pbos):
|
|||||||
#userconfig requires special handling since it is not a PBO source folder.
|
#userconfig requires special handling since it is not a PBO source folder.
|
||||||
#CfgConvert fails to build server.pbo if userconfig is not found in P:\
|
#CfgConvert fails to build server.pbo if userconfig is not found in P:\
|
||||||
if (dir_name == "userconfig"):
|
if (dir_name == "userconfig"):
|
||||||
if (os.path.exists(os.path.join(release_dir, "@ace","optionals",dir_name))):
|
if (os.path.exists(os.path.join(release_dir, project, "optionals", dir_name))):
|
||||||
shutil.rmtree(os.path.join(release_dir, "@ace","optionals",dir_name), True)
|
shutil.rmtree(os.path.join(release_dir, project, "optionals", dir_name), True)
|
||||||
shutil.copytree(os.path.join(optionals_root,dir_name), os.path.join(release_dir, "@ace","optionals",dir_name))
|
shutil.copytree(os.path.join(optionals_root,dir_name), os.path.join(release_dir, project, "optionals", dir_name))
|
||||||
destination = os.path.join(work_drive,dir_name)
|
destination = os.path.join(work_drive,dir_name)
|
||||||
else:
|
else:
|
||||||
destination = os.path.join(module_root,dir_name)
|
destination = os.path.join(module_root,dir_name)
|
||||||
@ -417,13 +413,13 @@ def cleanup_optionals(mod):
|
|||||||
print("Cleaning {}".format(destination))
|
print("Cleaning {}".format(destination))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_name = "ace_{}.pbo".format(dir_name)
|
file_name = "{}{}.pbo".format(pbo_name_prefix,dir_name)
|
||||||
src_file_path = os.path.join(release_dir, "@ace","addons",file_name)
|
src_file_path = os.path.join(release_dir, project, "addons", file_name)
|
||||||
dst_file_path = os.path.join(release_dir, "@ace","optionals",file_name)
|
dst_file_path = os.path.join(release_dir, project, "optionals", file_name)
|
||||||
|
|
||||||
sigFile_name = file_name +"."+ key_name + ".bisign"
|
sigFile_name = "{}.{}.bisign".format(file_name,key_name)
|
||||||
src_sig_path = os.path.join(release_dir, "@ace","addons",sigFile_name)
|
src_sig_path = os.path.join(release_dir, project, "addons", sigFile_name)
|
||||||
dst_sig_path = os.path.join(release_dir, "@ace","optionals",sigFile_name)
|
dst_sig_path = os.path.join(release_dir, project, "optionals", sigFile_name)
|
||||||
|
|
||||||
if (os.path.isfile(src_file_path)):
|
if (os.path.isfile(src_file_path)):
|
||||||
#print("Preserving {}".format(file_name))
|
#print("Preserving {}".format(file_name))
|
||||||
@ -432,7 +428,7 @@ def cleanup_optionals(mod):
|
|||||||
#print("Preserving {}".format(sigFile_name))
|
#print("Preserving {}".format(sigFile_name))
|
||||||
os.renames(src_sig_path,dst_sig_path)
|
os.renames(src_sig_path,dst_sig_path)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
print_error(file_name + " already exists")
|
print_error("{} already exists".format(file_name))
|
||||||
continue
|
continue
|
||||||
shutil.rmtree(destination)
|
shutil.rmtree(destination)
|
||||||
|
|
||||||
@ -465,7 +461,7 @@ def build_signature_file(file_name):
|
|||||||
|
|
||||||
|
|
||||||
def check_for_obsolete_pbos(addonspath, file):
|
def check_for_obsolete_pbos(addonspath, file):
|
||||||
module = file[4:-4]
|
module = file[len(pbo_name_prefix):-4]
|
||||||
if not os.path.exists(os.path.join(addonspath, module)):
|
if not os.path.exists(os.path.join(addonspath, module)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -576,7 +572,7 @@ def get_ace_version():
|
|||||||
input("Press Enter to continue...")
|
input("Press Enter to continue...")
|
||||||
print("Resuming build...")
|
print("Resuming build...")
|
||||||
|
|
||||||
print_yellow("ACE VERSION set to {}".format(versionStamp))
|
print_yellow("{} VERSION set to {}".format(project.lstrip("@").upper(),versionStamp))
|
||||||
ACE_VERSION = versionStamp
|
ACE_VERSION = versionStamp
|
||||||
return ACE_VERSION
|
return ACE_VERSION
|
||||||
|
|
||||||
@ -963,13 +959,13 @@ See the make.cfg file for additional build options.
|
|||||||
|
|
||||||
# Use biKeyNameAbrev to attempt to minimize problems from this BI Bug REFERENCE: http://feedback.arma3.com/view.php?id=22133
|
# Use biKeyNameAbrev to attempt to minimize problems from this BI Bug REFERENCE: http://feedback.arma3.com/view.php?id=22133
|
||||||
biKeyNameAbrev = key_name.split("-")[0]
|
biKeyNameAbrev = key_name.split("-")[0]
|
||||||
shutil.copyfile(os.path.join(private_key_path, key_name + ".bikey"), os.path.join(module_root, release_dir, project, "keys", biKeyNameAbrev + ".bikey"))
|
shutil.copyfile(os.path.join(private_key_path, key_name + ".bikey"), os.path.join(module_root, release_dir, project, "keys", "{}.bikey".format(biKeyNameAbrev)))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print_error("Could not copy key to release directory.")
|
print_error("Could not copy key to release directory.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
key = os.path.join(private_key_path, key_name + ".biprivatekey")
|
key = os.path.join(private_key_path, "{}.biprivatekey".format(key_name))
|
||||||
|
|
||||||
# Remove any obsolete files.
|
# Remove any obsolete files.
|
||||||
print_blue("\nChecking for obsolete files...")
|
print_blue("\nChecking for obsolete files...")
|
||||||
@ -979,7 +975,7 @@ See the make.cfg file for additional build options.
|
|||||||
if check_for_obsolete_pbos(module_root, file):
|
if check_for_obsolete_pbos(module_root, file):
|
||||||
fileName = os.path.splitext(file)[0]
|
fileName = os.path.splitext(file)[0]
|
||||||
print_yellow("Removing obsolete file => {}".format(file))
|
print_yellow("Removing obsolete file => {}".format(file))
|
||||||
purge(obsolete_check_path,fileName+"\..",fileName+".*")
|
purge(obsolete_check_path, "{}\..".format(fileName), "{}.*".format(fileName))
|
||||||
|
|
||||||
obsolete_check_path = os.path.join(module_root, release_dir, project)
|
obsolete_check_path = os.path.join(module_root, release_dir, project)
|
||||||
for file in os.listdir(obsolete_check_path):
|
for file in os.listdir(obsolete_check_path):
|
||||||
@ -1010,12 +1006,12 @@ See the make.cfg file for additional build options.
|
|||||||
new_sha = get_directory_hash(os.path.join(module_root, module))
|
new_sha = get_directory_hash(os.path.join(module_root, module))
|
||||||
|
|
||||||
# Is the pbo or sig file missing?
|
# Is the pbo or sig file missing?
|
||||||
missing = not os.path.isfile(os.path.join(release_dir, project, "addons", "ace_{}.pbo".format(module)))
|
missing = not os.path.isfile(os.path.join(release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
||||||
sigFile = pbo_name_prefix+module + ".pbo." + key_name + ".bisign"
|
sigFile = "{}{}.pbo.{}.bisign".format(pbo_name_prefix,module,key_name)
|
||||||
sigMissing = not os.path.isfile(os.path.join(release_dir, project, "addons", sigFile))
|
sigMissing = not os.path.isfile(os.path.join(release_dir, project, "addons", sigFile))
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
print_yellow("Missing PBO file ace_{}.pbo".format(module) + ". Building...")
|
print_yellow("Missing PBO file {}{}.pbo. Building...".format(pbo_name_prefix,module))
|
||||||
|
|
||||||
# Check if it needs rebuilt
|
# Check if it needs rebuilt
|
||||||
# print ("Hash:", new_sha)
|
# print ("Hash:", new_sha)
|
||||||
@ -1025,7 +1021,7 @@ See the make.cfg file for additional build options.
|
|||||||
if sigMissing:
|
if sigMissing:
|
||||||
if key:
|
if key:
|
||||||
print("Missing Signature key {}".format(sigFile))
|
print("Missing Signature key {}".format(sigFile))
|
||||||
build_signature_file(os.path.join(module_root, release_dir, project, "addons", pbo_name_prefix + module + ".pbo"))
|
build_signature_file(os.path.join(module_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
||||||
# Skip everything else
|
# Skip everything else
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1050,13 +1046,13 @@ See the make.cfg file for additional build options.
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Remove the old pbo, key, and log
|
# Remove the old pbo, key, and log
|
||||||
old = os.path.join(module_root, release_dir, project, "addons", pbo_name_prefix+module) + "*"
|
old = os.path.join(module_root, release_dir, project, "addons", "{}{}".format(pbo_name_prefix,module)) + "*"
|
||||||
files = glob.glob(old)
|
files = glob.glob(old)
|
||||||
for f in files:
|
for f in files:
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
|
|
||||||
if pbo_name_prefix:
|
if pbo_name_prefix:
|
||||||
old = os.path.join(module_root, release_dir, project, "addons", pbo_name_prefix+module) + "*"
|
old = os.path.join(module_root, release_dir, project, "addons", "{}{}".format(pbo_name_prefix,module)) + "*"
|
||||||
files = glob.glob(old)
|
files = glob.glob(old)
|
||||||
for f in files:
|
for f in files:
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
@ -1114,17 +1110,17 @@ See the make.cfg file for additional build options.
|
|||||||
# Prettyprefix rename the PBO if requested.
|
# Prettyprefix rename the PBO if requested.
|
||||||
if pbo_name_prefix:
|
if pbo_name_prefix:
|
||||||
try:
|
try:
|
||||||
os.rename(os.path.join(module_root, release_dir, project, "addons", module+".pbo"), os.path.join(module_root, release_dir, project, "addons", pbo_name_prefix+module+".pbo"))
|
os.rename(os.path.join(module_root, release_dir, project, "addons", "{}.pbo".format(module)), os.path.join(module_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
print_error("Could not rename built PBO with prefix.")
|
print_error("Could not rename built PBO with prefix.")
|
||||||
# Sign result
|
# Sign result
|
||||||
if (key and not "ace_{}.pbo".format(module) in signature_blacklist):
|
if (key and not "{}{}.pbo".format(pbo_name_prefix,module) in signature_blacklist):
|
||||||
print("Signing with {}.".format(key))
|
print("Signing with {}.".format(key))
|
||||||
if pbo_name_prefix:
|
if pbo_name_prefix:
|
||||||
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", pbo_name_prefix + module + ".pbo")])
|
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module))])
|
||||||
else:
|
else:
|
||||||
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", module + ".pbo")])
|
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", "{}.pbo".format(module))])
|
||||||
|
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
build_successful = True
|
build_successful = True
|
||||||
@ -1183,7 +1179,7 @@ See the make.cfg file for additional build options.
|
|||||||
# Prettyprefix rename the PBO if requested.
|
# Prettyprefix rename the PBO if requested.
|
||||||
if pbo_name_prefix:
|
if pbo_name_prefix:
|
||||||
try:
|
try:
|
||||||
os.rename(os.path.join(make_root, release_dir, project, "addons", module+".pbo"), os.path.join(make_root, release_dir, project, "addons", pbo_name_prefix+module+".pbo"))
|
os.rename(os.path.join(make_root, release_dir, project, "addons", "{}.pbo".format(module)), os.path.join(make_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
print_error("Could not rename built PBO with prefix.")
|
print_error("Could not rename built PBO with prefix.")
|
||||||
@ -1192,12 +1188,12 @@ See the make.cfg file for additional build options.
|
|||||||
# Sign result
|
# Sign result
|
||||||
|
|
||||||
#print_yellow("Sig_fileName: ace_{}.pbo".format(module))
|
#print_yellow("Sig_fileName: ace_{}.pbo".format(module))
|
||||||
if (key and not "ace_{}.pbo".format(module) in signature_blacklist) :
|
if (key and not "{}{}.pbo".format(pbo_name_prefix,module) in signature_blacklist) :
|
||||||
print("Signing with {}.".format(key))
|
print("Signing with {}.".format(key))
|
||||||
if pbo_name_prefix:
|
if pbo_name_prefix:
|
||||||
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons", pbo_name_prefix + module + ".pbo")])
|
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons","{}{}.pbo".format(pbo_name_prefix,module))])
|
||||||
else:
|
else:
|
||||||
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons", module + ".pbo")])
|
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons", "{}.pbo".format(module))])
|
||||||
|
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
build_successful = True
|
build_successful = True
|
||||||
@ -1229,7 +1225,7 @@ See the make.cfg file for additional build options.
|
|||||||
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
copy_important_files(module_root_parent,os.path.join(release_dir, "@ace"))
|
copy_important_files(module_root_parent,os.path.join(release_dir, project))
|
||||||
cleanup_optionals(optionals_modules)
|
cleanup_optionals(optionals_modules)
|
||||||
|
|
||||||
# Done building all modules!
|
# Done building all modules!
|
||||||
|
Reference in New Issue
Block a user