SPB Git

Repository Public

build-xcframework.sh 5.6 KB 142 lines shellscript

1#!/bin/bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : KA Maps Engine8# File             : sdk/ios/Scripts/build-xcframework.sh9# Module           : sdk10# Repository       : https://git.spboucher.ai/ka-maps-engine11# Created          : 2026-12-0112# Last Modified    : 2026-12-0113#14# Author           : Simon-Pierre Boucher15# Position         : Professor of Finance16# Institution      : Université du Québec en Outaouais (UQO)17# Organization     : SP Boucher18# Website          : https://spboucher.ai19# Git              : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin   : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License          : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Construit sdk/ios/KAMapsCore.xcframework (moteur Rust km-ffi, bibliothèque statique) :41#   tranche appareil  : aarch64-apple-ios42#   tranche simulateur : aarch64-apple-ios-sim (+ x86_64-apple-ios avec --with-x86_64)43# L'en-tête C est régénéré par cbindgen. Résultat reproductible : Cargo.lock imposé (--locked),44# chemins de construction neutralisés, cible de déploiement fixée.45#46# Usage : sdk/ios/Scripts/build-xcframework.sh [--debug] [--with-x86_64]47set -euo pipefail4849HERE="$(cd "$(dirname "$0")" && pwd)"50SDK_DIR="$(cd "$HERE/.." && pwd)"51REPO="$(cd "$SDK_DIR/../.." && pwd)"52ENGINE="$REPO/engine"53OUT="$SDK_DIR/KAMapsCore.xcframework"54BUILD="$SDK_DIR/.build-core"5556# Empreinte des sources du moteur : arbre git de engine/ au commit courant (+ « modifié » si l'arbre de57# travail diffère). Écrite dans le .xcframework ; `--check` la compare à l'état courant.58stamp() {59  local tree dirty=""60  tree="$(git -C "$REPO" rev-parse HEAD:engine 2>/dev/null || echo inconnu)"61  git -C "$REPO" diff --quiet HEAD -- engine 2>/dev/null || dirty="+modifié"62  echo "engine=$tree$dirty"63}6465PROFILE=release66WITH_X86=067for a in "$@"; do68  case "$a" in69    --check)70      # À mettre en script de pré-construction d'une application : échoue si le moteur lié ne vient pas71      # des sources présentes (un `git pull` a changé engine/ sous un .xcframework plus ancien).72      if [ ! -f "$OUT/kamaps-stamp.txt" ]; then echo "error: KAMapsCore.xcframework absent : lancer sdk/ios/Scripts/build-xcframework.sh" >&2; exit 1; fi73      if [ "$(cat "$OUT/kamaps-stamp.txt")" != "$(stamp)" ]; then74        echo "error: KAMapsCore.xcframework périmé ($(cat "$OUT/kamaps-stamp.txt") ; sources : $(stamp)) : relancer sdk/ios/Scripts/build-xcframework.sh" >&2; exit 175      fi76      echo "KAMapsCore.xcframework à jour ($(stamp))"; exit 0 ;;77    --debug) PROFILE=debug ;;78    --with-x86_64) WITH_X86=1 ;;79    *) echo "option inconnue : $a" >&2; exit 2 ;;80  esac81done8283command -v cargo >/dev/null || { echo "cargo introuvable" >&2; exit 1; }84command -v cbindgen >/dev/null || { echo "cbindgen introuvable : cargo install cbindgen" >&2; exit 1; }8586export IPHONEOS_DEPLOYMENT_TARGET=18.087export SOURCE_DATE_EPOCH=176454720088export ZERO_AR_DATE=189export CARGO_PROFILE_RELEASE_DEBUG=090export CARGO_PROFILE_RELEASE_STRIP=debuginfo91export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=192export CARGO_INCREMENTAL=093export RUSTFLAGS="--remap-path-prefix=$REPO=ka-maps --remap-path-prefix=$HOME/.cargo=cargo --remap-path-prefix=$HOME/.rustup=rustup"9495TARGETS=(aarch64-apple-ios aarch64-apple-ios-sim)96[ "$WITH_X86" = 1 ] && TARGETS+=(x86_64-apple-ios)9798FLAG=""99[ "$PROFILE" = release ] && FLAG="--release"100for t in "${TARGETS[@]}"; do101  echo "== cargo build $t ($PROFILE)"102  cargo build --manifest-path "$ENGINE/Cargo.toml" -p km-ffi --lib --locked $FLAG --target "$t"103done104105rm -rf "$BUILD" "$OUT"106mkdir -p "$BUILD/Headers" "$BUILD/sim"107108echo "== cbindgen"109cbindgen --quiet --config "$ENGINE/km-ffi/cbindgen.toml" --crate km-ffi --output "$BUILD/Headers/ka_maps_core.h" "$ENGINE/km-ffi"110cat > "$BUILD/Headers/module.modulemap" <<'EOF'111module KAMapsCore {112    header "ka_maps_core.h"113    export *114}115EOF116# Copie versionnée de l'en-tête (revue, liaison Android éventuelle).117mkdir -p "$ENGINE/km-ffi/include"118cp "$BUILD/Headers/ka_maps_core.h" "$ENGINE/km-ffi/include/ka_maps_core.h"119120DEVICE_LIB="$ENGINE/target/aarch64-apple-ios/$PROFILE/libkm_ffi.a"121SIM_LIB="$BUILD/sim/libkm_ffi.a"122if [ "$WITH_X86" = 1 ]; then123  lipo -create "$ENGINE/target/aarch64-apple-ios-sim/$PROFILE/libkm_ffi.a" "$ENGINE/target/x86_64-apple-ios/$PROFILE/libkm_ffi.a" -output "$SIM_LIB"124else125  cp "$ENGINE/target/aarch64-apple-ios-sim/$PROFILE/libkm_ffi.a" "$SIM_LIB"126fi127128echo "== xcodebuild -create-xcframework"129xcodebuild -create-xcframework \130  -library "$DEVICE_LIB" -headers "$BUILD/Headers" \131  -library "$SIM_LIB" -headers "$BUILD/Headers" \132  -output "$OUT" >/dev/null133134stamp > "$OUT/kamaps-stamp.txt"135rm -rf "$BUILD"136echo "== tranches"137for d in "$OUT"/*/; do138  lib="$d/libkm_ffi.a"139  [ -f "$lib" ] && printf '%-28s %8s Ko  sha256 %s\n' "$(basename "$d")" "$(( $(stat -f %z "$lib") / 1024 ))" "$(shasum -a 256 "$lib" | cut -c1-16)"140done141echo "OK : $OUT"142
Files main
Menu

Theme