From 109098ae2f737407b5e90e7ec96d531bfbe92697 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 28 Aug 2024 12:34:29 +0300 Subject: [PATCH] Use vcpkg for android dependency tracking IB-8161 Signed-off-by: Raul Metsma --- .github/workflows/build.yml | 41 ++- CMakeLists.txt | 9 +- CMakePresets.json | 49 ++-- README.md | 6 +- .../ee/ria/libdigidocpp/MainActivity.java | 7 +- examples/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- prepare_osx_build_environment.sh | 253 ++---------------- vcpkg-triplets/arm-neon-android.cmake | 7 + vcpkg-triplets/arm64-android.cmake | 7 + vcpkg-triplets/x64-android.cmake | 7 + vcpkg.json | 1 + 12 files changed, 130 insertions(+), 261 deletions(-) create mode 100644 vcpkg-triplets/arm-neon-android.cmake create mode 100644 vcpkg-triplets/arm64-android.cmake create mode 100644 vcpkg-triplets/x64-android.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 109b3ed2e..f518e72b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: macos-latest strategy: matrix: - target: [macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64] + target: [macos, iphoneos, iphonesimulator] steps: - name: Checkout uses: actions/checkout@v4 @@ -32,9 +32,6 @@ jobs: - name: Build openssl if: steps.cache.outputs.cache-hit != 'true' run: ./prepare_osx_build_environment.sh openssl ${{ matrix.target }} - - name: Build libxml2 - if: steps.cache.outputs.cache-hit != 'true' - run: ./prepare_osx_build_environment.sh libxml2 ${{ matrix.target }} - name: Build xmlsec if: steps.cache.outputs.cache-hit != 'true' run: ./prepare_osx_build_environment.sh xmlsec ${{ matrix.target }} @@ -71,6 +68,42 @@ jobs: with: name: ${{ matrix.target }} path: libdigidocpp*.zip + android: + name: Build on Ubuntu for ${{ matrix.target }} + runs-on: ubuntu-24.04 + strategy: + matrix: + include: + - target: androidarm + triplet: arm-neon-android + - target: androidarm64 + triplet: arm64-android + - target: androidx86_64 + triplet: x64-android + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Prepare vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: 0f8b6ddf49fa8ae66a7826234e9ba3fda5f46d3c + vcpkgJsonGlob: ./vcpkg.json + runVcpkgInstall: true + env: + VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} + - name: Build + run: | + cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=libdigidocpp.${{ matrix.target }} + cmake --build --preset ${{ matrix.target }} + cmake --build --preset ${{ matrix.target }} --target install/strip + zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }} + - name: Archive artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: libdigidocpp*.zip fedora: name: Build on Fedora ${{ matrix.container }} runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b9f06e04..d2def81c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,13 @@ find_package(MiniZip 1 QUIET) add_library(xmlsec INTERFACE) if(UNIX) find_package(PkgConfig) - pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET) - target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL) + find_package(unofficial-xmlsec QUIET) + if(TARGET unofficial::xmlsec::xmlsec1-openssl) + target_link_libraries(xmlsec INTERFACE unofficial::xmlsec::xmlsec1-openssl) + else() + pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET) + target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL) + endif() if(NOT APPLE) pkg_check_modules(MINIZIP minizip IMPORTED_TARGET) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 9d5e4479e..69504a8fe 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,34 +6,34 @@ "displayName": "Default config", "description": "Default build using Ninja generator", "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}" + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, { "name": "base", - "displayName": "macOS base build config", + "displayName": "Base build config", "hidden": true, "inherits": "default", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, "environment": { "DEST": "/Library/libdigidocpp$env{DEST_SUFFIX}" }, - "installDir": "$env{DEST}", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_FIND_ROOT_PATH": "$env{DEST};/usr/local;/opt/homebrew" - } + "installDir": "$env{DEST}" }, { "name": "macos", - "inherits": "base", "description": "This macos build is only available on macOS", + "inherits": "base", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, "cacheVariables": { "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", - "CMAKE_OSX_DEPLOYMENT_TARGET": "12.0" + "CMAKE_OSX_DEPLOYMENT_TARGET": "12.0", + "CMAKE_FIND_ROOT_PATH": "$env{DEST}" } }, { @@ -52,12 +52,11 @@ { "name": "ios", "hidden": true, - "inherits": "mobile", + "inherits": ["mobile", "macos"], "cacheVariables": { "CMAKE_SYSTEM_NAME": "iOS", "CMAKE_OSX_SYSROOT": "${presetName}", "CMAKE_OSX_DEPLOYMENT_TARGET": "15.0", - "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", "CMAKE_DISABLE_FIND_PACKAGE_SWIG": "YES", "FRAMEWORK_DESTINATION": "$env{DEST}/lib" } @@ -91,31 +90,35 @@ "CMAKE_SYSTEM_NAME": "Android", "CMAKE_SYSTEM_VERSION": "30", "CMAKE_DISABLE_FIND_PACKAGE_Python3": "YES", - "BUILD_SHARED_LIBS": "NO" + "BUILD_SHARED_LIBS": "NO", + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" } }, { "name": "androidarm", "inherits": "android", - "description": "androidarm build is only available on macOS", + "description": "androidarm build", "cacheVariables": { - "CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a" + "CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a", + "VCPKG_TARGET_TRIPLET": "arm-neon-android" } }, { "name": "androidarm64", "inherits": "android", - "description": "androidarm64 build is only available on macOS", + "description": "androidarm64 build", "cacheVariables": { - "CMAKE_ANDROID_ARCH_ABI": "arm64-v8a" + "CMAKE_ANDROID_ARCH_ABI": "arm64-v8a", + "VCPKG_TARGET_TRIPLET": "arm64-android" } }, { "name": "androidx86_64", "inherits": "android", - "description": "androidx86_64 build is only available on macOS", + "description": "androidx86_64 build", "cacheVariables": { - "CMAKE_ANDROID_ARCH_ABI": "x86_64" + "CMAKE_ANDROID_ARCH_ABI": "x86_64", + "VCPKG_TARGET_TRIPLET": "x64-android" } } ], diff --git a/README.md b/README.md index 74c0c80a3..2b96a4d0f 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,18 @@ ### macOS 1. Install dependencies from - * [XCode](https://itunes.apple.com/en/app/xcode/id497799835?mt=12) + * [XCode](https://itunes.apple.com/en/app/xcode/id497799835?mt=12) - For macOS/iOS development * [CMake](http://www.cmake.org) * [Homebrew](https://brew.sh) + * [vcpkg](https://vcpkg.io/) - For Android development (VCPKG_ROOT) + * [Android NDK](https://developer.android.com/ndk/downloads) - For Android development (ANDROID_NDK_ROOT) 2. Fetch the source git clone --recursive https://github.com/open-eid/libdigidocpp cd libdigidocpp -3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64) +3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator) sh prepare_osx_build_environment.sh macos all diff --git a/examples/android/app/src/main/java/ee/ria/libdigidocpp/MainActivity.java b/examples/android/app/src/main/java/ee/ria/libdigidocpp/MainActivity.java index c2f37d913..ef55fb33e 100644 --- a/examples/android/app/src/main/java/ee/ria/libdigidocpp/MainActivity.java +++ b/examples/android/app/src/main/java/ee/ria/libdigidocpp/MainActivity.java @@ -28,6 +28,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.security.cert.X509Certificate; import java.sql.Timestamp; import java.util.Objects; @@ -59,14 +60,14 @@ protected void onCreate(Bundle savedInstanceState) { try (ZipInputStream zis = new ZipInputStream(getResources().openRawResource(R.raw.schema))) { ZipEntry ze; while ((ze = zis.getNextEntry()) != null) { - Files.copy(zis, Paths.get(cache, ze.getName())); + Files.copy(zis, Paths.get(cache, ze.getName()), StandardCopyOption.REPLACE_EXISTING); } } try (InputStream in = getResources().openRawResource(R.raw.test)) { - Files.copy(in, Paths.get(cache, "test.bdoc")); + Files.copy(in, Paths.get(cache, "test.bdoc"), StandardCopyOption.REPLACE_EXISTING); } try (ByteArrayInputStream bin = new ByteArrayInputStream(new byte[] {})) { - Files.copy(bin, Paths.get(cache, "EE_T.xml")); + Files.copy(bin, Paths.get(cache, "EE_T.xml"), StandardCopyOption.REPLACE_EXISTING); } } catch (IOException e) { e.printStackTrace(); diff --git a/examples/android/build.gradle b/examples/android/build.gradle index 9ed2c7f11..3e6b1456e 100644 --- a/examples/android/build.gradle +++ b/examples/android/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.5.2' + classpath 'com.android.tools.build:gradle:8.7.2' } } diff --git a/examples/android/gradle/wrapper/gradle-wrapper.properties b/examples/android/gradle/wrapper/gradle-wrapper.properties index ce6a37765..97b28e0c9 100644 --- a/examples/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip diff --git a/prepare_osx_build_environment.sh b/prepare_osx_build_environment.sh index 1f6426a83..a89d278f3 100755 --- a/prepare_osx_build_environment.sh +++ b/prepare_osx_build_environment.sh @@ -2,61 +2,17 @@ set -e OPENSSL_DIR=openssl-3.0.15 -LIBXML2_DIR=libxml2-2.12.9 XMLSEC_DIR=xmlsec1-1.3.6 -ANDROID_NDK=android-ndk-r26d -FREETYPE_DIR=freetype-2.10.1 -FONTCONFIG_DIR=fontconfig-2.13.1 -PODOFO_DIR=podofo-0.9.4 ARGS="$@" case "$@" in *android*) - case "$@" in - *x86_64*) - ARCH=x86_64 - ARCH_ABI=x86_64 - CROSS_COMPILE=x86_64-linux-android - ;; - *arm64*) - ARCH=arm64 - ARCH_ABI=arm64-v8a - CROSS_COMPILE=aarch64-linux-android - ;; - *) - ARCH=arm - ARCH_ABI=armeabi-v7a - CROSS_COMPILE=armv7a-linux-androideabi - ;; - esac - echo "Building for Android ${ARCH}" - - : ${ANDROID_NDK_HOME:=$(ls -d /Volumes/${ANDROID_NDK}/AndroidNDK*.app/Contents/NDK)} - if [ ! -d "${ANDROID_NDK_HOME}" ]; then - if [ ! -f ${ANDROID_NDK}-darwin.dmg ]; then - curl -O -L https://dl.google.com/android/repository/${ANDROID_NDK}-darwin.dmg - fi - hdiutil attach -mountpoint /Volumes/${ANDROID_NDK} ${ANDROID_NDK}-darwin.dmg - ANDROID_NDK_HOME=$(ls -d /Volumes/${ANDROID_NDK}/AndroidNDK*.app/Contents/NDK) - fi - - TARGET_PATH=/Library/libdigidocpp.android${ARCH} - API=30 - export ANDROID_NDK_HOME - export ANDROID_NDK_ROOT=${ANDROID_NDK_HOME} - export PATH=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH - export AR=llvm-ar - export CC=${CROSS_COMPILE}${API}-clang - export AS=${CC} - export CXX=${CROSS_COMPILE}${API}-clang++ - export RANLIB=llvm-ranlib - export STRIP=llvm-strip - CONFIGURE="--host=${CROSS_COMPILE} --enable-static --disable-shared --disable-dependency-tracking --with-pic" + echo "vcpkg is used for managing android dependencies " + exit ;; *simulator*) echo "Building for iOS Simulator" TARGET_PATH=/Library/libdigidocpp.iphonesimulator - CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --disable-dependency-tracking" SYSROOT=$(xcrun -sdk iphonesimulator --show-sdk-path) : ${ARCHS:="arm64 x86_64"} : ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"} @@ -66,7 +22,6 @@ case "$@" in *iphonecatalyst*) echo "Building for iOS macOS Catalyst" TARGET_PATH=/Library/libdigidocpp.iphonecatalyst - CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --disable-dependency-tracking" SYSROOT=$(xcrun -sdk macosx --show-sdk-path) : ${ARCHS:="arm64 x86_64"} : ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"} @@ -76,7 +31,6 @@ case "$@" in *iphoneos*) echo "Building for iOS" TARGET_PATH=/Library/libdigidocpp.iphoneos - CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --disable-dependency-tracking" SYSROOT=$(xcrun -sdk iphoneos --show-sdk-path) : ${ARCHS:="arm64"} : ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"} @@ -86,7 +40,6 @@ case "$@" in *) echo "Building for macOS" TARGET_PATH=/Library/libdigidocpp - CONFIGURE="--disable-static --enable-shared --disable-dependency-tracking" SYSROOT=$(xcrun -sdk macosx --show-sdk-path) : ${ARCHS:="arm64 x86_64"} : ${MACOSX_DEPLOYMENT_TARGET:="12.0"} @@ -94,31 +47,6 @@ case "$@" in export CFLAGS="-arch ${ARCHS// / -arch } " ;; esac -export CXXFLAGS="${CFLAGS} -std=gnu++11 -Wno-null-conversion" - -function libxml2 { - echo Building ${LIBXML2_DIR} - case "${ARGS}" in - *android*) ;; - *) - echo "Not needed" - return 0 - ;; - esac - if [ ! -f ${LIBXML2_DIR}.tar.xz ]; then - curl -O -L https://download.gnome.org/sources/libxml2/2.12/${LIBXML2_DIR}.tar.xz - fi - rm -rf ${LIBXML2_DIR} - tar xf ${LIBXML2_DIR}.tar.xz - cd ${LIBXML2_DIR} - ./configure --prefix=${TARGET_PATH} ${CONFIGURE} --without-python - # Android is missing glob.h - sed -ie 's!runtest$(EXEEXT)!!' Makefile - sed -ie 's!testrecurse$(EXEEXT)!!' Makefile - make -s - sudo make install - cd - -} function xmlsec { echo Building ${XMLSEC_DIR} @@ -130,11 +58,11 @@ function xmlsec { cd ${XMLSEC_DIR} patch -Np1 -i ../vcpkg-ports/xmlsec/xmlsec1-1.3.5.legacy.patch case "${ARGS}" in - *android*) CONF_EXTRA="--without-libxslt --with-libxml=${TARGET_PATH}" ;; - *iphone*) CONF_EXTRA="--without-libxslt" ;; - *) ;; + *iphone*) CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --without-libxslt" ;; + *) CONFIGURE="--disable-static --enable-shared" ;; esac - ./configure --prefix=${TARGET_PATH} ${CONFIGURE} ${CONF_EXTRA} \ + ./configure --prefix=${TARGET_PATH} ${CONFIGURE} \ + --disable-dependency-tracking \ --disable-crypto-dl \ --disable-apps-crypto-dl \ --without-gnutls \ @@ -157,170 +85,45 @@ function openssl { rm -rf ${OPENSSL_DIR} tar xf ${OPENSSL_DIR}.tar.gz pushd ${OPENSSL_DIR} - case "${ARGS}" in - *android*) - ./Configure android-${ARCH} -D__ANDROID_API__=${API} --prefix=${TARGET_PATH} --openssldir=${TARGET_PATH}/ssl no-shared no-dso no-module no-engine no-tests no-ui-console - make -s > /dev/null - sudo make install_sw - ;; - *) - for ARCH in ${ARCHS} - do - case "${ARGS}" in - *simulator*) CC="" CFLAGS="-arch ${ARCH}" ./Configure iossimulator-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; - *catalyst*) CC="" CFLAGS="-target ${ARCH}-apple-ios-macabi" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; - *iphone*) CC="" CFLAGS="" ./Configure ios64-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; - *) CC="" CFLAGS="" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} shared no-module no-tests enable-ec_nistp_64_gcc_128 - esac - make -s > /dev/null - if [[ ${ARCHS} == ${ARCH}* ]]; then - sudo make install_sw > /dev/null - else - make install_sw DESTDIR=${PWD}/${ARCH} > /dev/null - mkdir -p universal/${TARGET_PATH}/lib - pushd ${ARCH} - for i in $(find ./${TARGET_PATH}/lib -type f -depth 1); do - lipo -create /$i $i -output ../universal/$i - done - popd - sudo mv universal/${TARGET_PATH}/lib/* ${TARGET_PATH}/lib/ - fi - make distclean - done - ;; - esac - popd -} - -function freetype { - echo Building ${FREETYPE_DIR} - if [ ! -f ${FREETYPE_DIR}.tar.bz2 ]; then - curl -O -L http://download.savannah.gnu.org/releases/freetype/${FREETYPE_DIR}.tar.bz2 - fi - rm -rf ${FREETYPE_DIR} - tar xf ${FREETYPE_DIR}.tar.bz2 - cd ${FREETYPE_DIR} - ./configure --prefix=${TARGET_PATH} ${CONFIGURE} --with-png=no --with-bzip2=no - make -s - sudo make install - cd - -} - -function fontconfig { - echo Building ${FONTCONFIG_DIR} - if [ ! -f ${FONTCONFIG_DIR}.tar.bz2 ]; then - curl -O -L https://www.freedesktop.org/software/fontconfig/release//${FONTCONFIG_DIR}.tar.bz2 - fi - rm -rf ${FONTCONFIG_DIR} - tar xf ${FONTCONFIG_DIR}.tar.bz2 - cd ${FONTCONFIG_DIR} - case "${ARGS}" in - *android*) - ./configure --prefix=${TARGET_PATH} ${CONFIGURE} --enable-libxml2 \ - FREETYPE_CFLAGS="-I${TARGET_PATH}/include/freetype2" FREETYPE_LIBS="-L${TARGET_PATH}/lib -lfreetype" \ - LIBXML2_CFLAGS="-I${TARGET_PATH}/include/libxml2" LIBXML2_LIBS="-L${TARGET_PATH}/lib -lxml2" - ;; - *) - ./configure --prefix=${TARGET_PATH} ${CONFIGURE} --enable-libxml2 \ - FREETYPE_CFLAGS="-I${TARGET_PATH}/include/freetype2" FREETYPE_LIBS="-L${TARGET_PATH}/lib -lfreetype" \ - LIBXML2_CFLAGS="-I${SYSROOT}/usr/include/libxml2" LIBXML2_LIBS="-L${SYSROOT}/usr/lib -lxml2" - ;; - esac - make -s - sudo make install - cd - -} - -function podofo { - echo Building ${PODOFO_DIR} - if [ ! -f ${PODOFO_DIR}.tar.gz ]; then - curl -O -L http://downloads.sourceforge.net/project/podofo/podofo/0.9.4/${PODOFO_DIR}.tar.gz - fi - rm -rf ${PODOFO_DIR} - tar xf ${PODOFO_DIR}.tar.gz - cd ${PODOFO_DIR} - rm cmake/modules/FindFREETYPE.cmake - rm cmake/modules/FindOpenSSL.cmake - rm cmake/modules/FindZLIB.cmake - sed -ie 's!${PNG_LIBRARIES}!!' CMakeLists.txt - sed -ie 's!adbe.pkcs7.detached!ETSI.CAdES.detached!' src/doc/PdfSignatureField.cpp - PODOFO="" for ARCH in ${ARCHS} do case "${ARGS}" in - *android*) - PARAMS="-DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=${TARGET_PATH} - -DCMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} - -DLIBCRYPTO_LIBRARY_RELEASE=${TARGET_PATH}/lib/libcrypto.a - -DPODOFO_BUILD_STATIC=NO - -DPODOFO_BUILD_SHARED=YES - -DFONTCONFIG_LIBRARIES=${TARGET_PATH}/lib/libfontconfig.a;${TARGET_PATH}/lib/libxml2.a - -DZLIB_INCLUDE_DIR=${SYSROOT}/usr/include - -DZLIB_LIBRARY=${SYSROOT}/usr/lib/libz.so" - ;; - *iphone*) - PARAMS="-DLIBCRYPTO_LIBRARY_RELEASE=${TARGET_PATH}/lib/libcrypto.a - -DPODOFO_BUILD_STATIC=YES - -DPODOFO_BUILD_SHARED=NO - -DCMAKE_OSX_SYSROOT=${SYSROOT} - -DCMAKE_OSX_ARCHITECTURES=${ARCH}" - ;; - *) - PARAMS="-DLIBCRYPTO_LIBRARY_RELEASE=${TARGET_PATH}/lib/libcrypto.dylib - -DPODOFO_BUILD_STATIC=YES - -DPODOFO_BUILD_SHARED=NO - -DCMAKE_OSX_SYSROOT=${SYSROOT} - -DCMAKE_OSX_ARCHITECTURES=${ARCH}" - ;; + *simulator*) CC="" CFLAGS="-arch ${ARCH}" ./Configure iossimulator-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; + *catalyst*) CC="" CFLAGS="-target ${ARCH}-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-macabi" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; + *iphone*) CC="" CFLAGS="" ./Configure ios64-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;; + *) CC="" CFLAGS="" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} shared no-module no-tests enable-ec_nistp_64_gcc_128 esac - cmake \ - -DCMAKE_INSTALL_PREFIX=${TARGET_PATH} \ - -DCMAKE_C_COMPILER_WORKS=yes \ - -DCMAKE_CXX_COMPILER_WORKS=yes \ - -DCMAKE_C_FLAGS="${SDK_CFLAGS}" \ - -DCMAKE_CXX_FLAGS="${SDK_CFLAGS} -I${TARGET_PATH}/include/freetype2" \ - -DCMAKE_BUILD_TYPE="Release" \ - -DPODOFO_BUILD_LIB_ONLY=YES \ - -DOPENSSL_ROOT_DIR=${TARGET_PATH} \ - -DLIBCRYPTO_INCLUDE_DIR=${TARGET_PATH}/include \ - -DPNG_PNG_INCLUDE_DIR=PNG_PNG_INCLUDE_DIR-NOTFOUND \ - -DPNG_LIBRARY_RELEASE=PNG_LIBRARY_RELEASE-NOTFOUND \ - -DLIBJPEG_LIBRARY_RELEASE=LIBJPEG_LIBRARY_RELEASE-NOTFOUND \ - -DTIFF_INCLUDE_DIR=TIFF_INCLUDE_DIR-NOTFOUND \ - -DTIFF_LIBRARY_RELEASE=TIFF_LIBRARY_RELEASE-NOTFOUND \ - ${PARAMS} . - make -s - make install DESTDIR=${ARCH} - PODOFO="${PODOFO} ${ARCH}/${TARGET_PATH}/lib/libpodofo.a" + make -s > /dev/null + if [[ ${ARCHS} == ${ARCH}* ]]; then + sudo make install_sw > /dev/null + else + make install_sw DESTDIR=${PWD}/${ARCH} > /dev/null + mkdir -p universal/${TARGET_PATH}/lib + pushd ${ARCH} + for i in $(find ./${TARGET_PATH}/lib -type f -depth 1); do + lipo -create /$i $i -output ../universal/$i + done + popd + sudo mv universal/${TARGET_PATH}/lib/* ${TARGET_PATH}/lib/ + fi + make distclean done - sudo make install - tmp=(${ARCHS}) - if [ "${#tmp[@]}" -ne "1" ]; then - echo lipo - sudo lipo -create ${PODOFO} -output ${TARGET_PATH}/lib/libpodofo.a - fi - cd - + popd } case "$@" in -*libxml2*) libxml2 ;; *xmlsec*) xmlsec ;; *openssl*) openssl ;; -*freetype*) freetype ;; -*fontconfig*) fontconfig ;; -*podofo*) podofo ;; *all*) openssl - libxml2 xmlsec ;; *) echo "Usage:" echo " $0 [target] [task]" - echo " target: osx iphoneos iphonesimulator iphonecatalyst androidarm androidarm64 androidx86_64" - echo " tasks: openssl, libxml2, xmlsec, all, help" - echo "To control iOS, macOS builds set environment variables:" + echo " target: macos iphoneos iphonesimulator iphonecatalyst" + echo " tasks: openssl, xmlsec, all, help" + echo "To control builds set environment variables:" echo " minimum deployment target" echo " - MACOSX_DEPLOYMENT_TARGET=12.0" echo " - IPHONEOS_DEPLOYMENT_TARGET=15.0" diff --git a/vcpkg-triplets/arm-neon-android.cmake b/vcpkg-triplets/arm-neon-android.cmake new file mode 100644 index 000000000..2b729484a --- /dev/null +++ b/vcpkg-triplets/arm-neon-android.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE arm) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 30) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=armv7a-linux-androideabi") +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON) diff --git a/vcpkg-triplets/arm64-android.cmake b/vcpkg-triplets/arm64-android.cmake new file mode 100644 index 000000000..1d59c1517 --- /dev/null +++ b/vcpkg-triplets/arm64-android.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 30) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-linux-android") +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=arm64-v8a) diff --git a/vcpkg-triplets/x64-android.cmake b/vcpkg-triplets/x64-android.cmake new file mode 100644 index 000000000..98071d89a --- /dev/null +++ b/vcpkg-triplets/x64-android.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 30) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86_64-linux-android") +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=x86_64) diff --git a/vcpkg.json b/vcpkg.json index 2d8f1954a..764cf30ae 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -14,6 +14,7 @@ }, "builtin-baseline": "e2edf52610d2c94d2038fe30b247ea5a26964e1b", "vcpkg-configuration": { + "overlay-triplets": ["./vcpkg-triplets"], "overlay-ports": [ "vcpkg-ports/openssl", "vcpkg-ports/xmlsec"