-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.py
76 lines (63 loc) · 2.18 KB
/
build.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import sys
import shutil
PROGRAM_FILES = os.environ["ProgramFiles"]
VISUAL_STUDIO_INSTALLED_VERSION = 2022
VISUAL_STUDIO_INSTALLED_VARIANT = ["Community", "Professional", "Enterprise"]
MS_BUILD_PATH = '{}\\Microsoft Visual Studio\\{}\\{}\\MSBuild\\Current\\Bin\\MSBuild.exe'
for variant in VISUAL_STUDIO_INSTALLED_VARIANT:
if os.path.exists(
MS_BUILD_PATH.format(
PROGRAM_FILES, VISUAL_STUDIO_INSTALLED_VERSION, variant
)
):
MS_BUILD_PATH = MS_BUILD_PATH.format(
PROGRAM_FILES, VISUAL_STUDIO_INSTALLED_VERSION, variant
)
break
PROJECT_SOLUTION_PATH = os.path.join(os.path.curdir, 'ArchWSL.sln')
MS_BUILD_TARGET = "Build"
MS_BUILD_CONFIG = "Debug"
MS_BUILD_PLATFORM = "x64"
if len(sys.argv) > 1:
for i in range(1, len(sys.argv)):
if sys.argv[i].startswith("--target="):
MS_BUILD_TARGET = sys.argv[i].split("=")[1].capitalize()
if MS_BUILD_TARGET == "Clean":
break
elif sys.argv[i].startswith("--config="):
MS_BUILD_CONFIG = sys.argv[i].split("=")[1].capitalize()
elif sys.argv[i].startswith("--platform="):
MS_BUILD_PLATFORM = sys.argv[i].split("=")[1]
BUILD_COMMAND = "\"{}\" {} /t:{} /m /nr:true /p:Configuration={};Platform={}"
BUILD_COMMAND = BUILD_COMMAND.format(
MS_BUILD_PATH,
PROJECT_SOLUTION_PATH,
MS_BUILD_TARGET,
MS_BUILD_CONFIG,
MS_BUILD_PLATFORM
)
exitCode = os.system(BUILD_COMMAND)
if (MS_BUILD_TARGET == "Clean"):
cleanDirs = [
"ArchWSL\\x64",
"ArchWSL\\ARM64",
"ArchWSL-Appx\\x64",
"ArchWSL-Appx\\ARM64",
"ArchWSL-Appx\\BundleArtifacts",
"x64\\Debug",
"x64\\Release",
"AppPackages"
]
cleanFiles = [
"ArchWSL-Appx\\ArchWSL-Appx.vcxproj.user",
"ArchWSL\\ArchWSL.vcxproj.user",
"ArchWSL\\MSG00409.bin",
]
for cleanDir in cleanDirs:
if os.path.exists(cleanDir):
shutil.rmtree(cleanDir)
for cleanFile in cleanFiles:
if os.path.exists(cleanFile):
os.remove(cleanFile)
sys.exit(exitCode)