Skip to content

Commit 83d57e4

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 83d57e4

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

dpctl-capi/cmake/modules/GetLevelZeroHeaders.cmake

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,37 @@
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} fetch
33+
RESULT_VARIABLE result
34+
ERROR_VARIABLE error
35+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/level-zero
36+
OUTPUT_STRIP_TRAILING_WHITESPACE
37+
ERROR_STRIP_TRAILING_WHITESPACE
38+
)
3739

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

4462
# 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)