Commit 1316c797 authored by Jan Speichert's avatar Jan Speichert
Browse files

Moved scripts

parent c2ae122d
......@@ -21,4 +21,5 @@
*.suo
*.user
*.tlog
*.bat
build.json
\ No newline at end of file
#define MAJOR 1
#define MINOR 0
#define PATCHLVL 0
#define BUILD 3
#define BUILDDATE 2015-10-01 22:43:11.015000
\ No newline at end of file
#define BUILD 4
#define BUILDDATE 2015-10-02 08:51:42.914000
\ No newline at end of file
3
\ No newline at end of file
4
\ No newline at end of file
"""
Colors text in console mode application (win32).
Uses ctypes and Win32 methods SetConsoleTextAttribute and
GetConsoleScreenBufferInfo.
$Id: color_console.py 534 2009-05-10 04:00:59Z andre $
"""
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)
\ No newline at end of file
#!/usr/bin/python
import os
import sys
import shutil
import subprocess
from subprocess import Popen, PIPE
import ntpath
import json
import zipfile
import datetime
import errno
import stat
import shared
import color_console as cons
with open('build.json') as data_file:
config = json.load(data_file)
def file_get_contents(filename):
with open(filename) as f:
return f.read()
def file_put_contents(filename, data):
with open(filename, 'w') as f:
f.write(data)
buildNumber = file_get_contents(os.path.join("p:\\","sol","clearhud","buildnumber"))
buildNumber = int(buildNumber) + 1
platform = "arma3"
major = 1
minor = 0
subminor = 0
buildmode = "Release"
stringVer = "%s_%s_%s_%s" %(major, minor, subminor, buildNumber)
displayVer = "%s.%s.%s.%s" %(major, minor, subminor, buildNumber)
file_put_contents('version_number', displayVer)
cppHeader = "#define MAJOR %s\n#define MINOR %s\n#define SUBMINOR %s\n#define BUILD %s\n#define BUILDDATE %s" %(major, minor, subminor, buildNumber, datetime.datetime.now().isoformat(' '))
def build_dir(dir, key, version):
directories = [o for o in os.listdir(dir) if os.path.isdir(os.path.join(dir,o))]
for addonDir in directories:
if os.path.isfile(os.path.join(dir,addonDir,"config.cpp")):
#$cmd = sprintf("robocopy /E %s p:\\idi\\temp\\%s %s", $addonPath, $entry, "config.cpp script_*.hpp *.sqf *.paa *.b64 *.txt *.bin *.wss *.lip *.p3d \$PBOPREFIX\$");
cmd = subprocess.Popen(["rapify", "-P", os.path.join(dir,addonDir,"config.cpp")])
cmd.wait()
if os.path.isfile(os.path.join(dir,addonDir,"config.bin")):
if os.path.isfile(os.path.join("p:\\","sol","clearhud","temp",addonDir)):
subprocess.call("rmdir " + os.path.join("p:\\","sol","clearhud","temp",addonDir) + "\\" + " /s /q", shell=True)
cmd = subprocess.Popen(["robocopy",
"/E",
os.path.join(dir,addonDir),
os.path.join("p:\\","sol","clearhud","temp",addonDir),
"script_*.hpp", "*.sqf", "*.paa", "*.b64", "*.txt", "*.bin", "*.wss", "*.lip", "*.p3d", "$PBOPREFIX$"
])
cmd.wait()
os.remove(os.path.join(dir,addonDir,"config.bin"))
subprocess.call("pboProject.exe -P +E=\"arma3\" +Clean +N +X +W=p:\\ -Mod=p:\\sol\\clearhud\\temp\\ p:\\sol\\clearhud\\temp\\%s"%(addonDir))
if os.path.isfile(os.path.join("p:\\","sol","clearhud","temp","addons",addonDir + ".pbo")):
subprocess.call("rmdir " + os.path.join("p:\\","sol","clearhud","temp",addonDir) + "\\" + " /s /q", shell=True)
os.rename(os.path.join("p:\\","sol","clearhud","temp","addons",addonDir + ".pbo"),
os.path.join("p:\\","sol","clearhud","build_pbo","sol_clearhud_" + addonDir + ".pbo"))
if os.path.isfile(os.path.join("p:\\","sol","clearhud","build_pbo","sol_clearhud_" + addonDir + ".pbo")):
pbo_file = os.path.join("p:\\","sol","clearhud","build_pbo","sol_clearhud_" + addonDir + ".pbo")
cmd = subprocess.Popen(["DSSignFile",
key,
pbo_file
], shell=True)
cmd.wait()
else:
raise Exception("Pbo build failed")
else:
raise Exception("Pbo build failed")
else:
raise Exception("Pbo build failed")
def prepare():
file_put_contents(os.path.join("p:\\","sol","clearhud","buildnumber"), str(buildNumber))
# file_put_contents(os.path.join("p:\\","idi","src","ACRE2Shared","version.h"), cppHeader)
pboHeader = "#define MAJOR %s\n#define MINOR %s\n#define PATCHLVL %s\n#define BUILD %s\n#define BUILDDATE %s" %(major, minor, subminor, buildNumber, datetime.datetime.now().isoformat(' '))
file_put_contents(os.path.join("p:\\","sol","clearhud","addons","main","script_version.hpp"), pboHeader)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
shared.print_colored(' BUILD: Clearing Global Addons', cons.FOREGROUND_BLUE)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
# passthru("rmdir /S /Q p:\\idi\\clients\\global\\addons");
try:
#subprocess.call("rmdir " + os.path.join("p:\\","idi","clients","global","addons") + "\\" + " /s /q", shell=True)
subprocess.call("rm *.pbo", cwd="build_pbo")
subprocess.call("rm *.bisign", cwd="build_pbo")
subprocess.call("rm *.bikey", cwd="build_pbo\\key")
except:
pass
try:
os.mkdir('build_pbo/key')
except:
pass
def compile_addons(args):
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
shared.print_colored(' BUILD: Adding Global Addons for Platform: \''+platform+'\'', cons.FOREGROUND_BLUE)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
# passthru(sprintf("xcopy p:\\idi\\clients\\%s p:\\idi\\clients\\global\\ /E", $platform));
#print ["xcopy",os.path.join("p:\\","idi","clients",platform), os.path.join("p:\\","idi","clients","global"), "/E"]
#cmd = subprocess.Popen(["xcopy",os.path.join("p:\\","idi","clients",platform), os.path.join("p:\\","idi","clients","global\\"), "/E"])
#cmd.wait()
# $addonPath = $buildBase . "Game\\\@ACRE2\\";
# print "\nBUILD: Creating new signing keypair\n";
# chdir("p:\\idi\\build_keys\\");
# passthru(sprintf("DSCreateKey acre2_%s", $stringVer));
cmd = subprocess.Popen(["DSCreateKey", "sol_clearhud"], cwd="build_keys")
cmd.wait()
# $privateKey = sprintf("p:\\idi\\build_keys\\acre2_%s.biprivatekey", $stringVer);
privateKey = os.path.join("p:\\","sol","clearhud","build_keys","sol_clearhud.biprivatekey")
# $publicKey = sprintf("p:\\idi\\build_keys\\acre2_%s.bikey", $stringVer);
publicKey = os.path.join("p:\\","sol","clearhud","build_keys","sol_clearhud.bikey")
shutil.copy(publicKey, "p:\\sol\\clearhud\\build_pbo\\key\\sol_clearhud.bikey")
# if(!file_exists($privateKey)) {
# die(sprintf("FAILED TO CREATE PRIVATE KEY: %s", $privateKey));
# }
if os.path.isfile(privateKey) is not True:
raise Exception("FAILED TO CREATE PRIVATE KEY: %s"%(privateKey))
# if(!file_exists($publicKey)) {
# die(sprintf("FAILED TO CREATE PRIVATE KEY: %s", $publicKey));
# }
if os.path.isfile(publicKey) is not True:
raise Exception("FAILED TO CREATE PUBLIC KEY: %s"%(publicKey))
# passthru(sprintf("xcopy %s %s\\Game\\\@ACRE2\\keys\\", $publicKey, $buildBase));
# chdir("p:\\");
# build_dir('p:\idi\clients\acre\Addons', $addonPath, 'acre', $privateKey, $stringVer, $useAddonBuilder);
build_dir(os.path.join("p:\\","sol","clearhud","addons"), privateKey, stringVer)
# build_dir('p:\idi\clients\global\Addons', $addonPath, 'acre', $privateKey, $stringVer, $useAddonBuilder);
#build_dir(os.path.join("p:\\","idi","clients","global","addons"), privateKey, stringVer)
# print "\nBUILD: Packing Zip Archive: acre2_" . $stringVer . "\n";
# passthru(sprintf("winrar a -afzip -r -ep1 -m5 p:\\idi\\builds\\acre2_%s.zip %s*.*", $stringVer, $buildBase));
# chdir("p:\\idi\\");
# passthru("git add --all .");
# passthru(sprintf("git commit -m \"ACRE AUTO COMMIT, BUILD: %s.%s.%s.%s\"", $major, $minor, $subminor, $buildNumber));
shared.print_colored('===========================================', cons.FOREGROUND_GREEN)
shared.print_colored(' BUILD: Complete', cons.FOREGROUND_GREEN)
shared.print_colored('===========================================', cons.FOREGROUND_GREEN)
if __name__ == "__main__":
prepare()
compile_addons("NOARGS")
......@@ -29,7 +29,7 @@ def file_put_contents(filename, data):
with open(filename, 'w') as f:
f.write(data)
buildNumber = file_get_contents(os.path.join("p:\\","sol","tfa_fix","buildnumber"))
buildNumber = file_get_contents(os.path.join("p:\\","sol","clearhud","buildnumber"))
buildNumber = int(buildNumber) + 1
platform = "arma3"
......@@ -51,28 +51,27 @@ def build_dir(dir, key, version):
directories = [o for o in os.listdir(dir) if os.path.isdir(os.path.join(dir,o))]
for addonDir in directories:
if os.path.isfile(os.path.join(dir,addonDir,"config.cpp")):
#$cmd = sprintf("robocopy /E %s p:\\idi\\temp\\%s %s", $addonPath, $entry, "config.cpp script_*.hpp *.sqf *.paa *.b64 *.txt *.bin *.wss *.lip *.p3d \$PBOPREFIX\$");
cmd = subprocess.Popen(["rapify", "-P", os.path.join(dir,addonDir,"config.cpp")])
cmd.wait()
if os.path.isfile(os.path.join(dir,addonDir,"config.bin")):
if os.path.isfile(os.path.join("p:\\","sol","tfa_fix","temp",addonDir)):
subprocess.call("rmdir " + os.path.join("p:\\","sol","tfa_fix","temp",addonDir) + "\\" + " /s /q", shell=True)
if os.path.isfile(os.path.join("p:\\","sol","clearhud","temp",addonDir)):
subprocess.call("rmdir " + os.path.join("p:\\","sol","clearhud","temp",addonDir) + "\\" + " /s /q", shell=True)
cmd = subprocess.Popen(["robocopy",
"/E",
os.path.join(dir,addonDir),
os.path.join("p:\\","sol","tfa_fix","temp",addonDir),
os.path.join("p:\\","sol","clearhud","temp",addonDir),
"script_*.hpp", "*.sqf", "*.paa", "*.b64", "*.txt", "*.bin", "*.wss", "*.lip", "*.p3d", "$PBOPREFIX$"
])
cmd.wait()
os.remove(os.path.join(dir,addonDir,"config.bin"))
subprocess.call("pboProject.exe -P +E=\"arma3\" +Clean +N +X +W=p:\\ -Mod=p:\\sol\\tfa_fix\\temp\\ p:\\sol\\tfa_fix\\temp\\%s"%(addonDir))
if os.path.isfile(os.path.join("p:\\","sol","tfa_fix","temp","addons",addonDir + ".pbo")):
subprocess.call("rmdir " + os.path.join("p:\\","sol","tfa_fix","temp",addonDir) + "\\" + " /s /q", shell=True)
os.rename(os.path.join("p:\\","sol","tfa_fix","temp","addons",addonDir + ".pbo"),
os.path.join("p:\\","sol","tfa_fix","build_pbo","sol_tfa_fix_" + addonDir + ".pbo"))
if os.path.isfile(os.path.join("p:\\","sol","tfa_fix","build_pbo","sol_tfa_fix_" + addonDir + ".pbo")):
pbo_file = os.path.join("p:\\","sol","tfa_fix","build_pbo","sol_tfa_fix_" + addonDir + ".pbo")
subprocess.call("pboProject.exe -P +E=\"arma3\" +Clean +N +X +W=p:\\ -Mod=p:\\sol\\clearhud\\temp\\ p:\\sol\\clearhud\\temp\\%s"%(addonDir))
if os.path.isfile(os.path.join("p:\\","sol","clearhud","temp","addons",addonDir + ".pbo")):
subprocess.call("rmdir " + os.path.join("p:\\","sol","clearhud","temp",addonDir) + "\\" + " /s /q", shell=True)
os.rename(os.path.join("p:\\","sol","clearhud","temp","addons",addonDir + ".pbo"),
os.path.join("p:\\","sol","clearhud","build_pbo","addons","sol_clearhud_" + addonDir + ".pbo"))
if os.path.isfile(os.path.join("p:\\","sol","clearhud","build_pbo","addons","sol_clearhud_" + addonDir + ".pbo")):
pbo_file = os.path.join("p:\\","sol","clearhud","build_pbo","addons","sol_clearhud_" + addonDir + ".pbo")
cmd = subprocess.Popen(["DSSignFile",
key,
pbo_file
......@@ -86,25 +85,22 @@ def build_dir(dir, key, version):
raise Exception("Pbo build failed")
def prepare():
file_put_contents(os.path.join("p:\\","sol","tfa_fix","buildnumber"), str(buildNumber))
# file_put_contents(os.path.join("p:\\","idi","src","ACRE2Shared","version.h"), cppHeader)
file_put_contents(os.path.join("p:\\","sol","clearhud","buildnumber"), str(buildNumber))
pboHeader = "#define MAJOR %s\n#define MINOR %s\n#define PATCHLVL %s\n#define BUILD %s\n#define BUILDDATE %s" %(major, minor, subminor, buildNumber, datetime.datetime.now().isoformat(' '))
file_put_contents(os.path.join("p:\\","sol","tfa_fix","addons","main","script_version.hpp"), pboHeader)
file_put_contents(os.path.join("p:\\","sol","clearhud","addons","main","script_version.hpp"), pboHeader)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
shared.print_colored(' BUILD: Clearing Global Addons', cons.FOREGROUND_BLUE)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
# passthru("rmdir /S /Q p:\\idi\\clients\\global\\addons");
try:
#subprocess.call("rmdir " + os.path.join("p:\\","idi","clients","global","addons") + "\\" + " /s /q", shell=True)
subprocess.call("rm *.pbo", cwd="build_pbo")
subprocess.call("rm *.bisign", cwd="build_pbo")
subprocess.call("rm *.bikey", cwd="build_pbo\\key")
subprocess.call("rm *.pbo", cwd="build_pbo\\addons")
subprocess.call("rm *.bisign", cwd="build_pbo\\addons")
subprocess.call("rm *.bikey", cwd="build_pbo\\keys")
except:
pass
try:
os.mkdir('build_pbo/key')
os.mkdir('build_pbo/keys')
except:
pass
......@@ -112,53 +108,31 @@ def compile_addons(args):
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
shared.print_colored(' BUILD: Adding Global Addons for Platform: \''+platform+'\'', cons.FOREGROUND_BLUE)
shared.print_colored('===========================================', cons.FOREGROUND_BLUE)
# passthru(sprintf("xcopy p:\\idi\\clients\\%s p:\\idi\\clients\\global\\ /E", $platform));
#print ["xcopy",os.path.join("p:\\","idi","clients",platform), os.path.join("p:\\","idi","clients","global"), "/E"]
#cmd = subprocess.Popen(["xcopy",os.path.join("p:\\","idi","clients",platform), os.path.join("p:\\","idi","clients","global\\"), "/E"])
#cmd.wait()
# $addonPath = $buildBase . "Game\\\@ACRE2\\";
# print "\nBUILD: Creating new signing keypair\n";
# chdir("p:\\idi\\build_keys\\");
# passthru(sprintf("DSCreateKey acre2_%s", $stringVer));
cmd = subprocess.Popen(["DSCreateKey", "sol_tfa_fix"], cwd="build_keys")
cmd = subprocess.Popen(["DSCreateKey", "sol_clearhud"], cwd="build_keys")
cmd.wait()
# $privateKey = sprintf("p:\\idi\\build_keys\\acre2_%s.biprivatekey", $stringVer);
privateKey = os.path.join("p:\\","sol","tfa_fix","build_keys","sol_tfa_fix.biprivatekey")
# $publicKey = sprintf("p:\\idi\\build_keys\\acre2_%s.bikey", $stringVer);
publicKey = os.path.join("p:\\","sol","tfa_fix","build_keys","sol_tfa_fix.bikey")
shutil.copy(publicKey, "p:\\sol\\tfa_fix\\build_pbo\\key\\sol_tfa_fix.bikey")
# if(!file_exists($privateKey)) {
# die(sprintf("FAILED TO CREATE PRIVATE KEY: %s", $privateKey));
# }
privateKey = os.path.join("p:\\","sol","clearhud","build_keys","sol_clearhud.biprivatekey")
publicKey = os.path.join("p:\\","sol","clearhud","build_keys","sol_clearhud.bikey")
shutil.copy(publicKey, "p:\\sol\\clearhud\\build_pbo\\keys\\sol_clearhud.bikey")
if os.path.isfile(privateKey) is not True:
raise Exception("FAILED TO CREATE PRIVATE KEY: %s"%(privateKey))
# if(!file_exists($publicKey)) {
# die(sprintf("FAILED TO CREATE PRIVATE KEY: %s", $publicKey));
# }
if os.path.isfile(publicKey) is not True:
raise Exception("FAILED TO CREATE PUBLIC KEY: %s"%(publicKey))
# passthru(sprintf("xcopy %s %s\\Game\\\@ACRE2\\keys\\", $publicKey, $buildBase));
# chdir("p:\\");
# build_dir('p:\idi\clients\acre\Addons', $addonPath, 'acre', $privateKey, $stringVer, $useAddonBuilder);
build_dir(os.path.join("p:\\","sol","tfa_fix","addons"), privateKey, stringVer)
build_dir(os.path.join("p:\\","sol","clearhud","addons"), privateKey, stringVer)
# build_dir('p:\idi\clients\global\Addons', $addonPath, 'acre', $privateKey, $stringVer, $useAddonBuilder);
#build_dir(os.path.join("p:\\","idi","clients","global","addons"), privateKey, stringVer)
cmd = subprocess.Popen(["robocopy",
"/E",
os.path.join("p:\\","sol","clearhud","build_pbo"),
os.path.join("p:\\","sol","clearhud","release","@Clearhud")
])
cmd.wait()
# print "\nBUILD: Packing Zip Archive: acre2_" . $stringVer . "\n";
# passthru(sprintf("winrar a -afzip -r -ep1 -m5 p:\\idi\\builds\\acre2_%s.zip %s*.*", $stringVer, $buildBase));
# chdir("p:\\idi\\");
# passthru("git add --all .");
# passthru(sprintf("git commit -m \"ACRE AUTO COMMIT, BUILD: %s.%s.%s.%s\"", $major, $minor, $subminor, $buildNumber));
shared.print_colored('===========================================', cons.FOREGROUND_GREEN)
shared.print_colored(' BUILD: Complete', cons.FOREGROUND_GREEN)
shared.print_colored(' BUILD: Complete. Version: \''+displayVer+'\'', cons.FOREGROUND_GREEN)
shared.print_colored('===========================================', cons.FOREGROUND_GREEN)
......
#!/usr/bin/python
import os
import sys
import shutil
import subprocess
from subprocess import Popen, PIPE
import ntpath
import json
import zipfile
import argparse
import color_console as cons
import errno
import stat
def zip_tree(dir, zip_file):
zip = zipfile.ZipFile(zip_file, 'w', compression=zipfile.ZIP_DEFLATED)
root_len = len(os.path.abspath(dir))
empty_dirs = []
for root, dirs, files in os.walk(dir):
empty_dirs.extend([dir for dir in dirs if os.listdir(os.path.join(root, dir)) == []])
archive_root = os.path.abspath(root)[root_len:]
for f in files:
fullpath = os.path.join(root, f)
archive_name = os.path.join(archive_root, f)
zip.write(fullpath, archive_name, zipfile.ZIP_DEFLATED)
for dir in empty_dirs:
zif = zipfile.ZipInfo(os.path.join(archive_root, dir) + "/")
zip.writestr(zif, "")
zip.close()
return zip_file
def handleRemoveReadonly(func, path, exc):
excvalue = exc[1]
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777
func(path)
else:
raise
def print_colored(text, color):
default_colors = cons.get_text_attr()
default_bg = default_colors & 0x0070
cons.set_text_attr(color | default_bg |
cons.FOREGROUND_INTENSITY)
print text
cons.set_text_attr(default_colors)
def delete_tree(path):
if os.path.exists(path):
shutil.rmtree(path, ignore_errors=False, onerror=handleRemoveReadonly)
os.mkdir(path)
\ No newline at end of file
1.0.0.3
\ No newline at end of file
1.0.0.4
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment