Skip to content

Commit

Permalink
enable parallel build (#142)
Browse files Browse the repository at this point in the history
add an option to build in parallel
  • Loading branch information
yufenglee authored Mar 2, 2024
1 parent 87f30d1 commit c9464ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def build(
ort_home: str | bytes | os.PathLike | None = None,
skip_csharp: bool = False,
build_dir: str | bytes | os.PathLike | None = None,
parallel: bool = False,
):
"""Generates the CMake build tree and builds the project.
Expand Down Expand Up @@ -159,6 +160,8 @@ def build(
config = "RelWithDebInfo"
run_subprocess(command, env=env).check_returncode()
make_command = ["cmake", "--build", ".", "--config", config]
if parallel:
make_command.append("--parallel")
run_subprocess(make_command, cwd=build_dir, env=env).check_returncode()

if not skip_csharp:
Expand Down Expand Up @@ -214,6 +217,7 @@ def build(
parser.add_argument("--skip_csharp", action="store_true", help="Skip building the C# API.")
parser.add_argument("--build_dir", default=None, help="Path to output directory.")
parser.add_argument("--use_cuda", action="store_true", help="Whether to use CUDA. Default is to not use cuda.")
parser.add_argument("--parallel", action="store_true", help="Enable parallel build.")
args = parser.parse_args()

update_submodules()
Expand All @@ -225,4 +229,5 @@ def build(
ort_home=args.ort_home,
skip_csharp=args.skip_csharp,
build_dir=args.build_dir,
parallel=args.parallel,
)

0 comments on commit c9464ff

Please sign in to comment.