simple-c2pa

This is a fork of https://gitlab.com/guardianproject/proofmode/simple-c2pa
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/simple-c2pa.git
Log | Files | Refs | README | LICENSE

Makefile.toml (3928B)


      1 [env]
      2 BUILD_MODE = "release"
      3 TARGET_DIR = "target"
      4 BINDINGS_DIR = "bindings"
      5 OUT_DIR = "out"
      6 
      7 [tasks.clean-build-dirs]
      8 script = '''
      9 rm -rf "${TARGET_DIR}"
     10 rm -rf "${BINDINGS_DIR}"
     11 rm -rf "${OUT_DIR}"
     12 '''
     13 
     14 [tasks.common-install-dependencies]
     15 script = 'cargo install --force cargo-make'
     16 
     17 [tasks.apple-install-dependencies]
     18 script = 'rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim'
     19 
     20 [tasks.apple-build-bindings]
     21 script = 'cargo run --bin uniffi-bindgen generate --language swift --library ${TARGET_DIR}/aarch64-apple-ios/release/libsimple_c2pa.a --out-dir ${BINDINGS_DIR}/swift'
     22 
     23 [tasks.apple-build-libraries]
     24 script = '''
     25 cargo build --target aarch64-apple-darwin --release
     26 cargo build --target aarch64-apple-ios --release
     27 cargo build --target x86_64-apple-ios --release
     28 cargo build --target aarch64-apple-ios-sim --release
     29 '''
     30 dependencies = ["common-install-dependencies"]
     31 
     32 [tasks.apple-assemble-framework]
     33 env = { NAME = "SimpleC2PA", LIB_NAME = "simple_c2pa", HEADER_PATH = "${BINDINGS_DIR}/swift/${NAME}FFI.h", NEW_HEADER_DIR = "${BINDINGS_DIR}/swift/include", STATIC_LIB_NAME = "lib${LIB_NAME}.a", OUT_DIR = "out/apple" }
     34 script = '''
     35 mkdir -p "${NEW_HEADER_DIR}"
     36 cp "${HEADER_PATH}" "${NEW_HEADER_DIR}/"
     37 cp "${BINDINGS_DIR}/swift/${NAME}FFI.modulemap" "${NEW_HEADER_DIR}/module.modulemap"
     38 
     39 rm -rf "${OUT_DIR}"
     40 mkdir -p ${OUT_DIR}
     41 
     42 xcrun lipo -create -output "${TARGET_DIR}/simulators.a" "${TARGET_DIR}/aarch64-apple-ios-sim/${BUILD_MODE}/${STATIC_LIB_NAME}" "${TARGET_DIR}/x86_64-apple-ios/${BUILD_MODE}/${STATIC_LIB_NAME}"
     43 
     44 xcodebuild -create-xcframework \
     45 	   -library "${TARGET_DIR}/aarch64-apple-ios/${BUILD_MODE}/${STATIC_LIB_NAME}" \
     46 	   -headers "${NEW_HEADER_DIR}" \
     47 	   -library "${TARGET_DIR}/simulators.a" \
     48 	   -headers "${NEW_HEADER_DIR}" \
     49     -output "${OUT_DIR}/${NAME}.xcframework"
     50 
     51 (cd "${OUT_DIR}" && zip -r "${NAME}.xcframework.zip" "${NAME}.xcframework")
     52 rm -rf "${OUT_DIR}/${NAME}.xcframework"
     53 cp "${BINDINGS_DIR}/swift/${NAME}.swift" "${OUT_DIR}/"
     54 '''
     55 
     56 [tasks.apple-build]
     57 dependencies = [
     58   "apple-install-dependencies",
     59   "apple-build-libraries",
     60   "apple-build-bindings",
     61   "apple-assemble-framework",
     62 ]
     63 
     64 [tasks.android-install-dependencies]
     65 script = 'cargo install cross --git https://github.com/cross-rs/cross'
     66 dependencies = ["common-install-dependencies"]
     67 
     68 [tasks.android-build-libraries]
     69 script = '''
     70 cross build --target x86_64-linux-android --release
     71 cross build --target i686-linux-android --release
     72 cross build --target armv7-linux-androideabi --release
     73 cross build --target aarch64-linux-android --release
     74 '''
     75 
     76 [tasks.android-build-bindings]
     77 script = '''
     78 cross build --target x86_64-linux-android
     79 cargo run --bin uniffi-bindgen generate --language kotlin --library ./target/x86_64-linux-android/debug/libsimple_c2pa.so --out-dir ${BINDINGS_DIR}/kotlin
     80 '''
     81 
     82 [tasks.android-assemble-aar-files]
     83 env = { NAME = "simple_c2pa", LIB_NAME = "lib${NAME}.so", OUT_DIR = "out/android", JNILIBS_DIR = "${OUT_DIR}/jniLibs", ANDROID_BINDINGS_DIR = "kotlin/info/guardianproject/simple_c2pa" }
     84 script = '''
     85 rm -rf "${OUT_DIR}"
     86 mkdir -p ${OUT_DIR}/${ANDROID_BINDINGS_DIR}
     87 cp ${BINDINGS_DIR}/${ANDROID_BINDINGS_DIR}/* ${OUT_DIR}/${ANDROID_BINDINGS_DIR}/
     88 echo "${JNILIBS_DIR}/x86_64"
     89 mkdir -p "${JNILIBS_DIR}/x86_64" "${JNILIBS_DIR}/x86" "${JNILIBS_DIR}/armeabi-v7a" "${JNILIBS_DIR}/arm64-v8a"
     90 cp "${TARGET_DIR}/x86_64-linux-android/${BUILD_MODE}/${LIB_NAME}" "${JNILIBS_DIR}/x86_64/${LIB_NAME}"
     91 cp "${TARGET_DIR}/i686-linux-android/${BUILD_MODE}/${LIB_NAME}" "${JNILIBS_DIR}/x86/${LIB_NAME}"
     92 cp "${TARGET_DIR}/armv7-linux-androideabi/${BUILD_MODE}/${LIB_NAME}" "${JNILIBS_DIR}/armeabi-v7a/${LIB_NAME}"
     93 cp "${TARGET_DIR}/aarch64-linux-android/${BUILD_MODE}/${LIB_NAME}" "${JNILIBS_DIR}/arm64-v8a/${LIB_NAME}"
     94 '''
     95 
     96 [tasks.android-build]
     97 dependencies = [
     98   "android-install-dependencies",
     99   "android-build-libraries",
    100   "android-build-bindings",
    101   "android-assemble-aar-files",
    102 ]