-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
53 lines (44 loc) · 1.83 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import subprocess
import os.path as path
import os
import sys
from time import sleep
SRC_FOLDER = path.join(os.getcwd(), 'src')
CSPROJ_PATH = path.join(SRC_FOLDER, 'BinChillingTools/BinChillingTools.csproj')
BC_FOLDER = path.join(os.getcwd(), 'BinChilling')
BUILD_FOLDER = path.join(SRC_FOLDER, 'Build')
EXECUTABLE_PATH = path.join(BC_FOLDER, 'BinChillingTools.exe')
PDB_PATH = path.join(BC_FOLDER, 'BinChillingTools.pdb')
REQ_PATH = path.join(os.getcwd(), 'requirements.txt')
def update_req():
subprocess.run(['pip', 'install', '-r', REQ_PATH])
def main(compile_only: bool):
if compile_only is False: update_req()
if path.exists(EXECUTABLE_PATH):
print("Removing old EXE file: " + EXECUTABLE_PATH)
os.remove(EXECUTABLE_PATH)
if path.exists(PDB_PATH):
print("Removing old PDB file: " + PDB_PATH)
os.remove(PDB_PATH)
if path.exists(BUILD_FOLDER) is False:
print("Making build folder at: " + BUILD_FOLDER)
os.mkdir(BUILD_FOLDER)
subprocess.run(['mkdir', BUILD_FOLDER], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
args = ['dotnet', 'publish', CSPROJ_PATH,
'-c', 'release',
'-r', 'ubuntu.20.04-x64',
'-o', BUILD_FOLDER,
'-p:PublishSingleFile=true',
'-p:PublishTrimmed=true',
'--self-contained', 'true']
print("Compiling using: " + ' '.join(args))
subprocess.run(args)
sleep(1)
exe_output = path.join(BUILD_FOLDER, 'BinChillingTools')
pdb_output = path.join(BUILD_FOLDER, 'BinChillingTools.pdb')
os.rename(exe_output, EXECUTABLE_PATH)
os.rename(pdb_output, PDB_PATH )
if __name__ == '__main__':
print(sys.argv)
compile_only = '-compile' in sys.argv[1] if len(sys.argv) > 1 else False
main(compile_only)