Skip to content

Commit

Permalink
Add sparsehash
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Jan 27, 2025
1 parent f089b44 commit 5c8c9de
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ env:

asiosdk_version: '2.3.3_2019-06-14'

sparsehash_version: '2.0.4'

max_releases: '6'

curl_options: '-f -O -L --connect-timeout 15 -m 900 --retry 15 --retry-delay 10 --retry-max-time 300 --retry-all-errors'
Expand Down Expand Up @@ -398,6 +400,44 @@ jobs:
run: cmake --install .


- name: Download sparsehash
shell: bash
working-directory: downloads
run: curl ${{env.curl_options}} https://github.com/sparsehash/sparsehash/archive/refs/tags/sparsehash-${{env.sparsehash_version}}.tar.gz

- name: Extract sparsehash
shell: bash
working-directory: build
run: tar -xf ../downloads/sparsehash-${{env.sparsehash_version}}.tar.gz

- name: Patch sparsehash
shell: bash
working-directory: build/sparsehash-sparsehash-${{env.sparsehash_version}}
run: patch -p1 < ../../patches/sparsehash-msvc.patch

- name: Install sparsehash
shell: bash
working-directory: build/sparsehash-sparsehash-${{env.sparsehash_version}}
run: |
cp -v -r src/{google,sparsehash} ${{env.prefix_path_forwardslash}}/include/
cp -v -r src/windows/google/sparsehash/sparseconfig.h ${{env.prefix_path_forwardslash}}/include/google/sparsehash/
cp -v -r src/windows/sparsehash/internal/sparseconfig.h ${{env.prefix_path_forwardslash}}/include/sparsehash/internal/
- name: Create libsparsehash.pc
shell: bash
run: |
mkdir -p ${{env.prefix_path_unix}}/lib/pkgconfig
echo "prefix=${{env.prefix_path_forwardslash}}" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "exec_prefix=${{env.prefix_path_forwardslash}}" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "includedir=${{env.prefix_path_forwardslash}}/include" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "Name: sparsehash" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "Description: C++ associative containers" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "URL: https://github.com/sparsehash/sparsehash" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "Version: ${{env.sparsehash_version}}" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
echo "Cflags: -I\${includedir}" >>${{env.prefix_path_unix}}/lib/pkgconfig/libsparsehash.pc
- name: Download zlib
shell: bash
working-directory: downloads
Expand Down
13 changes: 13 additions & 0 deletions patches/sparsehash-msvc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/sparsehash/internal/hashtable-common.h b/src/sparsehash/internal/hashtable-common.h
index bac2b88..1224e0a 100644
--- a/src/sparsehash/internal/hashtable-common.h
+++ b/src/sparsehash/internal/hashtable-common.h
@@ -51,7 +51,7 @@ _START_GOOGLE_NAMESPACE_

template <bool> struct SparsehashCompileAssert { };
#define SPARSEHASH_COMPILE_ASSERT(expr, msg) \
- __attribute__((unused)) typedef SparsehashCompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+ typedef SparsehashCompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]

namespace sparsehash_internal {

5 changes: 4 additions & 1 deletion scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function error() { echo "[$(timestamp)] ERROR: $*" >&2; }

function latest_github_release() {

curl ${curl_options} -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/$1/$2/releases/latest" | jq -r '.tag_name' | sed 's/^v//g' | sort -V | head -1
curl ${curl_options} -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/$1/$2/releases/latest" | jq -r '.tag_name' | sed 's/^v//g' | sed 's/^sparsehash-//g' | sort -V | head -1

}

Expand Down Expand Up @@ -305,6 +305,9 @@ function update_package() {
"gettext")
package_version_latest=$(latest_github_release "mlocati" "gettext-iconv-windows")
;;
"sparsehash")
package_version_latest=$(latest_github_release "sparsehash" "sparsehash")
;;
*)
package_version_latest=
error "No update rule for package: ${package}"
Expand Down

0 comments on commit 5c8c9de

Please sign in to comment.