@@ -1229,6 +1229,111 @@ def build_llvm(tool):
1229
1229
return success
1230
1230
1231
1231
1232
+ def build_ninja (tool ):
1233
+ debug_print ('build_ninja(' + str (tool ) + ')' )
1234
+ root = os .path .normpath (tool .installation_path ())
1235
+ src_root = os .path .join (root , 'src' )
1236
+ success = git_clone_checkout_and_pull (tool .download_url (), src_root , tool .git_branch )
1237
+ if not success :
1238
+ return False
1239
+
1240
+ build_dir = llvm_build_dir (tool )
1241
+ build_root = os .path .join (root , build_dir )
1242
+
1243
+ build_type = decide_cmake_build_type (tool )
1244
+
1245
+ # Configure
1246
+ cmake_generator = CMAKE_GENERATOR
1247
+ args = []
1248
+ if 'Visual Studio 16' in CMAKE_GENERATOR : # VS2019
1249
+ # With Visual Studio 16 2019, CMake changed the way they specify target arch.
1250
+ # Instead of appending it into the CMake generator line, it is specified
1251
+ # with a -A arch parameter.
1252
+ args += ['-A' , 'x64' if tool .bitness == 64 else 'x86' ]
1253
+ args += ['-Thost=x64' ]
1254
+ elif 'Visual Studio' in CMAKE_GENERATOR and tool .bitness == 64 :
1255
+ cmake_generator += ' Win64'
1256
+ args += ['-Thost=x64' ]
1257
+
1258
+ cmakelists_dir = os .path .join (src_root )
1259
+ success = cmake_configure (cmake_generator , build_root , cmakelists_dir , build_type , args )
1260
+ if not success :
1261
+ return False
1262
+
1263
+ # Make
1264
+ success = make_build (build_root , build_type , 'x64' if tool .bitness == 64 else 'Win32' )
1265
+
1266
+ if success :
1267
+ bin_dir = os .path .join (root , 'bin' )
1268
+ mkdir_p (bin_dir )
1269
+ exe_paths = [os .path .join (build_root , 'Release' , 'ninja' ), os .path .join (build_root , 'ninja' )]
1270
+ for e in exe_paths :
1271
+ for s in ['.exe' , '' ]:
1272
+ ninja = e + s
1273
+ if os .path .isfile (ninja ):
1274
+ dst = os .path .join (bin_dir , 'ninja' + s )
1275
+ shutil .copyfile (ninja , dst )
1276
+ os .chmod (dst , os .stat (dst ).st_mode | stat .S_IEXEC )
1277
+
1278
+ return success
1279
+
1280
+
1281
+ def build_ccache (tool ):
1282
+ debug_print ('build_ccache(' + str (tool ) + ')' )
1283
+ root = os .path .normpath (tool .installation_path ())
1284
+ src_root = os .path .join (root , 'src' )
1285
+ success = git_clone_checkout_and_pull (tool .download_url (), src_root , tool .git_branch )
1286
+ if not success :
1287
+ return False
1288
+
1289
+ build_dir = llvm_build_dir (tool )
1290
+ build_root = os .path .join (root , build_dir )
1291
+
1292
+ build_type = decide_cmake_build_type (tool )
1293
+
1294
+ # Configure
1295
+ cmake_generator = CMAKE_GENERATOR
1296
+ args = ['-DZSTD_FROM_INTERNET=ON' ]
1297
+ if 'Visual Studio 16' in CMAKE_GENERATOR : # VS2019
1298
+ # With Visual Studio 16 2019, CMake changed the way they specify target arch.
1299
+ # Instead of appending it into the CMake generator line, it is specified
1300
+ # with a -A arch parameter.
1301
+ args += ['-A' , 'x64' if tool .bitness == 64 else 'x86' ]
1302
+ args += ['-Thost=x64' ]
1303
+ elif 'Visual Studio' in CMAKE_GENERATOR and tool .bitness == 64 :
1304
+ cmake_generator += ' Win64'
1305
+ args += ['-Thost=x64' ]
1306
+
1307
+ cmakelists_dir = os .path .join (src_root )
1308
+ success = cmake_configure (cmake_generator , build_root , cmakelists_dir , build_type , args )
1309
+ if not success :
1310
+ return False
1311
+
1312
+ # Make
1313
+ success = make_build (build_root , build_type , 'x64' if tool .bitness == 64 else 'Win32' )
1314
+
1315
+ if success :
1316
+ bin_dir = os .path .join (root , 'bin' )
1317
+ mkdir_p (bin_dir )
1318
+ exe_paths = [os .path .join (build_root , 'Release' , 'ccache' ), os .path .join (build_root , 'ccache' )]
1319
+ for e in exe_paths :
1320
+ for s in ['.exe' , '' ]:
1321
+ ccache = e + s
1322
+ if os .path .isfile (ccache ):
1323
+ dst = os .path .join (bin_dir , 'ccache' + s )
1324
+ shutil .copyfile (ccache , dst )
1325
+ os .chmod (dst , os .stat (dst ).st_mode | stat .S_IEXEC )
1326
+
1327
+ cache_dir = os .path .join (root , 'cache' )
1328
+ open (os .path .join (root , 'emcc_ccache.conf' ), 'w' ).write ('''# Set maximum cache size to 10 GB:
1329
+ max_size = 10G
1330
+ cache_dir = %s
1331
+ ''' % cache_dir )
1332
+ mkdir_p (cache_dir )
1333
+
1334
+ return success
1335
+
1336
+
1232
1337
# Emscripten asm.js optimizer build scripts:
1233
1338
def optimizer_build_root (tool ):
1234
1339
build_root = tool .installation_path ().strip ()
@@ -1898,6 +2003,10 @@ def install_tool(self):
1898
2003
success = build_fastcomp (self )
1899
2004
elif hasattr (self , 'custom_install_script' ) and self .custom_install_script == 'build_llvm' :
1900
2005
success = build_llvm (self )
2006
+ elif hasattr (self , 'custom_install_script' ) and self .custom_install_script == 'build_ninja' :
2007
+ success = build_ninja (self )
2008
+ elif hasattr (self , 'custom_install_script' ) and self .custom_install_script == 'build_ccache' :
2009
+ success = build_ccache (self )
1901
2010
elif hasattr (self , 'git_branch' ):
1902
2011
success = git_clone_checkout_and_pull (url , self .installation_path (), self .git_branch )
1903
2012
elif url .endswith (ARCHIVE_SUFFIXES ):
@@ -1925,7 +2034,7 @@ def install_tool(self):
1925
2034
success = emscripten_post_install (self )
1926
2035
elif self .custom_install_script == 'emscripten_npm_install' :
1927
2036
success = emscripten_npm_install (self , self .installation_path ())
1928
- elif self .custom_install_script in ('build_fastcomp' , 'build_llvm' ):
2037
+ elif self .custom_install_script in ('build_fastcomp' , 'build_llvm' , 'build_ninja' , 'build_ccache' ):
1929
2038
# 'build_fastcomp' is a special one that does the download on its
1930
2039
# own, others do the download manually.
1931
2040
pass
0 commit comments