Skip to content

Commit

Permalink
Add libclang caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Galarius committed Aug 28, 2023
1 parent 5f840e4 commit 9b1eb1e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ jobs:
run: |
python3 build.py conan-install --with-tests
- name: Cache libclang
id: cache-libclang
uses: actions/cache@v3
env:
cache-name: cache-libclang
with:
path: .build/_deps/libclang-subbuild/libclang-populate-prefix/src/*.7z
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('libclang/libclang-urls.txt') }}

- name: Configure
run: |
python3 build.py configure --with-tests
Expand All @@ -73,6 +82,3 @@ jobs:
run: |
cd .build
ctest --verbose --output-on-failure
# TODO: cache prebuilt libraries like in
# https://github.com/cristianadam/qt5/blob/eb958d8c1a9d22ebc94502fc30d56e77dbebb580/.github/workflows/qmake_build.yml#L83
41 changes: 28 additions & 13 deletions libclang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,42 @@ if(DEFINED LLVM_ROOT_DIR AND NOT LLVM_ROOT_DIR STREQUAL "")
else()

# Download prebuilt static llvm & clang libraries

include(FetchContent)
set(FETCHCONTENT_QUIET OFF)

if(APPLE)
set(LIBCLANG_URL "https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-mac.7z")
set(LIBCLANG_HASH "8a944b4b65d2dca883fe539af5e5eef9a67e2abca91b28258fb08c46e3bb05b6")
elseif(WIN32)
set(LIBCLANG_URL "https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-windows-vs2019_64.7z")
set(LIBCLANG_HASH "3cd73b31be503ec7281f1f8907f95392d1c8bd0a8c2c92c39dc177f8c3d02baf")
else()
set(LIBCLANG_URL "https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-linux-Ubuntu20.04-gcc9.3-x86_64.7z")
set(LIBCLANG_HASH "0cfdf3387b8917e99fbd81358a142daeb3bcb84c107c96f1508f257ee2082bda")
endif()
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/libclang-urls.txt libclang_entries)

message(STATUS "Parsing ${CMAKE_CURRENT_SOURCE_DIR}/libclang-urls.txt...")
foreach(entry ${libclang_entries})
# Parse platform, URL, and hash
list(GET entry 0 platform)
list(GET entry 1 url_value)
list(GET entry 2 hash_value)

if(platform STREQUAL "APPLE" AND APPLE)
set(libclang_url ${url_value})
set(libclang_hash ${hash_value})
break()
elseif(platform STREQUAL "WIN32" AND WIN32)
set(libclang_url ${url_value})
set(libclang_hash ${hash_value})
break()
elseif(platform STREQUAL "LINUX" AND LINUX)
set(libclang_url ${url_value})
set(libclang_hash ${hash_value})
break()
endif()
endforeach()

message(STATUS "LIBCLANG URL: ${libclang_url}")
message(STATUS "LIBCLANG HASH: ${libclang_hash}")

FetchContent_Declare(libclang
SOURCE_DIR prebuild
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
TLS_VERIFY TRUE
URL ${LIBCLANG_URL}
URL_HASH SHA256=${LIBCLANG_HASH}
URL ${libclang_url}
URL_HASH SHA256=${libclang_hash}
)
FetchContent_MakeAvailable(libclang)
set(LLVM_ROOT_DIR ${libclang_SOURCE_DIR})
Expand Down
3 changes: 3 additions & 0 deletions libclang/libclang-urls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APPLE;https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-mac.7z;8a944b4b65d2dca883fe539af5e5eef9a67e2abca91b28258fb08c46e3bb05b6
WIN32;https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-windows-vs2019_64.7z;3cd73b31be503ec7281f1f8907f95392d1c8bd0a8c2c92c39dc177f8c3d02baf
LINUX;https://download.qt.io/development_releases/prebuilt/libclang/qt/libclang-release_15.0.0-based-linux-Ubuntu20.04-gcc9.3-x86_64.7z;0cfdf3387b8917e99fbd81358a142daeb3bcb84c107c96f1508f257ee2082bda

0 comments on commit 9b1eb1e

Please sign in to comment.