已合并
[feat]suppport ninja #34206
一只食醉狗创建于 4月23日
[feat]suppport ninja #34206
已合并
一只食醉狗创建于 4月23日
2 个文件变更+15-4
Msetup.py+14-3
@@ -321,6 +321,7 @@ class Clean(distutils.command.clean.clean):
321 if os.path.exists(file_path):321 if os.path.exists(file_path):
322 os.remove(file_path)322 os.remove(file_path)
323 323 
324+USE_NINJA = os.environ["CMAKE_GENERATOR"].lower() == "ninja" if "CMAKE_GENERATOR" in os.environ else shutil.which("ninja")
324 325 
325class CPPLibBuild(build_clib, object):326class CPPLibBuild(build_clib, object):
326 def run(self):327 def run(self):
@@ -373,8 +374,15 @@ class CPPLibBuild(build_clib, object):
373 if os.getenv('_ABI_VERSION') is not None:374 if os.getenv('_ABI_VERSION') is not None:
374 cmake_args.append('-DABI_VERSION=' + os.getenv('_ABI_VERSION'))375 cmake_args.append('-DABI_VERSION=' + os.getenv('_ABI_VERSION'))
375 376 
376- max_jobs = os.getenv("MAX_JOBS", str(multiprocessing.cpu_count()))377+ if USE_NINJA:
377- build_args = ['-j', max_jobs]378+ cmake_args.append("-GNinja")
379+ 
380+ max_jobs = os.getenv("MAX_JOBS")
381+ if max_jobs is not None or not USE_NINJA:
382+ max_jobs = max_jobs or str(multiprocessing.cpu_count())
383+ build_args = ['-j', max_jobs]
384+ else:
385+ build_args = []
378 386 
379 subprocess.check_call([self.cmake, BASE_DIR] + cmake_args, cwd=build_type_dir, env=os.environ)387 subprocess.check_call([self.cmake, BASE_DIR] + cmake_args, cwd=build_type_dir, env=os.environ)
380 for base_dir, dirs, files in os.walk(build_type_dir):388 for base_dir, dirs, files in os.walk(build_type_dir):
@@ -385,7 +393,10 @@ class CPPLibBuild(build_clib, object):
385 file_path = os.path.join(base_dir, file_name)393 file_path = os.path.join(base_dir, file_name)
386 os.chmod(file_path, mode=BUILD_PERMISSION)394 os.chmod(file_path, mode=BUILD_PERMISSION)
387 395 
388- subprocess.check_call(['make'] + build_args, cwd=build_type_dir, env=os.environ)396+ if USE_NINJA:
397+ subprocess.check_call(['ninja'] + build_args, cwd=build_type_dir, env=os.environ)
398+ else:
399+ subprocess.check_call(['make'] + build_args, cwd=build_type_dir, env=os.environ)
389 400 
390 401 
391class Build(build_ext, object):402class Build(build_ext, object):
Mthird_party/Tensorpipe+1-1
@@ -1 +1 @@
1-Subproject commit 483a5907c1d4000094924a8c1b1ae6ed1859dcc11+Subproject commit d8a18ac35924bfc56b36a138868e3c71ff5f203f