@@ -35,7 +35,7 @@ def _get_llvm_sha():
35
35
sha = ""
36
36
base_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
37
37
with open (base_dir + "/llvm-sha.txt" , "r" ) as fd :
38
- sha = fd .readline ()
38
+ sha = fd .readline (). strip ()
39
39
if len (sha ) == 0 :
40
40
raise RuntimeError ("sha cannot be empty" )
41
41
return sha
@@ -63,6 +63,8 @@ def _sha_matched(llvm_install_dir, llvm_sha):
63
63
break
64
64
if sha is None :
65
65
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 )
66
68
return sha == llvm_sha
67
69
68
70
@@ -467,6 +469,11 @@ def _build_imex(
467
469
action = "store_true" ,
468
470
help = "Enables building IMEX with dpnp" ,
469
471
)
472
+ imex_builder .add_argument (
473
+ "--imex-clean-build" ,
474
+ action = "store_true" ,
475
+ help = "Removes any existing build directory when building IMEX" ,
476
+ )
470
477
471
478
args = parser .parse_args ()
472
479
@@ -479,7 +486,7 @@ def _build_imex(
479
486
if g_working_dir is None :
480
487
warnings .warn (
481
488
"No working directory specified. Going to use system temp "
482
- + "direcotry to build LLVM"
489
+ + "directory to build LLVM"
483
490
)
484
491
g_working_dir = tempfile .gettempdir ()
485
492
if g_working_dir == os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))):
@@ -511,7 +518,7 @@ def _build_imex(
511
518
g_llvm_install_dir = _build_llvm (
512
519
build_type = args .build_type ,
513
520
llvm_src_dir = g_llvm_source_dir ,
514
- mlir_install_dir = g_working_dir ,
521
+ mlir_install_dir = g_working_dir + "/_mlir_install" ,
515
522
enable_assertions = args .assertion_setting ,
516
523
c_compiler = args .c_compiler ,
517
524
cxx_compiler = args .cxx_compiler ,
@@ -528,7 +535,7 @@ def _build_imex(
528
535
g_llvm_install_dir = _build_llvm (
529
536
build_type = args .build_type ,
530
537
llvm_src_dir = g_llvm_source_dir ,
531
- mlir_install_dir = g_working_dir ,
538
+ mlir_install_dir = g_working_dir + "/_mlir_install" ,
532
539
enable_assertions = args .assertion_setting ,
533
540
c_compiler = args .c_compiler ,
534
541
cxx_compiler = args .cxx_compiler ,
@@ -540,7 +547,7 @@ def _build_imex(
540
547
g_llvm_install_dir = _build_llvm (
541
548
build_type = args .build_type ,
542
549
llvm_src_dir = llvm_src ,
543
- mlir_install_dir = g_working_dir ,
550
+ mlir_install_dir = g_working_dir + "/_mlir_install" ,
544
551
enable_assertions = args .assertion_setting ,
545
552
c_compiler = args .c_compiler ,
546
553
cxx_compiler = args .cxx_compiler ,
@@ -551,6 +558,14 @@ def _build_imex(
551
558
# Now we are ready to build IMEX
552
559
setup_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
553
560
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 )
554
569
os .mkdir (imex_build_dir )
555
570
_build_imex (
556
571
build_dir = imex_build_dir ,
0 commit comments