Skip to content

Commit d25f5dc

Browse files
author
Diptorup Deb
committed
Minor edits to build_locally.py
1 parent 9156e3e commit d25f5dc

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

scripts/build_locally.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _get_llvm_sha():
3535
sha = ""
3636
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
3737
with open(base_dir + "/llvm-sha.txt", "r") as fd:
38-
sha = fd.readline()
38+
sha = fd.readline().strip()
3939
if len(sha) == 0:
4040
raise RuntimeError("sha cannot be empty")
4141
return sha
@@ -63,6 +63,8 @@ def _sha_matched(llvm_install_dir, llvm_sha):
6363
break
6464
if sha is None:
6565
raise RuntimeError("Should have found the SHA in a valid LLVM install")
66+
if sha != llvm_sha:
67+
warnings.warn("Expected SHA " + llvm_sha + " Actual SHA " + sha)
6668
return sha == llvm_sha
6769

6870

@@ -467,6 +469,11 @@ def _build_imex(
467469
action="store_true",
468470
help="Enables building IMEX with dpnp",
469471
)
472+
imex_builder.add_argument(
473+
"--imex-clean-build",
474+
action="store_true",
475+
help="Removes any existing build directory when building IMEX",
476+
)
470477

471478
args = parser.parse_args()
472479

@@ -479,7 +486,7 @@ def _build_imex(
479486
if g_working_dir is None:
480487
warnings.warn(
481488
"No working directory specified. Going to use system temp "
482-
+ "direcotry to build LLVM"
489+
+ "directory to build LLVM"
483490
)
484491
g_working_dir = tempfile.gettempdir()
485492
if g_working_dir == os.path.dirname(os.path.dirname(os.path.abspath(__file__))):
@@ -511,7 +518,7 @@ def _build_imex(
511518
g_llvm_install_dir = _build_llvm(
512519
build_type=args.build_type,
513520
llvm_src_dir=g_llvm_source_dir,
514-
mlir_install_dir=g_working_dir,
521+
mlir_install_dir=g_working_dir + "/_mlir_install",
515522
enable_assertions=args.assertion_setting,
516523
c_compiler=args.c_compiler,
517524
cxx_compiler=args.cxx_compiler,
@@ -528,7 +535,7 @@ def _build_imex(
528535
g_llvm_install_dir = _build_llvm(
529536
build_type=args.build_type,
530537
llvm_src_dir=g_llvm_source_dir,
531-
mlir_install_dir=g_working_dir,
538+
mlir_install_dir=g_working_dir + "/_mlir_install",
532539
enable_assertions=args.assertion_setting,
533540
c_compiler=args.c_compiler,
534541
cxx_compiler=args.cxx_compiler,
@@ -540,7 +547,7 @@ def _build_imex(
540547
g_llvm_install_dir = _build_llvm(
541548
build_type=args.build_type,
542549
llvm_src_dir=llvm_src,
543-
mlir_install_dir=g_working_dir,
550+
mlir_install_dir=g_working_dir + "/_mlir_install",
544551
enable_assertions=args.assertion_setting,
545552
c_compiler=args.c_compiler,
546553
cxx_compiler=args.cxx_compiler,
@@ -551,6 +558,14 @@ def _build_imex(
551558
# Now we are ready to build IMEX
552559
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
553560
imex_build_dir = os.path.abspath(setup_dir + "/_build")
561+
if os.path.exists(imex_build_dir):
562+
if not args.imex_clean_build:
563+
raise RuntimeError(
564+
"IMEX build directory already exists. Use --imex-clean-build "
565+
+ "to remove build directory"
566+
)
567+
else:
568+
shutil.rmtree(imex_build_dir)
554569
os.mkdir(imex_build_dir)
555570
_build_imex(
556571
build_dir=imex_build_dir,

0 commit comments

Comments
 (0)