Skip to content

Commit 3a11295

Browse files
GetLevelZeroHeaders: clone if absent, pull if exists
build_backend: do not delete level-zero git checkout in build_cmake if present. Cmake is able to update existing checkout
1 parent 5b3c5d5 commit 3a11295

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

dpctl-capi/cmake/modules/GetLevelZeroHeaders.cmake

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,36 @@
2626

2727
function(get_level_zero_headers)
2828

29-
# Clone the Level Zero git repo
30-
execute_process(
31-
COMMAND ${GIT_EXECUTABLE} clone https://github.com/oneapi-src/level-zero.git
32-
RESULT_VARIABLE result
33-
ERROR_VARIABLE error
34-
OUTPUT_STRIP_TRAILING_WHITESPACE
35-
ERROR_STRIP_TRAILING_WHITESPACE
36-
)
29+
if(EXISTS level-zero)
30+
# Update the checkout
31+
execute_process(
32+
COMMAND ${GIT_EXECUTABLE} pull
33+
RESULT_VARIABLE result
34+
ERROR_VARIABLE error
35+
OUTPUT_STRIP_TRAILING_WHITESPACE
36+
ERROR_STRIP_TRAILING_WHITESPACE
37+
)
3738

38-
if(NOT result EQUAL 0)
39-
message(FATAL_ERROR
40-
"Could not clone the Level Zero sources."
39+
if(NOT result EQUAL 0)
40+
message(FATAL_ERROR
41+
"Could not update Level Zero sources."
42+
)
43+
endif()
44+
else()
45+
# Clone the Level Zero git repo
46+
execute_process(
47+
COMMAND ${GIT_EXECUTABLE} clone https://github.com/oneapi-src/level-zero.git
48+
RESULT_VARIABLE result
49+
ERROR_VARIABLE error
50+
OUTPUT_STRIP_TRAILING_WHITESPACE
51+
ERROR_STRIP_TRAILING_WHITESPACE
4152
)
53+
54+
if(NOT result EQUAL 0)
55+
message(FATAL_ERROR
56+
"Could not clone Level Zero sources from github.com/oneapi-src/level-zero."
57+
)
58+
endif()
4259
endif()
4360

4461
# Use git describe to get latest tag name

scripts/build_backend.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,20 @@
4545
dpctl_dir = os.getcwd()
4646
build_cmake_dir = os.path.join(dpctl_dir, "build_cmake")
4747
if os.path.exists(build_cmake_dir):
48-
shutil.rmtree(build_cmake_dir)
49-
os.mkdir(build_cmake_dir)
48+
for f in os.listdir(build_cmake_dir):
49+
f_path = os.path.join(build_cmake_dir, f)
50+
if os.path.isdir(f_path):
51+
if (f == "level-zero") and os.path.isdir(
52+
os.path.join(f_path, ".git")
53+
):
54+
# do not delete Git checkout of level zero headers
55+
pass
56+
else:
57+
shutil.rmtree(f_path)
58+
else:
59+
os.remove(f_path)
60+
else:
61+
os.mkdir(build_cmake_dir)
5062
os.chdir(build_cmake_dir)
5163

5264
INSTALL_PREFIX = os.path.join(dpctl_dir, "install")

0 commit comments

Comments
 (0)