2015-08-25 18:59:55 +00:00
|
|
|
#!/usr/bin/env python3
|
2015-03-20 18:04:54 +00:00
|
|
|
# vim: set fileencoding=utf-8 :
|
|
|
|
|
|
|
|
# make.py
|
|
|
|
# An Arma 3 addon build system
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# The MIT License (MIT)
|
|
|
|
|
2015-04-09 11:37:19 +00:00
|
|
|
# Copyright (c) 2013-2014 Ryan Schultz
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
2017-06-14 13:34:35 +00:00
|
|
|
__version__ = "0.9"
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if sys.version_info[0] == 2:
|
2015-04-21 11:02:10 +00:00
|
|
|
print("Python 3 is required.")
|
|
|
|
sys.exit(1)
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import shutil
|
|
|
|
import platform
|
|
|
|
import glob
|
|
|
|
import subprocess
|
|
|
|
import hashlib
|
|
|
|
import configparser
|
|
|
|
import json
|
|
|
|
import traceback
|
2015-04-07 17:49:00 +00:00
|
|
|
import time
|
2015-08-24 06:00:22 +00:00
|
|
|
import timeit
|
2015-04-07 22:04:57 +00:00
|
|
|
import re
|
2016-10-25 18:11:05 +00:00
|
|
|
import fileinput
|
2015-06-17 18:42:11 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
if sys.platform == "win32":
|
2015-04-21 11:02:10 +00:00
|
|
|
import winreg
|
2015-03-20 18:04:54 +00:00
|
|
|
|
2015-04-19 21:51:51 +00:00
|
|
|
######## GLOBALS #########
|
2015-05-22 17:21:29 +00:00
|
|
|
project = "@ace"
|
2015-08-25 18:59:55 +00:00
|
|
|
project_version = "3.0.0"
|
2015-05-11 19:53:49 +00:00
|
|
|
arma3tools_path = ""
|
2015-04-19 21:51:51 +00:00
|
|
|
work_drive = ""
|
|
|
|
module_root = ""
|
2015-05-11 01:16:27 +00:00
|
|
|
make_root = ""
|
2015-04-19 21:51:51 +00:00
|
|
|
release_dir = ""
|
|
|
|
module_root_parent = ""
|
|
|
|
optionals_root = ""
|
2015-05-11 01:16:27 +00:00
|
|
|
key_name = "ace"
|
2015-04-23 02:14:03 +00:00
|
|
|
key = ""
|
|
|
|
dssignfile = ""
|
2015-05-11 01:16:27 +00:00
|
|
|
prefix = "ace"
|
|
|
|
pbo_name_prefix = "ace_"
|
2017-11-17 05:44:20 +00:00
|
|
|
signature_blacklist = []
|
2016-02-18 16:00:19 +00:00
|
|
|
importantFiles = ["mod.cpp", "README.md", "docs\\README_DE.md", "docs\\README_PL.md", "AUTHORS.txt", "LICENSE", "logo_ace3_ca.paa", "meta.cpp"]
|
2015-09-09 16:57:34 +00:00
|
|
|
versionFiles = ["README.md", "docs\\README_DE.md", "docs\\README_PL.md", "mod.cpp"]
|
2015-04-19 21:51:51 +00:00
|
|
|
|
2016-02-16 14:46:10 +00:00
|
|
|
ciBuild = False # Used for CI builds
|
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
###############################################################################
|
|
|
|
# http://akiscode.com/articles/sha-1directoryhash.shtml
|
|
|
|
# Copyright (c) 2009 Stephen Akiki
|
|
|
|
# MIT License (Means you can do whatever you want with this)
|
|
|
|
# See http://www.opensource.org/licenses/mit-license.php
|
|
|
|
# Error Codes:
|
|
|
|
# -1 -> Directory does not exist
|
|
|
|
# -2 -> General error (see stack traceback)
|
|
|
|
def get_directory_hash(directory):
|
2015-04-21 11:02:10 +00:00
|
|
|
directory_hash = hashlib.sha1()
|
|
|
|
if not os.path.exists (directory):
|
|
|
|
return -1
|
|
|
|
|
|
|
|
try:
|
|
|
|
for root, dirs, files in os.walk(directory):
|
|
|
|
for names in files:
|
|
|
|
path = os.path.join(root, names)
|
|
|
|
try:
|
|
|
|
f = open(path, 'rb')
|
|
|
|
except:
|
|
|
|
# You can't open the file for some reason
|
|
|
|
f.close()
|
|
|
|
continue
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
# Read file in as little chunks
|
|
|
|
buf = f.read(4096)
|
|
|
|
if not buf: break
|
|
|
|
new = hashlib.sha1(buf)
|
|
|
|
directory_hash.update(new.digest())
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
except:
|
|
|
|
# Print the stack traceback
|
|
|
|
traceback.print_exc()
|
|
|
|
return -2
|
|
|
|
|
2015-05-09 18:05:35 +00:00
|
|
|
retVal = directory_hash.hexdigest()
|
|
|
|
#print_yellow("Hash Value for {} is {}".format(directory,retVal))
|
2015-04-21 11:02:10 +00:00
|
|
|
return directory_hash.hexdigest()
|
2015-03-20 18:04:54 +00:00
|
|
|
|
2015-08-24 06:00:22 +00:00
|
|
|
def Fract_Sec(s):
|
|
|
|
temp = float()
|
|
|
|
temp = float(s) / (60*60*24)
|
|
|
|
d = int(temp)
|
|
|
|
temp = (temp - d) * 24
|
|
|
|
h = int(temp)
|
|
|
|
temp = (temp - h) * 60
|
|
|
|
m = int(temp)
|
|
|
|
temp = (temp - m) * 60
|
|
|
|
sec = temp
|
|
|
|
return d,h,m,sec
|
|
|
|
#endef Fract_Sec
|
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
# Copyright (c) André Burgaud
|
|
|
|
# http://www.burgaud.com/bring-colors-to-the-windows-console-with-python/
|
|
|
|
if sys.platform == "win32":
|
2015-04-21 11:02:10 +00:00
|
|
|
from ctypes import windll, Structure, c_short, c_ushort, byref
|
|
|
|
|
|
|
|
SHORT = c_short
|
|
|
|
WORD = c_ushort
|
|
|
|
|
|
|
|
class COORD(Structure):
|
|
|
|
"""struct in wincon.h."""
|
|
|
|
_fields_ = [
|
|
|
|
("X", SHORT),
|
|
|
|
("Y", SHORT)]
|
|
|
|
|
|
|
|
class SMALL_RECT(Structure):
|
|
|
|
"""struct in wincon.h."""
|
|
|
|
_fields_ = [
|
|
|
|
("Left", SHORT),
|
|
|
|
("Top", SHORT),
|
|
|
|
("Right", SHORT),
|
|
|
|
("Bottom", SHORT)]
|
|
|
|
|
|
|
|
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
|
|
|
"""struct in wincon.h."""
|
|
|
|
_fields_ = [
|
|
|
|
("dwSize", COORD),
|
|
|
|
("dwCursorPosition", COORD),
|
|
|
|
("wAttributes", WORD),
|
|
|
|
("srWindow", SMALL_RECT),
|
|
|
|
("dwMaximumWindowSize", COORD)]
|
|
|
|
|
|
|
|
# winbase.h
|
|
|
|
STD_INPUT_HANDLE = -10
|
|
|
|
STD_OUTPUT_HANDLE = -11
|
|
|
|
STD_ERROR_HANDLE = -12
|
|
|
|
|
|
|
|
# wincon.h
|
|
|
|
FOREGROUND_BLACK = 0x0000
|
|
|
|
FOREGROUND_BLUE = 0x0001
|
|
|
|
FOREGROUND_GREEN = 0x0002
|
|
|
|
FOREGROUND_CYAN = 0x0003
|
|
|
|
FOREGROUND_RED = 0x0004
|
|
|
|
FOREGROUND_MAGENTA = 0x0005
|
|
|
|
FOREGROUND_YELLOW = 0x0006
|
|
|
|
FOREGROUND_GREY = 0x0007
|
|
|
|
FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified.
|
|
|
|
|
|
|
|
BACKGROUND_BLACK = 0x0000
|
|
|
|
BACKGROUND_BLUE = 0x0010
|
|
|
|
BACKGROUND_GREEN = 0x0020
|
|
|
|
BACKGROUND_CYAN = 0x0030
|
|
|
|
BACKGROUND_RED = 0x0040
|
|
|
|
BACKGROUND_MAGENTA = 0x0050
|
|
|
|
BACKGROUND_YELLOW = 0x0060
|
|
|
|
BACKGROUND_GREY = 0x0070
|
|
|
|
BACKGROUND_INTENSITY = 0x0080 # background color is intensified.
|
|
|
|
|
|
|
|
stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
|
|
|
|
SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
|
|
|
GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
|
|
|
|
|
|
|
def get_text_attr():
|
|
|
|
"""Returns the character attributes (colors) of the console screen
|
|
|
|
buffer."""
|
|
|
|
csbi = CONSOLE_SCREEN_BUFFER_INFO()
|
|
|
|
GetConsoleScreenBufferInfo(stdout_handle, byref(csbi))
|
|
|
|
return csbi.wAttributes
|
|
|
|
|
|
|
|
def set_text_attr(color):
|
|
|
|
"""Sets the character attributes (colors) of the console screen
|
|
|
|
buffer. Color is a combination of foreground and background color,
|
|
|
|
foreground and background intensity."""
|
|
|
|
SetConsoleTextAttribute(stdout_handle, color)
|
2015-03-20 18:04:54 +00:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
def find_bi_tools(work_drive):
|
2015-04-21 11:02:10 +00:00
|
|
|
"""Find BI tools."""
|
|
|
|
|
|
|
|
reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
|
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(reg, r"Software\bohemia interactive\arma 3 tools")
|
|
|
|
arma3tools_path = winreg.QueryValueEx(k, "path")[0]
|
|
|
|
winreg.CloseKey(k)
|
|
|
|
except:
|
|
|
|
raise Exception("BadTools","Arma 3 Tools are not installed correctly or the P: drive needs to be created.")
|
|
|
|
|
|
|
|
addonbuilder_path = os.path.join(arma3tools_path, "AddonBuilder", "AddonBuilder.exe")
|
|
|
|
dssignfile_path = os.path.join(arma3tools_path, "DSSignFile", "DSSignFile.exe")
|
|
|
|
dscreatekey_path = os.path.join(arma3tools_path, "DSSignFile", "DSCreateKey.exe")
|
|
|
|
cfgconvert_path = os.path.join(arma3tools_path, "CfgConvert", "CfgConvert.exe")
|
|
|
|
|
|
|
|
if os.path.isfile(addonbuilder_path) and os.path.isfile(dssignfile_path) and os.path.isfile(dscreatekey_path) and os.path.isfile(cfgconvert_path):
|
|
|
|
return [addonbuilder_path, dssignfile_path, dscreatekey_path, cfgconvert_path]
|
|
|
|
else:
|
|
|
|
raise Exception("BadTools","Arma 3 Tools are not installed correctly or the P: drive needs to be created.")
|
2015-03-20 18:04:54 +00:00
|
|
|
|
2015-04-23 03:09:52 +00:00
|
|
|
|
2017-11-22 22:10:30 +00:00
|
|
|
def find_depbo_tools():
|
2015-04-21 11:02:10 +00:00
|
|
|
"""Use registry entries to find DePBO-based tools."""
|
2017-11-22 22:10:30 +00:00
|
|
|
requiredToolPaths = {"pboProject": None, "rapify": None, "MakePbo": None}
|
|
|
|
failed = False
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2017-11-22 22:10:30 +00:00
|
|
|
for tool in requiredToolPaths:
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
2017-12-04 19:15:24 +00:00
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Mikero\{}".format(tool))
|
|
|
|
path = winreg.QueryValueEx(k, "exe")[0]
|
|
|
|
except FileNotFoundError:
|
2017-12-12 11:40:33 +00:00
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Mikero\{}".format(tool))
|
|
|
|
path = winreg.QueryValueEx(k, "exe")[0]
|
|
|
|
except FileNotFoundError:
|
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Wow6432Node\Mikero\{}".format(tool))
|
|
|
|
path = winreg.QueryValueEx(k, "exe")[0]
|
|
|
|
except FileNotFoundError:
|
|
|
|
k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Wow6432Node\Mikero\{}".format(tool))
|
|
|
|
path = winreg.QueryValueEx(k, "exe")[0]
|
2015-04-21 11:02:10 +00:00
|
|
|
except FileNotFoundError:
|
2017-12-04 19:15:24 +00:00
|
|
|
print_error("Could not find {}".format(tool))
|
|
|
|
failed = True
|
|
|
|
else:
|
2017-11-22 22:10:30 +00:00
|
|
|
#Strip any quotations from the path due to a MikeRo tool bug which leaves a trailing space in some of its registry paths.
|
|
|
|
requiredToolPaths[tool] = path.strip('"')
|
|
|
|
print_green("Found {}.".format(tool))
|
|
|
|
finally:
|
2015-04-21 11:02:10 +00:00
|
|
|
winreg.CloseKey(k)
|
|
|
|
|
2017-11-22 22:10:30 +00:00
|
|
|
if failed:
|
|
|
|
raise Exception("BadDePBO", "DePBO tools not installed correctly")
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2017-11-22 22:10:30 +00:00
|
|
|
return requiredToolPaths
|
2015-03-20 18:04:54 +00:00
|
|
|
|
2015-04-23 03:09:52 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
def color(color):
|
2015-04-21 11:02:10 +00:00
|
|
|
"""Set the color. Works on Win32 and normal terminals."""
|
|
|
|
if sys.platform == "win32":
|
|
|
|
if color == "green":
|
|
|
|
set_text_attr(FOREGROUND_GREEN | get_text_attr() & 0x0070 | FOREGROUND_INTENSITY)
|
|
|
|
elif color == "yellow":
|
|
|
|
set_text_attr(FOREGROUND_YELLOW | get_text_attr() & 0x0070 | FOREGROUND_INTENSITY)
|
|
|
|
elif color == "red":
|
|
|
|
set_text_attr(FOREGROUND_RED | get_text_attr() & 0x0070 | FOREGROUND_INTENSITY)
|
|
|
|
elif color == "blue":
|
|
|
|
set_text_attr(FOREGROUND_BLUE | get_text_attr() & 0x0070 | FOREGROUND_INTENSITY)
|
|
|
|
elif color == "reset":
|
|
|
|
set_text_attr(FOREGROUND_GREY | get_text_attr() & 0x0070)
|
|
|
|
elif color == "grey":
|
|
|
|
set_text_attr(FOREGROUND_GREY | get_text_attr() & 0x0070)
|
|
|
|
else :
|
|
|
|
if color == "green":
|
|
|
|
sys.stdout.write('\033[92m')
|
|
|
|
elif color == "red":
|
|
|
|
sys.stdout.write('\033[91m')
|
|
|
|
elif color == "blue":
|
|
|
|
sys.stdout.write('\033[94m')
|
|
|
|
elif color == "reset":
|
|
|
|
sys.stdout.write('\033[0m')
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
def print_error(msg):
|
2015-04-21 11:02:10 +00:00
|
|
|
color("red")
|
2017-06-14 13:34:35 +00:00
|
|
|
print("ERROR: {}".format(msg))
|
2015-04-21 11:02:10 +00:00
|
|
|
color("reset")
|
2017-06-14 13:34:35 +00:00
|
|
|
global printedErrors
|
|
|
|
printedErrors += 1
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
def print_green(msg):
|
2015-04-21 11:02:10 +00:00
|
|
|
color("green")
|
|
|
|
print(msg)
|
|
|
|
color("reset")
|
2015-03-20 18:04:54 +00:00
|
|
|
|
|
|
|
def print_blue(msg):
|
2015-04-21 11:02:10 +00:00
|
|
|
color("blue")
|
|
|
|
print(msg)
|
|
|
|
color("reset")
|
2015-04-09 11:37:19 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
def print_yellow(msg):
|
2015-04-21 11:02:10 +00:00
|
|
|
color("yellow")
|
|
|
|
print(msg)
|
|
|
|
color("reset")
|
2015-03-20 18:04:54 +00:00
|
|
|
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-18 03:23:39 +00:00
|
|
|
def copy_important_files(source_dir,destination_dir):
|
2015-04-21 11:02:10 +00:00
|
|
|
originalDir = os.getcwd()
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-08-25 18:28:33 +00:00
|
|
|
# Copy importantFiles
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
2015-05-03 14:21:27 +00:00
|
|
|
print_blue("\nSearching for important files in {}".format(source_dir))
|
|
|
|
print("Source_dir: {}".format(source_dir))
|
|
|
|
print("Destination_dir: {}".format(destination_dir))
|
2015-04-24 22:08:19 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
for file in importantFiles:
|
2015-08-25 18:28:33 +00:00
|
|
|
filePath = os.path.join(module_root_parent, file)
|
2016-10-25 18:11:05 +00:00
|
|
|
if os.path.exists(filePath):
|
|
|
|
print_green("Copying file => {}".format(filePath))
|
|
|
|
shutil.copy(os.path.join(source_dir,filePath), destination_dir)
|
|
|
|
else:
|
|
|
|
missingFiles.append("{}".format(filePath))
|
|
|
|
print_error("Failed copying file => {}".format(filePath))
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
print_error("COPYING IMPORTANT FILES.")
|
|
|
|
raise
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
# Copy all extension DLL's
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
|
|
|
os.chdir(os.path.join(source_dir))
|
2015-05-03 14:21:27 +00:00
|
|
|
print_blue("\nSearching for DLLs in {}".format(os.getcwd()))
|
2015-04-21 11:02:10 +00:00
|
|
|
filenames = glob.glob("*.dll")
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
if not filenames:
|
|
|
|
print ("Empty SET")
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
for dll in filenames:
|
2015-05-03 14:21:27 +00:00
|
|
|
print_green("Copying dll => {}".format(os.path.join(source_dir,dll)))
|
2015-04-21 11:02:10 +00:00
|
|
|
if os.path.isfile(dll):
|
|
|
|
shutil.copyfile(os.path.join(source_dir,dll),os.path.join(destination_dir,dll))
|
|
|
|
except:
|
|
|
|
print_error("COPYING DLL FILES.")
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
os.chdir(originalDir)
|
2015-04-19 21:51:51 +00:00
|
|
|
|
2015-04-23 03:09:52 +00:00
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
|
2015-04-19 22:28:54 +00:00
|
|
|
def copy_optionals_for_building(mod,pbos):
|
2015-04-21 11:02:10 +00:00
|
|
|
src_directories = os.listdir(optionals_root)
|
|
|
|
current_dir = os.getcwd()
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
print_blue("\nChecking optionals folder...")
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
|
|
|
#special server.pbo processing
|
2015-05-22 17:21:29 +00:00
|
|
|
files = glob.glob(os.path.join(release_dir, project, "optionals", "*.pbo"))
|
2015-04-21 11:02:10 +00:00
|
|
|
for file in files:
|
|
|
|
file_name = os.path.basename(file)
|
2015-05-03 14:21:27 +00:00
|
|
|
#print ("Adding the following file: {}".format(file_name))
|
2015-04-21 11:02:10 +00:00
|
|
|
pbos.append(file_name)
|
2015-05-22 17:21:29 +00:00
|
|
|
pbo_path = os.path.join(release_dir, project, "optionals", file_name)
|
2015-04-23 10:18:06 +00:00
|
|
|
sigFile_name = file_name +"."+ key_name + ".bisign"
|
2015-05-22 17:21:29 +00:00
|
|
|
sig_path = os.path.join(release_dir, project, "optionals", sigFile_name)
|
2015-04-21 11:02:10 +00:00
|
|
|
if (os.path.isfile(pbo_path)):
|
2015-05-03 14:21:27 +00:00
|
|
|
print("Moving {} for processing.".format(pbo_path))
|
2015-05-22 17:21:29 +00:00
|
|
|
shutil.move(pbo_path, os.path.join(release_dir, project, "addons", file_name))
|
2015-04-23 10:43:58 +00:00
|
|
|
|
2015-04-23 10:18:06 +00:00
|
|
|
if (os.path.isfile(sig_path)):
|
2015-05-03 14:21:27 +00:00
|
|
|
#print("Moving {} for processing.".format(sig_path))
|
2015-05-22 17:21:29 +00:00
|
|
|
shutil.move(sig_path, os.path.join(release_dir, project, "addons", sigFile_name))
|
2015-08-25 18:59:55 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
print_error("Error in moving")
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
os.chdir(current_dir)
|
|
|
|
|
|
|
|
try:
|
|
|
|
for dir_name in src_directories:
|
|
|
|
mod.append(dir_name)
|
2015-04-21 15:47:55 +00:00
|
|
|
#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:\
|
2015-04-21 11:02:10 +00:00
|
|
|
if (dir_name == "userconfig"):
|
2015-05-22 17:21:29 +00:00
|
|
|
if (os.path.exists(os.path.join(release_dir, project, "optionals", dir_name))):
|
|
|
|
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, project, "optionals", dir_name))
|
2015-04-21 11:02:10 +00:00
|
|
|
destination = os.path.join(work_drive,dir_name)
|
|
|
|
else:
|
|
|
|
destination = os.path.join(module_root,dir_name)
|
|
|
|
|
2015-05-03 14:21:27 +00:00
|
|
|
print("Temporarily copying {} => {} for building.".format(os.path.join(optionals_root,dir_name),destination))
|
2015-04-21 15:47:55 +00:00
|
|
|
if (os.path.exists(destination)):
|
|
|
|
shutil.rmtree(destination, True)
|
2015-04-21 11:02:10 +00:00
|
|
|
shutil.copytree(os.path.join(optionals_root,dir_name), destination)
|
|
|
|
except:
|
|
|
|
print_error("Copy Optionals Failed")
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
os.chdir(current_dir)
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-23 03:09:52 +00:00
|
|
|
|
|
|
|
def cleanup_optionals(mod):
|
2015-04-21 11:02:10 +00:00
|
|
|
print("")
|
2015-04-21 17:02:56 +00:00
|
|
|
try:
|
2015-04-21 11:02:10 +00:00
|
|
|
for dir_name in mod:
|
2015-04-21 15:47:55 +00:00
|
|
|
#userconfig requires special handling since it is not a PBO source folder.
|
2015-04-21 11:02:10 +00:00
|
|
|
if (dir_name == "userconfig"):
|
|
|
|
destination = os.path.join(work_drive,dir_name)
|
|
|
|
else:
|
|
|
|
destination = os.path.join(module_root,dir_name)
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-05-03 14:21:27 +00:00
|
|
|
print("Cleaning {}".format(destination))
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
2015-05-23 00:48:32 +00:00
|
|
|
file_name = "{}{}.pbo".format(pbo_name_prefix,dir_name)
|
2015-05-22 17:21:29 +00:00
|
|
|
src_file_path = os.path.join(release_dir, project, "addons", file_name)
|
|
|
|
dst_file_path = os.path.join(release_dir, project, "optionals", file_name)
|
2015-04-23 10:43:58 +00:00
|
|
|
|
2015-05-23 00:48:32 +00:00
|
|
|
sigFile_name = "{}.{}.bisign".format(file_name,key_name)
|
2015-05-22 17:21:29 +00:00
|
|
|
src_sig_path = os.path.join(release_dir, project, "addons", sigFile_name)
|
|
|
|
dst_sig_path = os.path.join(release_dir, project, "optionals", sigFile_name)
|
2015-04-23 10:43:58 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
if (os.path.isfile(src_file_path)):
|
2015-05-03 14:21:27 +00:00
|
|
|
#print("Preserving {}".format(file_name))
|
2015-04-21 11:02:10 +00:00
|
|
|
os.renames(src_file_path,dst_file_path)
|
2015-04-23 10:18:06 +00:00
|
|
|
if (os.path.isfile(src_sig_path)):
|
2015-05-03 14:21:27 +00:00
|
|
|
#print("Preserving {}".format(sigFile_name))
|
2015-04-23 10:18:06 +00:00
|
|
|
os.renames(src_sig_path,dst_sig_path)
|
2015-04-21 11:02:10 +00:00
|
|
|
except FileExistsError:
|
2015-05-23 00:48:32 +00:00
|
|
|
print_error("{} already exists".format(file_name))
|
2015-04-21 11:02:10 +00:00
|
|
|
continue
|
|
|
|
shutil.rmtree(destination)
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-08-25 18:59:55 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
print_yellow("{} file not found".format(file_name))
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
print_error("Cleaning Optionals Failed")
|
|
|
|
raise
|
2015-04-23 00:45:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
def purge(dir, pattern, friendlyPattern="files"):
|
2015-05-03 14:21:27 +00:00
|
|
|
print_green("Deleting {} files from directory: {}".format(friendlyPattern,dir))
|
2016-10-25 18:11:05 +00:00
|
|
|
if os.path.exists(dir):
|
|
|
|
for f in os.listdir(dir):
|
|
|
|
if re.search(pattern, f):
|
|
|
|
os.remove(os.path.join(dir, f))
|
2015-04-23 02:14:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def build_signature_file(file_name):
|
|
|
|
global key
|
|
|
|
global dssignfile
|
2015-05-06 21:05:11 +00:00
|
|
|
global signature_blacklist
|
|
|
|
ret = 0
|
|
|
|
baseFile = os.path.basename(file_name)
|
|
|
|
#print_yellow("Sig_fileName: {}".format(baseFile))
|
|
|
|
if not (baseFile in signature_blacklist):
|
|
|
|
print("Signing with {}.".format(key))
|
|
|
|
ret = subprocess.call([dssignfile, key, file_name])
|
2015-04-23 02:14:03 +00:00
|
|
|
if ret == 0:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2015-04-24 21:43:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check_for_obsolete_pbos(addonspath, file):
|
2015-05-22 17:21:29 +00:00
|
|
|
module = file[len(pbo_name_prefix):-4]
|
2015-04-24 21:43:30 +00:00
|
|
|
if not os.path.exists(os.path.join(addonspath, module)):
|
|
|
|
return True
|
|
|
|
return False
|
2015-05-06 18:56:09 +00:00
|
|
|
|
|
|
|
|
2015-05-11 19:53:49 +00:00
|
|
|
def backup_config(module):
|
2015-11-19 06:28:28 +00:00
|
|
|
#backup original $PBOPREFIX$
|
2015-05-11 19:53:49 +00:00
|
|
|
global work_drive
|
|
|
|
global prefix
|
|
|
|
|
|
|
|
try:
|
|
|
|
configpath = os.path.join(work_drive, prefix, module, "$PBOPREFIX$")
|
|
|
|
if os.path.isfile(configpath):
|
|
|
|
shutil.copyfile(configpath, os.path.join(work_drive, prefix, module, "$PBOPREFIX$.backup"))
|
|
|
|
else:
|
|
|
|
print_error("$PBOPREFIX$ Does not exist for module: {}.".format(module))
|
|
|
|
|
|
|
|
except:
|
|
|
|
print_error("Error creating backup of $PBOPREFIX$ for module {}.".format(module))
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
def addon_restore(modulePath):
|
2015-11-19 06:28:28 +00:00
|
|
|
#restore original $PBOPREFIX$
|
2015-05-06 18:56:09 +00:00
|
|
|
try:
|
2015-05-11 01:16:27 +00:00
|
|
|
if os.path.isfile(os.path.join(modulePath, "$PBOPREFIX$.backup")):
|
|
|
|
if os.path.isfile(os.path.join(modulePath, "$PBOPREFIX$")):
|
|
|
|
os.remove(os.path.join(modulePath, "$PBOPREFIX$"))
|
|
|
|
os.rename(os.path.join(modulePath, "$PBOPREFIX$.backup"), os.path.join(modulePath, "$PBOPREFIX$"))
|
2015-05-06 18:56:09 +00:00
|
|
|
except:
|
|
|
|
print_yellow("Some error occurred. Check your addon folder {} for integrity".format(modulePath))
|
|
|
|
|
|
|
|
return True
|
2015-05-11 01:16:27 +00:00
|
|
|
|
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
def get_project_version(version_increments=[]):
|
2015-08-25 18:59:55 +00:00
|
|
|
global project_version
|
|
|
|
versionStamp = project_version
|
2015-05-11 01:16:27 +00:00
|
|
|
#do the magic based on https://github.com/acemod/ACE3/issues/806#issuecomment-95639048
|
2015-05-11 16:48:47 +00:00
|
|
|
|
|
|
|
try:
|
2016-10-25 18:11:05 +00:00
|
|
|
scriptModPath = os.path.join(module_root, "main\script_version.hpp")
|
2015-05-11 16:48:47 +00:00
|
|
|
|
|
|
|
if os.path.isfile(scriptModPath):
|
|
|
|
f = open(scriptModPath, "r")
|
|
|
|
hpptext = f.read()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if hpptext:
|
|
|
|
majorText = re.search(r"#define MAJOR (.*\b)", hpptext).group(1)
|
|
|
|
minorText = re.search(r"#define MINOR (.*\b)", hpptext).group(1)
|
2016-10-25 18:11:05 +00:00
|
|
|
patchText = re.search(r"#define PATCHLVL (.*\b)", hpptext).group(1)
|
2015-05-11 16:48:47 +00:00
|
|
|
buildText = re.search(r"#define BUILD (.*\b)", hpptext).group(1)
|
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
# Increment version (reset all below except build)
|
|
|
|
if version_increments != []:
|
|
|
|
if "major" in version_increments:
|
|
|
|
majorText = int(majorText) + 1
|
|
|
|
minorText = 0
|
|
|
|
patchText = 0
|
|
|
|
elif "minor" in version_increments:
|
|
|
|
minorText = int(minorText) + 1
|
|
|
|
patchText = 0
|
|
|
|
elif "patch" in version_increments:
|
|
|
|
patchText = int(patchText) + 1
|
|
|
|
|
|
|
|
# Always increment build
|
|
|
|
if "build" in version_increments:
|
|
|
|
buildText = int(buildText) + 1
|
|
|
|
|
|
|
|
print_green("Incrementing version to {}.{}.{}.{}".format(majorText,minorText,patchText,buildText))
|
|
|
|
with open(scriptModPath, "w", newline="\n") as file:
|
|
|
|
file.writelines([
|
|
|
|
"#define MAJOR {}\n".format(majorText),
|
|
|
|
"#define MINOR {}\n".format(minorText),
|
|
|
|
"#define PATCHLVL {}\n".format(patchText),
|
|
|
|
"#define BUILD {}\n".format(buildText)
|
|
|
|
])
|
|
|
|
|
2015-05-11 16:48:47 +00:00
|
|
|
if majorText:
|
2016-10-25 18:11:05 +00:00
|
|
|
versionStamp = "{}.{}.{}.{}".format(majorText,minorText,patchText,buildText)
|
2015-05-11 16:48:47 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
print_error("A Critical file seems to be missing or inaccessible: {}".format(scriptModPath))
|
2015-05-11 17:06:40 +00:00
|
|
|
raise FileNotFoundError("File Not Found: {}".format(scriptModPath))
|
2015-05-11 16:48:47 +00:00
|
|
|
|
|
|
|
except Exception as e:
|
2015-08-25 18:59:55 +00:00
|
|
|
print_error("Get_project_version error: {}".format(e))
|
2015-05-11 17:06:40 +00:00
|
|
|
print_error("Check the integrity of the file: {}".format(scriptModPath))
|
2015-08-25 18:59:55 +00:00
|
|
|
versionStamp = project_version
|
2015-05-11 17:06:40 +00:00
|
|
|
print_error("Resetting to the default version stamp: {}".format(versionStamp))
|
|
|
|
input("Press Enter to continue...")
|
|
|
|
print("Resuming build...")
|
|
|
|
|
2015-05-23 00:48:32 +00:00
|
|
|
print_yellow("{} VERSION set to {}".format(project.lstrip("@").upper(),versionStamp))
|
2015-08-25 18:59:55 +00:00
|
|
|
project_version = versionStamp
|
|
|
|
return project_version
|
2015-05-11 01:16:27 +00:00
|
|
|
|
2015-05-11 02:44:24 +00:00
|
|
|
|
2015-06-17 18:42:11 +00:00
|
|
|
def replace_file(filePath, oldSubstring, newSubstring):
|
2016-10-25 18:11:05 +00:00
|
|
|
for line in fileinput.input(filePath, inplace=True):
|
|
|
|
# Use stdout directly, print() adds newlines automatically
|
|
|
|
sys.stdout.write(line.replace(oldSubstring,newSubstring))
|
2015-06-17 18:42:11 +00:00
|
|
|
|
|
|
|
|
2015-06-18 19:19:01 +00:00
|
|
|
def set_version_in_files():
|
2015-08-25 18:59:55 +00:00
|
|
|
newVersion = project_version # MAJOR.MINOR.PATCH.BUILD
|
2016-10-25 18:11:05 +00:00
|
|
|
newVersionArr = newVersion.split(".")
|
|
|
|
newVersionShort = ".".join((newVersionArr[0],newVersionArr[1],newVersionArr[2])) # MAJOR.MINOR.PATCH
|
2015-06-17 18:42:11 +00:00
|
|
|
|
2015-06-18 19:19:01 +00:00
|
|
|
# Regex patterns
|
2016-10-18 20:14:19 +00:00
|
|
|
pattern = re.compile(r"([\d]+\.[\d]+\.[\d]+\.[\d]+)") # MAJOR.MINOR.PATCH.BUILD
|
|
|
|
patternShort = re.compile(r"([\d]+\.[\d]+\.[\d]+)") # MAJOR.MINOR.PATCH
|
2015-06-18 19:19:01 +00:00
|
|
|
|
2015-06-17 18:42:11 +00:00
|
|
|
# Change versions in files containing version
|
|
|
|
for i in versionFiles:
|
2015-06-17 19:21:35 +00:00
|
|
|
filePath = os.path.join(module_root_parent, i)
|
2015-06-17 18:42:11 +00:00
|
|
|
|
2015-06-17 19:21:35 +00:00
|
|
|
try:
|
2015-06-17 18:42:11 +00:00
|
|
|
# Save the file contents to a variable if the file exists
|
|
|
|
if os.path.isfile(filePath):
|
|
|
|
f = open(filePath, "r+")
|
|
|
|
fileText = f.read()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if fileText:
|
2016-10-25 18:11:05 +00:00
|
|
|
# Version string files
|
|
|
|
# Search and save version stamp
|
|
|
|
versionsFound = re.findall(pattern, fileText) + re.findall(patternShort, fileText)
|
|
|
|
# Filter out sub-versions of other versions
|
|
|
|
versionsFound = [j for i, j in enumerate(versionsFound) if all(j not in k for k in versionsFound[i + 1:])]
|
2015-06-18 19:19:01 +00:00
|
|
|
|
2015-06-17 18:42:11 +00:00
|
|
|
# Replace version stamp if any of the new version parts is higher than the one found
|
2016-10-25 18:11:05 +00:00
|
|
|
for versionFound in versionsFound:
|
|
|
|
if versionFound:
|
|
|
|
# Use the same version length as the one found
|
|
|
|
newVersionUsed = "" # In case undefined
|
|
|
|
if versionFound.count(".") == newVersion.count("."):
|
|
|
|
newVersionUsed = newVersion
|
|
|
|
if versionFound.count(".") == newVersionShort.count("."):
|
|
|
|
newVersionUsed = newVersionShort
|
|
|
|
|
|
|
|
# Print change and modify the file if changed
|
|
|
|
if newVersionUsed and versionFound != newVersionUsed:
|
|
|
|
print_green("Changing version {} => {} in {}".format(versionFound, newVersionUsed, filePath))
|
|
|
|
replace_file(filePath, versionFound, newVersionUsed)
|
2015-06-17 18:42:11 +00:00
|
|
|
except WindowsError as e:
|
|
|
|
# Temporary file is still "in use" by Python, pass this exception
|
|
|
|
pass
|
|
|
|
except Exception as e:
|
2015-06-18 19:19:01 +00:00
|
|
|
print_error("set_version_in_files error: {}".format(e))
|
2015-06-21 19:58:19 +00:00
|
|
|
raise
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def stash_version_files_for_building():
|
|
|
|
try:
|
|
|
|
for file in versionFiles:
|
|
|
|
filePath = os.path.join(module_root_parent, file)
|
2016-10-25 18:11:05 +00:00
|
|
|
if os.path.exists(filePath):
|
|
|
|
# Take only file name for stash location if in subfolder (otherwise it gets removed when removing folders from release dir)
|
|
|
|
if "\\" in file:
|
|
|
|
count = file.count("\\")
|
|
|
|
file = file.split("\\", count)[-1]
|
|
|
|
stashPath = os.path.join(release_dir, file)
|
|
|
|
print("Temporarily stashing {} => {}.bak for version update".format(filePath, stashPath))
|
|
|
|
shutil.copy(filePath, "{}.bak".format(stashPath))
|
|
|
|
else:
|
|
|
|
print_error("Failed temporarily stashing {} for version update".format(filePath))
|
|
|
|
missingFiles.append("{}".format(filePath))
|
2015-06-21 19:58:19 +00:00
|
|
|
except:
|
|
|
|
print_error("Stashing version files failed")
|
|
|
|
raise
|
2015-06-17 19:21:35 +00:00
|
|
|
|
2015-06-21 19:58:19 +00:00
|
|
|
# Set version
|
|
|
|
set_version_in_files()
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def restore_version_files():
|
|
|
|
try:
|
2016-10-25 18:11:05 +00:00
|
|
|
print_blue("\nRestoring version files...")
|
|
|
|
|
2015-06-21 19:58:19 +00:00
|
|
|
for file in versionFiles:
|
|
|
|
filePath = os.path.join(module_root_parent, file)
|
2015-08-25 18:28:33 +00:00
|
|
|
# Take only file name for stash path if in subfolder (otherwise it gets removed when removing folders from release dir)
|
|
|
|
if "\\" in file:
|
|
|
|
count = file.count("\\")
|
|
|
|
file = file.split("\\", count)[-1]
|
2015-06-21 19:58:19 +00:00
|
|
|
stashPath = os.path.join(release_dir, file)
|
2016-10-25 18:11:05 +00:00
|
|
|
if os.path.exists(filePath):
|
|
|
|
print("Restoring {}".format(filePath))
|
|
|
|
shutil.move("{}.bak".format(stashPath), filePath)
|
2015-06-21 19:58:19 +00:00
|
|
|
except:
|
|
|
|
print_error("Restoring version files failed")
|
|
|
|
raise
|
2015-06-17 19:21:35 +00:00
|
|
|
return True
|
2015-06-17 18:42:11 +00:00
|
|
|
|
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
def get_private_keyname(commitID,module="main"):
|
|
|
|
global pbo_name_prefix
|
2016-10-25 18:11:05 +00:00
|
|
|
global project_version
|
2015-05-11 01:16:27 +00:00
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
keyName = str("{prefix}{version}-{commit_id}".format(prefix=pbo_name_prefix,version=project_version,commit_id=commitID))
|
2015-05-11 01:16:27 +00:00
|
|
|
return keyName
|
|
|
|
|
|
|
|
|
|
|
|
def get_commit_ID():
|
|
|
|
# Get latest commit ID
|
|
|
|
global make_root
|
|
|
|
curDir = os.getcwd()
|
2016-08-20 09:52:18 +00:00
|
|
|
commit_id = ""
|
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
try:
|
2016-08-20 09:52:18 +00:00
|
|
|
# Verify if Git repository
|
2015-05-11 01:16:27 +00:00
|
|
|
gitpath = os.path.join(os.path.dirname(make_root), ".git")
|
|
|
|
assert os.path.exists(gitpath)
|
|
|
|
|
2016-08-20 09:52:18 +00:00
|
|
|
# Try to get commit ID through Git client
|
|
|
|
os.chdir(make_root)
|
2015-05-11 01:16:27 +00:00
|
|
|
commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"])
|
|
|
|
commit_id = str(commit_id, "utf-8")[:8]
|
2016-08-20 09:52:18 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
# Try to get commit ID from git files (subprocess failed - eg. no Git client)
|
|
|
|
head_path = os.path.join(gitpath, "HEAD")
|
|
|
|
if os.path.exists(head_path):
|
|
|
|
with open(head_path, "r") as head_file:
|
|
|
|
branch_path = head_file.readline().split(": ")
|
|
|
|
|
|
|
|
# Commit ID is written in HEAD file directly when in detached state
|
|
|
|
if len(branch_path) == 1:
|
|
|
|
commit_id = branch_path[0]
|
|
|
|
else:
|
|
|
|
branch_path = branch_path[-1].strip()
|
|
|
|
ref_path = os.path.join(gitpath, branch_path)
|
|
|
|
if os.path.exists(ref_path):
|
|
|
|
with open(ref_path, "r") as ref_file:
|
|
|
|
commit_id = ref_file.readline()
|
|
|
|
|
|
|
|
if commit_id != "":
|
|
|
|
commit_id = commit_id.strip()[:8]
|
|
|
|
else:
|
|
|
|
raise
|
2015-05-11 01:16:27 +00:00
|
|
|
except:
|
2016-08-20 09:52:18 +00:00
|
|
|
# All other exceptions (eg. AssertionException)
|
|
|
|
if commit_id == "":
|
|
|
|
raise
|
2015-05-11 01:16:27 +00:00
|
|
|
finally:
|
|
|
|
pass
|
2016-08-20 09:52:18 +00:00
|
|
|
if commit_id == "":
|
|
|
|
print_error("Failed to determine commit ID - folder is not a Git repository.")
|
|
|
|
commit_id = "NOGIT"
|
2015-05-11 01:16:27 +00:00
|
|
|
os.chdir(curDir)
|
|
|
|
|
|
|
|
print_yellow("COMMIT ID set to {}".format(commit_id))
|
|
|
|
return commit_id
|
|
|
|
|
|
|
|
|
|
|
|
def version_stamp_pboprefix(module,commitID):
|
|
|
|
### Update pboPrefix with the correct version stamp. Use commit_id as the build number.
|
2015-05-11 05:12:57 +00:00
|
|
|
#This function will not handle any $PBOPREFIX$ backup or cleanup.
|
2015-05-11 01:16:27 +00:00
|
|
|
global work_drive
|
|
|
|
global prefix
|
|
|
|
|
2015-05-11 05:12:57 +00:00
|
|
|
configpath = os.path.join(work_drive, prefix, module, "$PBOPREFIX$")
|
|
|
|
|
2015-05-11 02:58:32 +00:00
|
|
|
try:
|
2015-05-11 01:16:27 +00:00
|
|
|
f = open(configpath, "r")
|
|
|
|
configtext = f.read()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if configtext:
|
2016-01-10 02:16:46 +00:00
|
|
|
if re.search(r"version=(.*?)$", configtext, re.DOTALL):
|
2015-05-11 02:44:24 +00:00
|
|
|
if configtext:
|
2016-01-10 02:16:46 +00:00
|
|
|
configtext = re.sub(r"version=(.*?)$", "version={}\n".format(commitID), configtext, flags=re.DOTALL)
|
2015-05-11 02:44:24 +00:00
|
|
|
f = open(configpath, "w")
|
|
|
|
f.write(configtext)
|
|
|
|
f.close()
|
|
|
|
else:
|
|
|
|
os.remove(os.path.join(work_drive, prefix, module, "$PBOPREFIX$"))
|
|
|
|
os.rename(os.path.join(work_drive, prefix, module, "$PBOPREFIX$.backup"), os.path.join(work_drive, prefix, module, "$PBOPREFIX$"))
|
|
|
|
else:
|
|
|
|
if configtext:
|
|
|
|
#append version info
|
|
|
|
f = open(configpath, "a")
|
|
|
|
f.write("\nversion = {}".format(commitID))
|
|
|
|
f.close()
|
2015-05-11 05:12:57 +00:00
|
|
|
else:
|
|
|
|
os.remove(os.path.join(work_drive, prefix, module, "$PBOPREFIX$"))
|
|
|
|
os.rename(os.path.join(work_drive, prefix, module, "$PBOPREFIX$.backup"), os.path.join(work_drive, prefix, module, "$PBOPREFIX$"))
|
2015-05-11 07:34:32 +00:00
|
|
|
except Exception as e:
|
|
|
|
print_error("Failed to include build number: {}".format(e))
|
2015-05-11 01:16:27 +00:00
|
|
|
return False
|
2015-05-11 02:44:24 +00:00
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
return True
|
2015-05-11 16:48:47 +00:00
|
|
|
|
2015-06-17 19:21:35 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
###############################################################################
|
|
|
|
|
2015-04-23 03:09:52 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
def main(argv):
|
2015-04-21 11:02:10 +00:00
|
|
|
"""Build an Arma addon suite in a directory from rules in a make.cfg file."""
|
2015-05-03 14:21:27 +00:00
|
|
|
print_blue("\nmake.py for Arma, modified for Advanced Combat Environment v{}".format(__version__))
|
2015-04-23 02:14:03 +00:00
|
|
|
|
2015-08-25 18:59:55 +00:00
|
|
|
global project_version
|
2015-05-11 19:53:49 +00:00
|
|
|
global arma3tools_path
|
2015-04-22 23:58:29 +00:00
|
|
|
global work_drive
|
|
|
|
global module_root
|
2015-05-11 01:16:27 +00:00
|
|
|
global make_root
|
2015-04-22 23:58:29 +00:00
|
|
|
global release_dir
|
|
|
|
global module_root_parent
|
|
|
|
global optionals_root
|
|
|
|
global key_name
|
2015-04-23 02:14:03 +00:00
|
|
|
global key
|
|
|
|
global dssignfile
|
2015-05-11 01:16:27 +00:00
|
|
|
global prefix
|
|
|
|
global pbo_name_prefix
|
2016-02-16 14:46:10 +00:00
|
|
|
global ciBuild
|
2016-10-25 18:11:05 +00:00
|
|
|
global missingFiles
|
2017-06-14 13:34:35 +00:00
|
|
|
global failedBuilds
|
|
|
|
global printedErrors
|
|
|
|
|
|
|
|
printedErrors = 0
|
2015-04-23 02:14:03 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
if sys.platform != "win32":
|
|
|
|
print_error("Non-Windows platform (Cygwin?). Please re-run from cmd.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
|
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(reg, r"Software\bohemia interactive\arma 3 tools")
|
|
|
|
arma3tools_path = winreg.QueryValueEx(k, "path")[0]
|
|
|
|
winreg.CloseKey(k)
|
|
|
|
except:
|
|
|
|
raise Exception("BadTools","Arma 3 Tools are not installed correctly or the P: drive needs to be created.")
|
|
|
|
|
|
|
|
# Default behaviors
|
|
|
|
test = False # Copy to Arma 3 directory?
|
|
|
|
arg_modules = False # Only build modules on command line?
|
|
|
|
use_pboproject = True # Default to pboProject build tool
|
|
|
|
make_target = "DEFAULT" # Which section in make.cfg to use for the build
|
2015-04-22 23:58:29 +00:00
|
|
|
new_key = True # Make a new key and use it to sign?
|
2015-04-21 11:02:10 +00:00
|
|
|
quiet = False # Suppress output from build tool?
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
if "help" in argv or "-h" in argv or "--help" in argv:
|
|
|
|
print ("""
|
2015-03-20 18:04:54 +00:00
|
|
|
make.py [help] [test] [force] [key <name>] [target <name>] [release <version>]
|
|
|
|
[module name] [module name] [...]
|
|
|
|
|
|
|
|
test -- Copy result to Arma 3.
|
|
|
|
release <version> -- Make archive with <version>.
|
|
|
|
force -- Ignore cache and build all.
|
2015-04-17 19:05:49 +00:00
|
|
|
checkexternal -- Check External Files
|
2015-04-09 11:37:19 +00:00
|
|
|
target <name> -- Use rules in make.cfg under heading [<name>] rather than
|
2015-03-20 18:04:54 +00:00
|
|
|
default [Make]
|
2015-04-09 11:37:19 +00:00
|
|
|
key <name> -- Use key in working directory with <name> to sign. If it does not
|
2015-03-20 18:04:54 +00:00
|
|
|
exist, create key.
|
|
|
|
quiet -- Suppress command line output from build tool.
|
|
|
|
|
|
|
|
If module names are specified, only those modules will be built.
|
|
|
|
|
|
|
|
Examples:
|
2015-04-09 11:37:19 +00:00
|
|
|
make.py force test
|
|
|
|
Build all modules (ignoring cache) and copy the mod folder to the Arma 3
|
2015-03-20 18:04:54 +00:00
|
|
|
directory.
|
|
|
|
make.py mymodule_gun
|
|
|
|
Only build the module named 'mymodule_gun'.
|
|
|
|
make.py force key MyNewKey release 1.0
|
2015-04-09 11:37:19 +00:00
|
|
|
Build all modules (ignoring cache), sign them with NewKey, and pack them
|
2015-03-20 18:04:54 +00:00
|
|
|
into a zip file for release with version 1.0.
|
|
|
|
|
|
|
|
|
|
|
|
If a file called $NOBIN$ is found in the module directory, that module will not be binarized.
|
|
|
|
|
|
|
|
See the make.cfg file for additional build options.
|
|
|
|
""")
|
2015-04-21 11:02:10 +00:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if "force" in argv:
|
|
|
|
argv.remove("force")
|
|
|
|
force_build = True
|
|
|
|
else:
|
|
|
|
force_build = False
|
|
|
|
|
|
|
|
if "test" in argv:
|
|
|
|
test = True
|
|
|
|
argv.remove("test")
|
|
|
|
|
|
|
|
if "release" in argv:
|
2015-06-18 19:19:01 +00:00
|
|
|
make_release_zip = True
|
2015-04-21 11:02:10 +00:00
|
|
|
argv.remove("release")
|
2015-06-18 19:19:01 +00:00
|
|
|
else:
|
|
|
|
make_release_zip = False
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
if "target" in argv:
|
|
|
|
make_target = argv[argv.index("target") + 1]
|
|
|
|
argv.remove("target")
|
|
|
|
argv.remove(make_target)
|
|
|
|
force_build = True
|
|
|
|
|
|
|
|
if "key" in argv:
|
|
|
|
new_key = True
|
|
|
|
key_name = argv[argv.index("key") + 1]
|
|
|
|
argv.remove("key")
|
|
|
|
argv.remove(key_name)
|
|
|
|
|
|
|
|
if "quiet" in argv:
|
|
|
|
quiet = True
|
|
|
|
argv.remove("quiet")
|
|
|
|
|
|
|
|
if "checkexternal" in argv:
|
|
|
|
argv.remove("checkexternal")
|
|
|
|
check_external = True
|
|
|
|
else:
|
|
|
|
check_external = False
|
2015-08-24 06:00:22 +00:00
|
|
|
|
2015-06-21 19:58:19 +00:00
|
|
|
if "version" in argv:
|
|
|
|
argv.remove("version")
|
|
|
|
version_update = True
|
|
|
|
else:
|
|
|
|
version_update = False
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
version_increments = []
|
|
|
|
if "increment_build" in argv:
|
|
|
|
argv.remove("increment_build")
|
|
|
|
version_increments.append("build")
|
|
|
|
if "increment_patch" in argv:
|
|
|
|
argv.remove("increment_patch")
|
|
|
|
version_increments.append("patch")
|
|
|
|
if "increment_minor" in argv:
|
|
|
|
argv.remove("increment_minor")
|
|
|
|
version_increments.append("minor")
|
|
|
|
if "increment_major" in argv:
|
|
|
|
argv.remove("increment_major")
|
|
|
|
version_increments.append("major")
|
|
|
|
|
|
|
|
if "ci" in argv:
|
|
|
|
argv.remove("ci")
|
2016-02-16 14:46:10 +00:00
|
|
|
ciBuild = True
|
|
|
|
|
2015-05-03 14:21:27 +00:00
|
|
|
print_yellow("\nCheck external references is set to {}".format(str(check_external)))
|
2015-04-23 21:35:33 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
# Get the directory the make script is in.
|
|
|
|
make_root = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
make_root_parent = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
|
|
|
|
os.chdir(make_root)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfg = configparser.ConfigParser();
|
|
|
|
try:
|
|
|
|
cfg.read(os.path.join(make_root, "make.cfg"))
|
|
|
|
|
|
|
|
# Project name (with @ symbol)
|
|
|
|
project = cfg.get(make_target, "project", fallback="@"+os.path.basename(os.getcwd()))
|
|
|
|
|
2015-04-23 17:31:17 +00:00
|
|
|
# BI Tools work drive on Windows
|
|
|
|
work_drive = cfg.get(make_target, "work_drive", fallback="P:\\")
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
# Private key path
|
|
|
|
key = cfg.get(make_target, "key", fallback=None)
|
|
|
|
|
2015-04-23 17:12:28 +00:00
|
|
|
# Private key creation directory
|
|
|
|
private_key_path = cfg.get(make_target, "private_key_path", fallback=os.path.join(work_drive, "private_keys"))
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
# Project prefix (folder path)
|
|
|
|
prefix = cfg.get(make_target, "prefix", fallback="")
|
2015-08-24 06:00:22 +00:00
|
|
|
|
2015-06-18 19:19:01 +00:00
|
|
|
# Release archive prefix
|
|
|
|
zipPrefix = cfg.get(make_target, "zipPrefix", fallback=project.lstrip("@").lower())
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
# Should we autodetect modules on a complete build?
|
|
|
|
module_autodetect = cfg.getboolean(make_target, "module_autodetect", fallback=True)
|
|
|
|
|
|
|
|
# Manual list of modules to build for a complete build
|
|
|
|
modules = cfg.get(make_target, "modules", fallback=None)
|
|
|
|
# Parse it out
|
|
|
|
if modules:
|
|
|
|
modules = [x.strip() for x in modules.split(',')]
|
|
|
|
else:
|
|
|
|
modules = []
|
|
|
|
|
|
|
|
# List of directories to ignore when detecting
|
|
|
|
ignore = [x.strip() for x in cfg.get(make_target, "ignore", fallback="release").split(',')]
|
|
|
|
|
|
|
|
# Which build tool should we use?
|
|
|
|
build_tool = cfg.get(make_target, "build_tool", fallback="addonbuilder").lower()
|
|
|
|
|
|
|
|
# Release/build directory, relative to script dir
|
|
|
|
release_dir = cfg.get(make_target, "release_dir", fallback="release")
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-05-04 20:36:23 +00:00
|
|
|
#Directory to copy the final built PBO's for a test run.
|
|
|
|
test_dir = cfg.get(make_target, "test_dir", fallback=os.path.join(os.environ["USERPROFILE"],r"documents\Arma 3"))
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
# Project PBO file prefix (files are renamed to prefix_name.pbo)
|
|
|
|
pbo_name_prefix = cfg.get(make_target, "pbo_name_prefix", fallback=None)
|
|
|
|
|
|
|
|
# Project module Root
|
|
|
|
module_root_parent = os.path.abspath(os.path.join(os.path.join(work_drive, prefix), os.pardir))
|
|
|
|
module_root = cfg.get(make_target, "module_root", fallback=os.path.join(make_root_parent, "addons"))
|
|
|
|
optionals_root = os.path.join(module_root_parent, "optionals")
|
2015-05-09 19:13:03 +00:00
|
|
|
extensions_root = os.path.join(module_root_parent, "extensions")
|
2015-05-11 01:16:27 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
if (os.path.isdir(module_root)):
|
|
|
|
os.chdir(module_root)
|
|
|
|
else:
|
2015-05-03 14:21:27 +00:00
|
|
|
print_error ("Directory {} does not exist.".format(module_root))
|
2016-10-25 18:11:05 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
commit_id = get_commit_ID()
|
|
|
|
get_project_version(version_increments)
|
|
|
|
key_name = versionStamp = get_private_keyname(commit_id)
|
|
|
|
print_green ("module_root: {}".format(module_root))
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
if (os.path.isdir(optionals_root)):
|
2015-05-03 14:21:27 +00:00
|
|
|
print_green ("optionals_root: {}".format(optionals_root))
|
2015-04-21 11:02:10 +00:00
|
|
|
else:
|
2016-10-25 18:11:05 +00:00
|
|
|
print("optionals_root does not exist: {}".format(optionals_root))
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-05-03 14:21:27 +00:00
|
|
|
print_green ("release_dir: {}".format(release_dir))
|
2015-04-21 17:05:11 +00:00
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not parse make.cfg.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# See if we have been given specific modules to build from command line.
|
2015-06-18 19:19:01 +00:00
|
|
|
if len(argv) > 1 and not make_release_zip:
|
2015-04-21 11:02:10 +00:00
|
|
|
arg_modules = True
|
2016-02-16 12:26:47 +00:00
|
|
|
modules = [a for a in argv[1:] if a[0] != "-"]
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
# Find the tools we need.
|
|
|
|
try:
|
|
|
|
tools = find_bi_tools(work_drive)
|
|
|
|
addonbuilder = tools[0]
|
|
|
|
dssignfile = tools[1]
|
|
|
|
dscreatekey = tools[2]
|
|
|
|
cfgconvert = tools[3]
|
|
|
|
|
|
|
|
except:
|
|
|
|
print_error("Arma 3 Tools are not installed correctly or the P: drive has not been created.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if build_tool == "pboproject":
|
|
|
|
try:
|
2017-11-22 22:10:30 +00:00
|
|
|
depbo_tools = find_depbo_tools()
|
|
|
|
|
|
|
|
pboproject = depbo_tools["pboProject"]
|
|
|
|
rapifyTool = depbo_tools["rapify"]
|
|
|
|
makepboTool = depbo_tools["MakePbo"]
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not find dePBO tools. Download the needed tools from: https://dev.withsix.com/projects/mikero-pbodll/files")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Try to open and deserialize build cache file.
|
|
|
|
try:
|
|
|
|
cache = {}
|
|
|
|
with open(os.path.join(make_root, "make.cache"), 'r') as f:
|
|
|
|
cache_raw = f.read()
|
|
|
|
|
|
|
|
cache = json.loads(cache_raw)
|
|
|
|
|
|
|
|
except:
|
|
|
|
print ("No cache found.")
|
|
|
|
cache = {}
|
|
|
|
|
2016-01-10 02:16:46 +00:00
|
|
|
# Check the build version (from main) with cached version - forces a full rebuild when version changes
|
2015-12-13 21:43:12 +00:00
|
|
|
cacheVersion = "None";
|
|
|
|
if 'cacheVersion' in cache:
|
|
|
|
cacheVersion = cache['cacheVersion']
|
|
|
|
|
2016-01-10 02:16:46 +00:00
|
|
|
if (project_version != cacheVersion):
|
2015-12-13 21:43:12 +00:00
|
|
|
cache = {}
|
2016-01-10 02:16:46 +00:00
|
|
|
print("Reseting Cache {0} to New Version {1}".format(cacheVersion, project_version))
|
|
|
|
cache['cacheVersion'] = project_version
|
2015-12-13 21:43:12 +00:00
|
|
|
|
2015-04-23 18:22:00 +00:00
|
|
|
if not os.path.isdir(os.path.join(release_dir, project, "addons")):
|
|
|
|
try:
|
|
|
|
os.makedirs(os.path.join(release_dir, project, "addons"))
|
|
|
|
except:
|
|
|
|
print_error("Cannot create release directory")
|
|
|
|
raise
|
|
|
|
|
|
|
|
if not os.path.isdir(os.path.join(release_dir, project, "keys")):
|
|
|
|
try:
|
|
|
|
os.makedirs(os.path.join(release_dir, project, "keys"))
|
|
|
|
except:
|
|
|
|
print_error("Cannot create release directory")
|
|
|
|
raise
|
|
|
|
|
2016-10-25 18:11:05 +00:00
|
|
|
failedBuilds = []
|
|
|
|
missingFiles = []
|
|
|
|
|
2015-06-17 18:42:11 +00:00
|
|
|
# Update version stamp in all files that contain it
|
2015-06-21 19:58:19 +00:00
|
|
|
# Update version only for release if full update not requested (backup and restore files)
|
|
|
|
print_blue("\nChecking for obsolete version numbers...")
|
|
|
|
if not version_update:
|
|
|
|
stash_version_files_for_building()
|
|
|
|
else:
|
|
|
|
# Set version
|
|
|
|
set_version_in_files();
|
|
|
|
print("Version in files has been changed, make sure you commit and push the updates!")
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
try:
|
2015-06-21 19:58:19 +00:00
|
|
|
# Temporarily copy optionals_root for building. They will be removed later.
|
2016-10-25 18:11:05 +00:00
|
|
|
if (os.path.isdir(optionals_root)):
|
|
|
|
optionals_modules = []
|
|
|
|
optional_files = []
|
|
|
|
copy_optionals_for_building(optionals_modules,optional_files)
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# Get list of subdirs in make root.
|
|
|
|
dirs = next(os.walk(module_root))[1]
|
|
|
|
|
|
|
|
# Autodetect what directories to build.
|
|
|
|
if module_autodetect and not arg_modules:
|
|
|
|
modules = []
|
|
|
|
for path in dirs:
|
|
|
|
# Any dir that has a config.cpp in its root is an addon to build.
|
|
|
|
config_path = os.path.join(path, 'config.cpp')
|
|
|
|
if os.path.isfile(config_path) and not path in ignore:
|
|
|
|
modules.append(path)
|
|
|
|
|
|
|
|
# Make the key specified from command line if necessary.
|
|
|
|
if new_key:
|
|
|
|
if not os.path.isfile(os.path.join(private_key_path, key_name + ".biprivatekey")):
|
|
|
|
print_yellow("\nRequested key does not exist.")
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
2015-05-06 19:13:46 +00:00
|
|
|
os.makedirs(private_key_path)
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
pass
|
2015-05-06 19:13:46 +00:00
|
|
|
curDir = os.getcwd()
|
|
|
|
os.chdir(private_key_path)
|
|
|
|
ret = subprocess.call([dscreatekey, key_name]) # Created in make_root
|
|
|
|
os.chdir(curDir)
|
|
|
|
if ret == 0:
|
|
|
|
print_green("Created: {}".format(os.path.join(private_key_path, key_name + ".biprivatekey")))
|
|
|
|
print("Removing any old signature keys...")
|
|
|
|
purge(os.path.join(module_root, release_dir, project, "addons"), "^.*\.bisign$","*.bisign")
|
|
|
|
purge(os.path.join(module_root, release_dir, project, "optionals"), "^.*\.bisign$","*.bisign")
|
|
|
|
purge(os.path.join(module_root, release_dir, project, "keys"), "^.*\.bikey$","*.bikey")
|
|
|
|
else:
|
|
|
|
print_error("Failed to create key!")
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-11 17:43:05 +00:00
|
|
|
else:
|
|
|
|
print_green("\nNOTE: Using key {}".format(os.path.join(private_key_path, key_name + ".biprivatekey")))
|
|
|
|
|
|
|
|
try:
|
|
|
|
print("Copying public key to release directory.")
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-11 17:43:05 +00:00
|
|
|
try:
|
|
|
|
os.makedirs(os.path.join(module_root, release_dir, project, "keys"))
|
2015-05-06 19:13:46 +00:00
|
|
|
except:
|
2015-05-11 17:43:05 +00:00
|
|
|
pass
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-11 17:43:05 +00:00
|
|
|
# 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]
|
2015-05-23 00:48:32 +00:00
|
|
|
shutil.copyfile(os.path.join(private_key_path, key_name + ".bikey"), os.path.join(module_root, release_dir, project, "keys", "{}.bikey".format(biKeyNameAbrev)))
|
2015-05-11 17:43:05 +00:00
|
|
|
|
|
|
|
except:
|
|
|
|
print_error("Could not copy key to release directory.")
|
|
|
|
raise
|
2015-05-06 19:13:46 +00:00
|
|
|
|
2015-05-23 00:48:32 +00:00
|
|
|
key = os.path.join(private_key_path, "{}.biprivatekey".format(key_name))
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
# Remove any obsolete files.
|
|
|
|
print_blue("\nChecking for obsolete files...")
|
|
|
|
obsolete_check_path = os.path.join(module_root, release_dir, project,"addons")
|
|
|
|
for file in os.listdir(obsolete_check_path):
|
|
|
|
if (file.endswith(".pbo") and os.path.isfile(os.path.join(obsolete_check_path,file))):
|
|
|
|
if check_for_obsolete_pbos(module_root, file):
|
|
|
|
fileName = os.path.splitext(file)[0]
|
2016-10-25 18:11:05 +00:00
|
|
|
print_yellow("Removing obsolete pbo => {}".format(file))
|
2015-05-23 00:48:32 +00:00
|
|
|
purge(obsolete_check_path, "{}\..".format(fileName), "{}.*".format(fileName))
|
2015-05-06 19:13:46 +00:00
|
|
|
|
2015-05-09 19:13:03 +00:00
|
|
|
obsolete_check_path = os.path.join(module_root, release_dir, project)
|
|
|
|
for file in os.listdir(obsolete_check_path):
|
|
|
|
if (file.endswith(".dll") and os.path.isfile(os.path.join(obsolete_check_path,file))):
|
2016-10-25 18:11:05 +00:00
|
|
|
if not os.path.exists(os.path.join(module_root_parent, file)):
|
|
|
|
print_yellow("Removing obsolete dll => {}".format(file))
|
2015-05-09 19:13:03 +00:00
|
|
|
try:
|
|
|
|
os.remove(os.path.join(obsolete_check_path,file))
|
|
|
|
except:
|
|
|
|
print_error("\nFailed to delete {}".format(os.path.join(obsolete_check_path,file)))
|
|
|
|
pass
|
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# For each module, prep files and then build.
|
|
|
|
print_blue("\nBuilding...")
|
|
|
|
for module in modules:
|
|
|
|
print_green("\nMaking {}".format(module + "-"*max(1, (60-len(module)))))
|
|
|
|
missing = False
|
|
|
|
sigMissing = False
|
|
|
|
|
|
|
|
# Cache check
|
|
|
|
if module in cache:
|
|
|
|
old_sha = cache[module]
|
|
|
|
else:
|
|
|
|
old_sha = ""
|
|
|
|
|
|
|
|
# Hash the module
|
|
|
|
new_sha = get_directory_hash(os.path.join(module_root, module))
|
|
|
|
|
|
|
|
# Is the pbo or sig file missing?
|
2015-05-23 00:48:32 +00:00
|
|
|
missing = not os.path.isfile(os.path.join(release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
|
|
|
sigFile = "{}{}.pbo.{}.bisign".format(pbo_name_prefix,module,key_name)
|
2015-05-22 17:21:29 +00:00
|
|
|
sigMissing = not os.path.isfile(os.path.join(release_dir, project, "addons", sigFile))
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
if missing:
|
2015-05-23 00:48:32 +00:00
|
|
|
print_yellow("Missing PBO file {}{}.pbo. Building...".format(pbo_name_prefix,module))
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
# Check if it needs rebuilt
|
|
|
|
# print ("Hash:", new_sha)
|
|
|
|
if old_sha == new_sha and not missing:
|
|
|
|
if not force_build:
|
|
|
|
print("Module has not changed.")
|
|
|
|
if sigMissing:
|
|
|
|
if key:
|
|
|
|
print("Missing Signature key {}".format(sigFile))
|
2015-05-23 00:48:32 +00:00
|
|
|
build_signature_file(os.path.join(module_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module)))
|
2015-05-06 19:13:46 +00:00
|
|
|
# Skip everything else
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Only do this if the project isn't stored directly on the work drive.
|
|
|
|
# Split the path at the drive name and see if they are on the same drive (usually P:)
|
|
|
|
if os.path.splitdrive(module_root)[0] != os.path.splitdrive(work_drive)[0]:
|
|
|
|
try:
|
|
|
|
# Remove old work drive version (ignore errors)
|
|
|
|
shutil.rmtree(os.path.join(work_drive, prefix, module), True)
|
|
|
|
|
|
|
|
# Copy module to the work drive
|
|
|
|
shutil.copytree(module, os.path.join(work_drive, prefix, module))
|
|
|
|
|
|
|
|
except:
|
|
|
|
raise
|
2017-06-14 13:34:35 +00:00
|
|
|
print_error("Could not copy module to work drive. Does the module exist?")
|
2015-05-06 19:13:46 +00:00
|
|
|
input("Press Enter to continue...")
|
|
|
|
print("Resuming build...")
|
|
|
|
continue
|
|
|
|
#else:
|
|
|
|
#print("WARNING: Module is stored on work drive ({}).".format(work_drive))
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
try:
|
|
|
|
# Remove the old pbo, key, and log
|
2015-05-23 00:48:32 +00:00
|
|
|
old = os.path.join(module_root, release_dir, project, "addons", "{}{}".format(pbo_name_prefix,module)) + "*"
|
2015-05-06 19:13:46 +00:00
|
|
|
files = glob.glob(old)
|
|
|
|
for f in files:
|
|
|
|
os.remove(f)
|
|
|
|
|
|
|
|
if pbo_name_prefix:
|
2015-05-23 00:48:32 +00:00
|
|
|
old = os.path.join(module_root, release_dir, project, "addons", "{}{}".format(pbo_name_prefix,module)) + "*"
|
2015-05-06 19:13:46 +00:00
|
|
|
files = glob.glob(old)
|
|
|
|
for f in files:
|
|
|
|
os.remove(f)
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
2017-06-14 13:34:35 +00:00
|
|
|
print_error("Could not copy module to work drive. Does the module exist?")
|
2015-04-21 11:02:10 +00:00
|
|
|
input("Press Enter to continue...")
|
|
|
|
print("Resuming build...")
|
|
|
|
continue
|
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# Build the module into a pbo
|
|
|
|
print_blue("Building: {}".format(os.path.join(work_drive, prefix, module)))
|
|
|
|
print_blue("Destination: {}".format(os.path.join(module_root, release_dir, project, "addons")))
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# Make destination folder (if needed)
|
|
|
|
try:
|
|
|
|
os.makedirs(os.path.join(module_root, release_dir, project, "addons"))
|
|
|
|
except:
|
|
|
|
pass
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# Run build tool
|
|
|
|
build_successful = False
|
|
|
|
if build_tool == "pboproject":
|
|
|
|
try:
|
2015-05-11 19:53:49 +00:00
|
|
|
nobinFilePath = os.path.join(work_drive, prefix, module, "$NOBIN$")
|
2015-06-19 00:43:12 +00:00
|
|
|
backup_config(module)
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
version_stamp_pboprefix(module,commit_id)
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-11 19:53:49 +00:00
|
|
|
if os.path.isfile(nobinFilePath):
|
2015-05-06 19:13:46 +00:00
|
|
|
print_green("$NOBIN$ Found. Proceeding with non-binarizing!")
|
2017-10-24 20:52:04 +00:00
|
|
|
cmd = [makepboTool, "-P","-A","-G","-N","-X=*.backup", os.path.join(work_drive, prefix, module),os.path.join(module_root, release_dir, project,"addons")]
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
else:
|
2015-05-06 19:13:46 +00:00
|
|
|
if check_external:
|
|
|
|
cmd = [pboproject, "-P", os.path.join(work_drive, prefix, module), "+Engine=Arma3", "-S","+Noisy", "+X", "+Clean", "+Mod="+os.path.join(module_root, release_dir, project), "-Key"]
|
|
|
|
else:
|
|
|
|
cmd = [pboproject, "-P", os.path.join(work_drive, prefix, module), "+Engine=Arma3", "-S","+Noisy", "-X", "+Clean", "+Mod="+os.path.join(module_root, release_dir, project), "-Key"]
|
|
|
|
|
|
|
|
color("grey")
|
|
|
|
if quiet:
|
|
|
|
devnull = open(os.devnull, 'w')
|
|
|
|
ret = subprocess.call(cmd, stdout=devnull)
|
|
|
|
devnull.close()
|
|
|
|
else:
|
|
|
|
ret = subprocess.call(cmd)
|
|
|
|
color("reset")
|
|
|
|
|
|
|
|
if ret == 0:
|
|
|
|
print_green("pboProject return code == {}".format(str(ret)))
|
|
|
|
# Prettyprefix rename the PBO if requested.
|
|
|
|
if pbo_name_prefix:
|
|
|
|
try:
|
2015-05-23 00:48:32 +00:00
|
|
|
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)))
|
2015-05-06 19:13:46 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not rename built PBO with prefix.")
|
|
|
|
# Sign result
|
2015-05-23 00:48:32 +00:00
|
|
|
if (key and not "{}{}.pbo".format(pbo_name_prefix,module) in signature_blacklist):
|
2015-05-06 19:13:46 +00:00
|
|
|
print("Signing with {}.".format(key))
|
|
|
|
if pbo_name_prefix:
|
2015-05-23 00:48:32 +00:00
|
|
|
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", "{}{}.pbo".format(pbo_name_prefix,module))])
|
2015-05-06 19:13:46 +00:00
|
|
|
else:
|
2015-05-23 00:48:32 +00:00
|
|
|
ret = subprocess.call([dssignfile, key, os.path.join(module_root, release_dir, project, "addons", "{}.pbo".format(module))])
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
if ret == 0:
|
|
|
|
build_successful = True
|
|
|
|
else:
|
|
|
|
build_successful = True
|
|
|
|
|
|
|
|
if not build_successful:
|
|
|
|
print_error("pboProject return code == {}".format(str(ret)))
|
2015-05-09 18:29:42 +00:00
|
|
|
print_error("Module not successfully built/signed. Check your {}temp\{}_packing.log for more info.".format(work_drive,module))
|
2015-05-06 19:13:46 +00:00
|
|
|
print ("Resuming build...")
|
2016-10-25 18:11:05 +00:00
|
|
|
failedBuilds.append("{}".format(module))
|
2015-05-06 19:13:46 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
# Back to the root
|
|
|
|
os.chdir(module_root)
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
2015-05-06 19:13:46 +00:00
|
|
|
print_error("Could not run Addon Builder.")
|
|
|
|
input("Press Enter to continue...")
|
|
|
|
print ("Resuming build...")
|
2015-04-21 11:02:10 +00:00
|
|
|
continue
|
2015-05-06 19:13:46 +00:00
|
|
|
finally:
|
2015-05-11 01:16:27 +00:00
|
|
|
addon_restore(os.path.join(work_drive, prefix, module))
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
elif build_tool== "addonbuilder":
|
|
|
|
# Detect $NOBIN$ and do not binarize if found.
|
2015-04-21 11:02:10 +00:00
|
|
|
if os.path.isfile(os.path.join(work_drive, prefix, module, "$NOBIN$")):
|
2015-05-06 19:13:46 +00:00
|
|
|
do_binarize = False
|
|
|
|
print("$NOBIN$ file found in module, packing only.")
|
2015-04-21 11:02:10 +00:00
|
|
|
else:
|
2015-05-06 19:13:46 +00:00
|
|
|
do_binarize = True
|
|
|
|
try:
|
|
|
|
# Call AddonBuilder
|
|
|
|
os.chdir("P:\\")
|
|
|
|
|
|
|
|
cmd = [addonbuilder, os.path.join(work_drive, prefix, module), os.path.join(make_root, release_dir, project, "addons"), "-clear", "-project="+work_drive]
|
|
|
|
if not do_binarize:
|
|
|
|
cmd.append("-packonly")
|
|
|
|
|
|
|
|
if quiet:
|
|
|
|
previousDirectory = os.getcwd()
|
|
|
|
os.chdir(arma3tools_path)
|
|
|
|
devnull = open(os.devnull, 'w')
|
|
|
|
ret = subprocess.call(cmd, stdout=devnull)
|
|
|
|
devnull.close()
|
|
|
|
os.chdir(previousDirectory)
|
2015-04-21 11:02:10 +00:00
|
|
|
else:
|
2015-05-06 19:13:46 +00:00
|
|
|
previousDirectory = os.getcwd()
|
|
|
|
os.chdir(arma3tools_path)
|
|
|
|
print_error("Current directory - {}".format(os.getcwd()))
|
|
|
|
ret = subprocess.call(cmd)
|
|
|
|
os.chdir(previousDirectory)
|
|
|
|
print_error("Current directory - {}".format(os.getcwd()))
|
|
|
|
color("reset")
|
|
|
|
print_green("completed")
|
2015-04-21 11:02:10 +00:00
|
|
|
# Prettyprefix rename the PBO if requested.
|
|
|
|
if pbo_name_prefix:
|
|
|
|
try:
|
2015-05-23 00:48:32 +00:00
|
|
|
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)))
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not rename built PBO with prefix.")
|
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
if ret == 0:
|
|
|
|
# Sign result
|
2015-05-06 21:05:11 +00:00
|
|
|
|
|
|
|
#print_yellow("Sig_fileName: ace_{}.pbo".format(module))
|
2015-05-23 00:48:32 +00:00
|
|
|
if (key and not "{}{}.pbo".format(pbo_name_prefix,module) in signature_blacklist) :
|
2015-05-06 19:13:46 +00:00
|
|
|
print("Signing with {}.".format(key))
|
|
|
|
if pbo_name_prefix:
|
2015-05-23 00:48:32 +00:00
|
|
|
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons","{}{}.pbo".format(pbo_name_prefix,module))])
|
2015-05-06 19:13:46 +00:00
|
|
|
else:
|
2015-05-23 00:48:32 +00:00
|
|
|
ret = subprocess.call([dssignfile, key, os.path.join(make_root, release_dir, project, "addons", "{}.pbo".format(module))])
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
if ret == 0:
|
|
|
|
build_successful = True
|
|
|
|
else:
|
2015-04-21 11:02:10 +00:00
|
|
|
build_successful = True
|
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
if not build_successful:
|
2015-05-09 18:29:42 +00:00
|
|
|
print_error("Module not successfully built. Check your {}temp\{}_packing.log for more info.".format(work_drive,module))
|
2015-05-06 19:13:46 +00:00
|
|
|
|
|
|
|
# Back to the root
|
|
|
|
os.chdir(make_root)
|
|
|
|
|
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not run Addon Builder.")
|
|
|
|
input("Press Enter to continue...")
|
2015-04-21 11:02:10 +00:00
|
|
|
print ("Resuming build...")
|
|
|
|
continue
|
|
|
|
|
|
|
|
else:
|
2015-05-06 19:13:46 +00:00
|
|
|
print_error("Unknown build_tool {}!".format(build_tool))
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
# Update the hash for a successfully built module
|
|
|
|
if build_successful:
|
|
|
|
cache[module] = new_sha
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2015-05-12 14:05:48 +00:00
|
|
|
except Exception as e:
|
|
|
|
print_yellow("Cancel or some error detected: {}".format(e))
|
2015-06-19 00:43:12 +00:00
|
|
|
|
2015-05-11 01:16:27 +00:00
|
|
|
|
2015-05-06 19:13:46 +00:00
|
|
|
finally:
|
2015-05-22 17:21:29 +00:00
|
|
|
copy_important_files(module_root_parent,os.path.join(release_dir, project))
|
2016-10-25 18:11:05 +00:00
|
|
|
if (os.path.isdir(optionals_root)):
|
|
|
|
cleanup_optionals(optionals_modules)
|
2015-06-21 19:58:19 +00:00
|
|
|
if not version_update:
|
|
|
|
restore_version_files()
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
# Done building all modules!
|
|
|
|
|
|
|
|
# Write out the cache state
|
|
|
|
cache_out = json.dumps(cache)
|
|
|
|
with open(os.path.join(make_root, "make.cache"), 'w') as f:
|
|
|
|
f.write(cache_out)
|
|
|
|
|
|
|
|
# Delete the pboproject temp files if building a release.
|
2015-06-18 19:19:01 +00:00
|
|
|
if make_release_zip and build_tool == "pboproject":
|
2015-04-21 11:02:10 +00:00
|
|
|
try:
|
2015-06-17 19:21:35 +00:00
|
|
|
shutil.rmtree(os.path.join(release_dir, project, "temp"), True)
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
print_error("ERROR: Could not delete pboProject temp files.")
|
|
|
|
|
|
|
|
# Make release
|
2015-06-18 19:19:01 +00:00
|
|
|
if make_release_zip:
|
2016-11-24 10:07:29 +00:00
|
|
|
release_name = "{}_{}".format(zipPrefix, project_version.rsplit(".", 1)[0])
|
2015-04-21 11:02:10 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
# Delete all log files
|
2015-06-17 19:21:35 +00:00
|
|
|
for root, dirs, files in os.walk(os.path.join(release_dir, project, "addons")):
|
2015-04-21 11:02:10 +00:00
|
|
|
for currentFile in files:
|
|
|
|
if currentFile.lower().endswith("log"):
|
|
|
|
os.remove(os.path.join(root, currentFile))
|
|
|
|
|
2015-06-18 19:19:01 +00:00
|
|
|
# Remove all zip files from release folder to prevent zipping the zip
|
|
|
|
for file in os.listdir(release_dir):
|
|
|
|
if file.endswith(".zip"):
|
|
|
|
os.remove(os.path.join(release_dir, file))
|
|
|
|
|
2015-06-17 20:05:16 +00:00
|
|
|
# Create a zip with the contents of release folder in it
|
2016-10-25 18:11:05 +00:00
|
|
|
print_blue("\nMaking release: {}.zip ...".format(release_name))
|
|
|
|
print("Packing...")
|
2015-06-17 20:05:16 +00:00
|
|
|
release_zip = shutil.make_archive("{}".format(release_name), "zip", release_dir)
|
2016-10-25 18:11:05 +00:00
|
|
|
|
2015-06-17 20:05:16 +00:00
|
|
|
# Move release zip to release folder
|
2015-06-17 19:21:35 +00:00
|
|
|
shutil.copy(release_zip, release_dir)
|
|
|
|
os.remove(release_zip)
|
2015-04-21 11:02:10 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
print_error("Could not make release.")
|
|
|
|
|
|
|
|
# Copy to Arma 3 folder for testing
|
|
|
|
if test:
|
|
|
|
print_blue("\nCopying to Arma 3.")
|
|
|
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
|
|
|
|
try:
|
|
|
|
k = winreg.OpenKey(reg, r"SOFTWARE\Wow6432Node\Bohemia Interactive\Arma 3")
|
|
|
|
a3_path = winreg.EnumValue(k, 1)[1]
|
|
|
|
winreg.CloseKey(k)
|
|
|
|
except:
|
|
|
|
print_error("Could not find Arma 3's directory in the registry.")
|
|
|
|
else:
|
|
|
|
a3_path = cygwin_a3path
|
|
|
|
|
2015-05-04 20:36:23 +00:00
|
|
|
print_yellow("Path from the registry => {}".format(a3_path))
|
|
|
|
a3_path = test_dir
|
|
|
|
|
|
|
|
print_yellow("Copying build files to {}".format(a3_path))
|
|
|
|
|
2015-04-21 11:02:10 +00:00
|
|
|
if os.path.exists(a3_path):
|
|
|
|
try:
|
|
|
|
shutil.rmtree(os.path.join(a3_path, project), True)
|
|
|
|
shutil.copytree(os.path.join(module_root, release_dir, project), os.path.join(a3_path, project))
|
|
|
|
except:
|
|
|
|
print_error("Could not copy files. Is Arma 3 running?")
|
2015-05-03 14:21:27 +00:00
|
|
|
|
2017-06-14 13:34:35 +00:00
|
|
|
tracedErrors = len(failedBuilds) + len(missingFiles)
|
|
|
|
if printedErrors > 0: # printedErrors includes tracedErrors
|
|
|
|
printedOnlyErrors = printedErrors - tracedErrors
|
|
|
|
print()
|
|
|
|
print_error("Failed with {} errors.".format(printedErrors))
|
2016-10-25 18:11:05 +00:00
|
|
|
if len(failedBuilds) > 0:
|
|
|
|
for failedBuild in failedBuilds:
|
2017-06-14 13:34:35 +00:00
|
|
|
print("- {} build failed!".format(failedBuild))
|
2016-10-25 18:11:05 +00:00
|
|
|
if len(missingFiles) > 0:
|
|
|
|
for missingFile in missingFiles:
|
2017-06-14 13:34:35 +00:00
|
|
|
print("- {} not found!".format(missingFile))
|
|
|
|
if printedOnlyErrors > 0:
|
|
|
|
print_yellow("- {} untraced error(s)!".format(printedOnlyErrors))
|
2015-11-28 18:40:59 +00:00
|
|
|
else:
|
2016-10-25 18:11:05 +00:00
|
|
|
print_green("\nCompleted with 0 errors.")
|
2015-04-21 11:02:10 +00:00
|
|
|
|
2017-06-14 13:34:35 +00:00
|
|
|
|
2015-03-20 18:04:54 +00:00
|
|
|
if __name__ == "__main__":
|
2015-08-24 06:00:22 +00:00
|
|
|
start_time = timeit.default_timer()
|
2015-04-21 11:02:10 +00:00
|
|
|
main(sys.argv)
|
2015-08-24 06:00:22 +00:00
|
|
|
d,h,m,s = Fract_Sec(timeit.default_timer() - start_time)
|
|
|
|
print("\nTotal Program time elapsed: {0:2}h {1:2}m {2:4.5f}s".format(h,m,s))
|
2016-02-16 12:14:28 +00:00
|
|
|
|
2016-02-16 14:46:10 +00:00
|
|
|
if ciBuild:
|
2016-02-16 12:14:28 +00:00
|
|
|
sys.exit(0)
|
|
|
|
|
2015-10-30 02:07:33 +00:00
|
|
|
input("Press Enter to continue...")
|