#!/usr/bin/env bash
# Create the corresponding-source archive for the LGPL-2.1 CAD importer, to host next to the binaries:
#   occt-import-js-0.0.23-source.tar.gz  (occt-import-js tag 0.0.23 incl. Open CASCADE 7.6.1 in occt/)
set -euo pipefail
OUT="${1:-$PWD}/occt-import-js-0.0.23-source.tar.gz"
TMP="$(mktemp -d)"; cd "$TMP"
git clone https://github.com/kovacsv/occt-import-js.git occt-import-js-0.0.23
cd occt-import-js-0.0.23
git checkout c2148e54b456b571238d35cac037d304053d64b2
git config submodule.occt.url https://github.com/Open-Cascade-SAS/OCCT.git
git submodule update --init --depth 1 occt || git submodule update --init occt
test "$(git -C occt rev-parse HEAD)" = "d2abb6d844231cb8f29be6894440874a4700e4a5"
cat > SOURCE-INFO.txt <<INFO
Corresponding source of the CAD importer used by Design for Feeding (RNA Digital Solutions GmbH).
occt-import-js 0.0.23, commit c2148e54b456b571238d35cac037d304053d64b2, https://github.com/kovacsv/occt-import-js
Open CASCADE Technology 7.6.1, commit d2abb6d844231cb8f29be6894440874a4700e4a5 (tag V7_6_1), in occt/
Licence: GNU LGPL 2.1 (LICENSE.md, occt/LICENSE_LGPL_21.txt) with the Open CASCADE exception (occt/OCCT_LGPL_EXCEPTION.txt).
Build: see tools/ and CMakeLists.txt (Emscripten 3.1.69, Release, -Oz).
INFO
cd ..
tar --exclude='.git' -czf "$OUT" occt-import-js-0.0.23
rm -rf "$TMP"
ls -la "$OUT"; sha256sum "$OUT"
