1
+ import subprocess
2
+ import os
3
+ import sys
4
+
5
+ def IsConanInstalled ():
6
+ try :
7
+ subprocess .check_call (['conan' , '--version' ])
8
+ print ("Conan is already installed\n " )
9
+ return True
10
+ except :
11
+ print ("Conan is not installed\n " )
12
+ return False
13
+
14
+ def InstallConan ():
15
+ print ("Installing Conan..." )
16
+ subprocess .check_call (['pip' , 'install' , 'conan' ])
17
+ print ("Conan is now installed.\n " )
18
+
19
+ def DoesBuildFolderExist ():
20
+ return os .path .exists ("build" )
21
+
22
+ def RemoveBuildFolder ():
23
+ os .rmdir ("build" )
24
+
25
+ def CheckConanStep ():
26
+ print ("Checking for Conan..." )
27
+
28
+ if IsConanInstalled () == False :
29
+ InstallConan ()
30
+
31
+ print ("Done checking for Conan.\n " )
32
+
33
+ def InstallPackagesStep ():
34
+ print ("Installing packages..." )
35
+
36
+ packageConfigsInstalled = [False , False , False ]
37
+ removeBuildDir = False
38
+
39
+
40
+ for i in range (len (sys .argv )):
41
+ if sys .argv [i ] == "--debug" :
42
+ packageConfigsInstalled [0 ] = True
43
+ elif sys .argv [i ] == "--release" :
44
+ packageConfigsInstalled [1 ] = True
45
+ elif sys .argv [i ] == "--distribution" :
46
+ packageConfigsInstalled [2 ] = True
47
+ elif sys .argv [i ] == "--remove-build-folder" :
48
+ removeBuildDir = True
49
+
50
+ if DoesBuildFolderExist () == True and removeBuildDir == True :
51
+ print ("Removing build folder..." )
52
+ RemoveBuildFolder ()
53
+ print ("Done removing build folder.\n " )
54
+
55
+
56
+ if packageConfigsInstalled [0 ] == True :
57
+ print ("Installing debug packages..." )
58
+ subprocess .check_call (['conan' , 'install' , '.' , '--output-folder=build' , '--build=missing' , '-s' , 'build_type=Debug' ])
59
+
60
+ print ("Done installing debug packages.\n " )
61
+
62
+
63
+
64
+ if packageConfigsInstalled [1 ] == True :
65
+ print ("Installing release packages..." )
66
+ subprocess .check_call (['conan' , 'install' , '.' , '--output-folder=build' , '--build=missing' , '-s' , 'build_type=Release' ])
67
+
68
+ print ("Done installing release packages.\n " )
69
+
70
+
71
+ if packageConfigsInstalled [2 ] == True :
72
+ print ("Installing distribution packages..." )
73
+ subprocess .check_call (['conan' , 'install' , '.' , '--output-folder=build' , '--build=missing' , '-s' , 'build_type=Distribution' ])
74
+
75
+ print ("Done installing distribution packages.\n " )
76
+
77
+ print ("Done installing packages.\n " )
78
+ return packageConfigsInstalled
79
+
80
+ def GenerateProjectStep ():
81
+ print ("Generating project..." )
82
+ os .chdir ("build" )
83
+ subprocess .check_call (['cmake' , '..' , '-G' , 'Visual Studio 17 2022' , '-DCMAKE_TOOLCHAIN_FILE=build\conan_toolchain.cmake' ])
84
+ print ("Done generating project.\n " )
85
+
86
+ def BuildProject (type ):
87
+ print ("Building project of type " + type + "..." )
88
+ subprocess .check_call (['cmake' , '--build' , '.' , '--config=' + type ])
89
+ print ("Done building project.\n " )
90
+
91
+ print ("Configuring Techstorm..." )
92
+
93
+ os .chdir ("../" )
94
+
95
+ CheckConanStep ()
96
+ conf = InstallPackagesStep ()
97
+ GenerateProjectStep ()
98
+
99
+ print ("Building project..." )
100
+
101
+ installedDebug = conf [0 ]
102
+ installedRelease = conf [1 ]
103
+ installedDistribution = conf [2 ]
104
+
105
+ if installedDebug == True :
106
+ print ("Building debug packages and project..." )
107
+ BuildProject ("Debug" )
108
+ print ("Done building debug packages and project.\n " )
109
+
110
+ if installedRelease == True :
111
+ print ("Building release packages and project..." )
112
+ BuildProject ("Release" )
113
+ print ("Done building release packages and project.\n " )
114
+
115
+ if installedDistribution == True :
116
+ print ("Building distribution packages and project..." )
117
+ BuildProject ("Distribution" )
118
+ print ("Done building distribution packages and project.\n " )
119
+
120
+ print ("Done building project.\n " )
121
+
122
+ os .chdir (".." )
123
+
124
+ print ("Techstorm is now configured and built. Go to the build folder, and click on the Techstorm.sln solution to begin working. Happy coding, you magnificent developer! :)" )
0 commit comments