From 15dab88c7b3a7d5cb9fadfd0602bbb2c0084f79c Mon Sep 17 00:00:00 2001 From: Mason M Date: Mon, 23 Jun 2025 11:35:41 -0300 Subject: [PATCH 1/4] Add workflow to test relocatable cmake package --- .github/workflows/build-cmake-pkg.yml | 47 +++++++++++++++++++++++++++ .github/workflows/build.yml | 37 +++++++++++++++++++-- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-cmake-pkg.yml diff --git a/.github/workflows/build-cmake-pkg.yml b/.github/workflows/build-cmake-pkg.yml new file mode 100644 index 0000000000000..ba6d253187e9e --- /dev/null +++ b/.github/workflows/build-cmake-pkg.yml @@ -0,0 +1,47 @@ +name: Build relocatable cmake package +on: + workflow_dispatch: + workflow_call: + +jobs: + linux: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y build-essential tcl + + - name: Build + run: | + PREFIX="$(pwd)"/inst + cmake -S . -B build -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DLLAMA_CURL=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=OFF \ + -DLLAMA_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release + cmake --install build --prefix "$PREFIX" --config Release + + tclsh "$PREFIX"/lib/cmake/llama-config.cmake <<'EOF' + set build(commit) [string trim [exec git rev-parse --short HEAD]] + set build(number) [string trim [exec git rev-list --count HEAD]] + set build(version) "0.0.$build(number)" + + set llamaconfig [read [open [lindex $argv 0] r]] + set checks [list "set\\(LLAMA_VERSION \\s+$build(version)\\)" \ + "set\\(LLAMA_BUILD_COMMIT\\s+$build(commit)\\)" \ + "set\\(LLAMA_BUILD_NUMBER\\s+$build(number)\\)"] + + foreach check $checks { + if {![regexp -expanded -- $check $llamaconfig]} { + exit 1 + } + } + EOF + + cd examples/simple-cmake-pkg + cmake -S . -B build -DCMAKE_PREFIX_PATH="$PREFIX"/lib/cmake + cmake --build build \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be282897380ac..b9184c201a7ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,10 +5,43 @@ on: push: branches: - master - paths: ['.github/workflows/build.yml', '.github/workflows/build-linux-cross.yml', '**/CMakeLists.txt', '**/.cmake', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp'] + paths: [ + '.github/workflows/build.yml', + '.github/workflows/build-linux-cross.yml', + '.github/workflows/build-cmake-pkg.yml', + '**/CMakeLists.txt', + '**/.cmake', + '**/*.h', + '**/*.hpp', + '**/*.c', + '**/*.cpp', + '**/*.cu', + '**/*.cuh', + '**/*.swift', + '**/*.m', + '**/*.metal', + '**/*.comp' + ] + pull_request: types: [opened, synchronize, reopened] - paths: ['.github/workflows/build.yml', '.github/workflows/build-linux-cross.yml', '**/CMakeLists.txt', '**/.cmake', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp'] + paths: [ + '.github/workflows/build.yml', + '.github/workflows/build-linux-cross.yml', + '.github/workflows/build-cmake-pkg.yml', + '**/CMakeLists.txt', + '**/.cmake', + '**/*.h', + '**/*.hpp', + '**/*.c', + '**/*.cpp', + '**/*.cu', + '**/*.cuh', + '**/*.swift', + '**/*.m', + '**/*.metal', + '**/*.comp' + ] concurrency: group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} From 372b6a61a06208eeaa874b1376593ed3c4d3da95 Mon Sep 17 00:00:00 2001 From: Mason M Date: Mon, 23 Jun 2025 12:11:32 -0300 Subject: [PATCH 2/4] Add newline --- .github/workflows/build-cmake-pkg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-cmake-pkg.yml b/.github/workflows/build-cmake-pkg.yml index ba6d253187e9e..68944fe5d8316 100644 --- a/.github/workflows/build-cmake-pkg.yml +++ b/.github/workflows/build-cmake-pkg.yml @@ -44,4 +44,4 @@ jobs: cd examples/simple-cmake-pkg cmake -S . -B build -DCMAKE_PREFIX_PATH="$PREFIX"/lib/cmake - cmake --build build \ No newline at end of file + cmake --build build From ccd60da20ab5f0235968a31eebf6c08eed3f92f2 Mon Sep 17 00:00:00 2001 From: Mason M Date: Mon, 23 Jun 2025 12:32:42 -0300 Subject: [PATCH 3/4] Call build-cmake-pkg from build.yml --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9184c201a7ba..4feccf21e9e3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -511,6 +511,9 @@ jobs: build-linux-cross: uses: ./.github/workflows/build-linux-cross.yml + build-cmake-pkg: + uses: ./.github/workflows/build-cmake-pkg.yml + macOS-latest-cmake-ios: runs-on: macos-latest From 618e0bf096943655061f64111fa64b5c8d3b9143 Mon Sep 17 00:00:00 2001 From: Mason M Date: Mon, 23 Jun 2025 13:05:29 -0300 Subject: [PATCH 4/4] Share llama-config.cmake path with env. variable --- .github/workflows/build-cmake-pkg.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-cmake-pkg.yml b/.github/workflows/build-cmake-pkg.yml index 68944fe5d8316..fee2ab96bd0e8 100644 --- a/.github/workflows/build-cmake-pkg.yml +++ b/.github/workflows/build-cmake-pkg.yml @@ -25,21 +25,25 @@ jobs: cmake --build build --config Release cmake --install build --prefix "$PREFIX" --config Release - tclsh "$PREFIX"/lib/cmake/llama-config.cmake <<'EOF' + export LLAMA_CONFIG="$PREFIX"/lib/cmake/llama/llama-config.cmake + tclsh <<'EOF' set build(commit) [string trim [exec git rev-parse --short HEAD]] set build(number) [string trim [exec git rev-list --count HEAD]] set build(version) "0.0.$build(number)" - set llamaconfig [read [open [lindex $argv 0] r]] + set llamaconfig [read [open "$env(LLAMA_CONFIG)" r]] set checks [list "set\\(LLAMA_VERSION \\s+$build(version)\\)" \ "set\\(LLAMA_BUILD_COMMIT\\s+$build(commit)\\)" \ "set\\(LLAMA_BUILD_NUMBER\\s+$build(number)\\)"] + puts -nonewline "Checking llama-config.cmake version... " foreach check $checks { if {![regexp -expanded -- $check $llamaconfig]} { + puts "\"$check\" failed!" exit 1 } } + puts "success." EOF cd examples/simple-cmake-pkg