Merge pull request #1359 from jonpas/setupVars

Added maindir, projectdir and cba variables to setup.py
This commit is contained in:
ViperMaul 2015-05-24 13:13:58 -07:00
commit 4a12f53855

View File

@ -4,7 +4,6 @@
# ACE3 Setup Script # # ACE3 Setup Script #
####################### #######################
import os import os
import sys import sys
import shutil import shutil
@ -12,8 +11,14 @@ import platform
import subprocess import subprocess
import winreg import winreg
######## GLOBALS #########
MAINDIR = "z"
PROJECTDIR = "ace"
CBA = "P:\\x\\cba"
##########################
def main(): def main():
FULLDIR = "{}\\{}".format(MAINDIR,PROJECTDIR)
print(""" print("""
###################################### ######################################
# ACE3 Development Environment Setup # # ACE3 Development Environment Setup #
@ -28,10 +33,10 @@ def main():
If you have not done those things yet, please abort this script in the next step and do so first. If you have not done those things yet, please abort this script in the next step and do so first.
This script will create two hard links on your system, both pointing to your ACE3 project folder: This script will create two hard links on your system, both pointing to your ACE3 project folder:
[Arma 3 installation directory]\\z\\ace => ACE3 project folder [Arma 3 installation directory]\\{} => ACE3 project folder
P:\\z\\ace => ACE3 project folder P:\\{} => ACE3 project folder
It will also copy the required CBA includes to P:\\x\\cba, if you do not have the CBA source code already.""") It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(FULLDIR,FULLDIR,CBA))
print("\n") print("\n")
try: try:
@ -60,26 +65,26 @@ def main():
print("\n# Creating links ...") print("\n# Creating links ...")
if os.path.exists("P:\\z\\ace"): if os.path.exists("P:\\{}\\{}".format(MAINDIR,PROJECTDIR)):
print("Link on P: already exists. Please finish the setup manually.") print("Link on P: already exists. Please finish the setup manually.")
return 4 return 4
if os.path.exists(os.path.join(armapath, "z", "ace")): if os.path.exists(os.path.join(armapath, MAINDIR, PROJECTDIR)):
print("Link in Arma directory already exists. Please finish the setup manually.") print("Link in Arma directory already exists. Please finish the setup manually.")
return 5 return 5
try: try:
if not os.path.exists("P:\\z"): if not os.path.exists("P:\\{}".format(MAINDIR)):
os.mkdir("P:\\z") os.mkdir("P:\\{}".format(MAINDIR))
if not os.path.exists(os.path.join(armapath, "z")): if not os.path.exists(os.path.join(armapath, MAINDIR)):
os.mkdir(os.path.join(armapath, "z")) os.mkdir(os.path.join(armapath, MAINDIR))
if platform.win32_ver()[0] == "7": if platform.win32_ver()[0] == "7":
subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\z\\ace", projectpath]) subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\{}\\{}".format(MAINDIR,PROJECTDIR), projectpath])
subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, "z", "ace"), projectpath]) subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, MAINDIR, PROJECTDIR), projectpath])
else: else:
subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\z\\ace", projectpath]) subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\{}\\{}".format(MAINDIR,PROJECTDIR), projectpath])
subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, "z", "ace"), projectpath]) subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, MAINDIR, PROJECTDIR), projectpath])
except: except:
raise raise
print("Something went wrong during the link creation. Please finish the setup manually.") print("Something went wrong during the link creation. Please finish the setup manually.")
@ -90,18 +95,18 @@ def main():
print("\n# Copying required CBA includes ...") print("\n# Copying required CBA includes ...")
if os.path.exists("P:\\x\\cba"): if os.path.exists(CBA):
print("P:\\x\\cba already exists, skipping.") print("{} already exists, skipping.".format(CBA))
return -1 return -1
try: try:
shutil.copytree(os.path.join(projectpath, "tools", "cba"), "P:\\x\\cba") shutil.copytree(os.path.join(projectpath, "tools", "cba"), CBA)
except: except:
raise raise
print("Something went wrong while copying CBA includes. Please copy tools\\cba to P:\\x\\cba manually.") print("Something went wrong while copying CBA includes. Please copy tools\\cba to {} manually.".format(CBA))
return 7 return 7
print("# CBA includes copied successfully to P:\\x\\cba.") print("# CBA includes copied successfully to {}.".format(CBA))
return 0 return 0