Skip to content

Commit

Permalink
Add scripts to produce APK files for Alpine Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Nov 5, 2024
1 parent ce56ebc commit ef122bc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
44 changes: 44 additions & 0 deletions cmake/APKBUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Contributor: Couchbase SDK Team <[email protected]>
# Maintainer: Couchbase SDK Team <[email protected]>
pkgname=couchbase-cxx-client
pkgver=@COUCHBASE_CXX_CLIENT_PACKAGE_VERSION@
pkgrel=@COUCHBASE_CXX_CLIENT_PACKAGE_RELEASE@
pkgdesc="Couchbase C++ SDK"
url="https://docs.couchbase.com/cxx-sdk/current/hello-world/overview.html"
arch="all"
license="Apache-2.0"
depends=""
makedepends="
linux-headers
cmake
ninja
"
subpackages="$pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.gz"
options="!check"

build() {
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DBUILD_SHARED_LIBS=OFF \
-DCOUCHBASE_CXX_CLIENT_INSTALL=ON \
-DCOUCHBASE_CXX_CLIENT_STATIC_BORINGSSL=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON
cmake --build build
}

tools() {
pkgdesc="$pkgdesc (tools)"
depends="$pkgname=$pkgver-r$pkgrel"

amove usr/bin
}

package() {
DESTDIR="$pkgdir" cmake --install build
}
26 changes: 26 additions & 0 deletions cmake/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,29 @@ if(COUCHBASE_CXX_CLIENT_RPM_TARGETS)
# add target that depends on the last root
add_custom_target(packaging_rpm DEPENDS ${last_output})
endif()

option(COUCHBASE_CXX_CLIENT_APK_TARGETS "Enable targets for building APKs (for Alpine Linux)" FALSE)
if(COUCHBASE_CXX_CLIENT_APK_TARGETS)
find_program(ABUILD abuild REQUIRED) # apk add alpine-sdk

set(cxxcbc_apkbuild_file "${PROJECT_BINARY_DIR}/packaging/APKBUILD")
configure_file(${PROJECT_SOURCE_DIR}/cmake/APKBUILD.in "${cxxcbc_apkbuild_file}" @ONLY)

set(cxxcbc_apkbuild_checksum "${PROJECT_BINARY_DIR}/packaging/apk_checksum_updated.txt")
add_custom_command(
OUTPUT ${cxxcbc_apkbuild_checksum}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/packaging"
COMMAND ${ABUILD} checksum
COMMAND touch ${cxxcbc_apkbuild_checksum}
DEPENDS ${COUCHBASE_CXX_CLIENT_TARBALL} ${cxxcbc_apkbuild_file})

set(cxxcbc_apkbuild_timestamp "${PROJECT_BINARY_DIR}/packaging/apk_timestamp.txt")
add_custom_command(
OUTPUT ${cxxcbc_apkbuild_timestamp}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/packaging"
COMMAND ${ABUILD} -r
COMMAND touch ${cxxcbc_apkbuild_timestamp}
DEPENDS ${COUCHBASE_CXX_CLIENT_TARBALL} ${cxxcbc_apkbuild_checksum})

add_custom_target(packaging_apk DEPENDS ${cxxcbc_apkbuild_timestamp})
endif()

0 comments on commit ef122bc

Please sign in to comment.