@@ -27,9 +27,47 @@ if [ "$verify_only" = true ]; then
2727else
2828
2929if [ -d " $code_dir " ]; then # Do we have an existing code repo?
30- pushd " $code_dir " # todo fix this workaround for building into cbuild dir in "our" objectbox-swift dir
31- echo " Have repository, building."
32- " $code_dir /scripts/apple-build-static-libs.sh" " $dest_dir " release
30+ pushd " $code_dir " # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
31+ build_params=" " # must also part of the cache key
32+ commit_id=$( git rev-parse HEAD)
33+ cache_dir=" $HOME /Library/Caches/ObjectBox"
34+ mkdir -p " ${cache_dir} "
35+ find " ${cache_dir} " -name " objectbox-static-*.zip" -type f -mtime +30 # -delete # TODO enable delete once this looks good
36+ cache_key=" ${commit_id} "
37+ if [ -n " $build_params " ]; then
38+ cache_key=" ${cache_key} -$( echo " $build_params " | tr -cd ' [a-zA-Z0-9]._-' ) "
39+ fi
40+ cache_zip=" ${cache_dir} /objectbox-static-${cache_key} .zip"
41+ do_build=true
42+ git_clean=false
43+ git_status=$( git status --porcelain)
44+ # ignore untracked uws submodule (left over when switching from a sync to a non-sync branch)
45+ git_status=${git_status# " ?? objectbox/src/main/cpp/external/uws-objectbox/" }
46+ if [ -z " $git_status " ]; then
47+ git_clean=true
48+ if [ -f " ${cache_zip} " ]; then
49+ echo " ObjectBox core is clean and cache ZIP found for ${cache_key} . Extracting..."
50+ unzip -o " ${cache_zip} " -d " ${dest_dir} "
51+ do_build=false
52+ else
53+ echo " ObjectBox core is clean but no cache ZIP found for ${cache_key} . Building..."
54+ fi
55+ else
56+ git status
57+ echo " ObjectBox core is not clean, won't use caching. Building..."
58+ fi
59+ if [ " $do_build " = true ]; then
60+ " $code_dir /scripts/apple-build-static-libs.sh" $build_params " $dest_dir " release
61+ if [ " $git_clean " = true ] ; then # clean before?
62+ git_status=${git_status# " ?? objectbox/src/main/cpp/external/uws-objectbox/" }
63+ if [ -z " $git_status " ]; then # still clean
64+ cp " ${dest_dir} /objectbox-static.zip" " ${cache_zip} "
65+ echo " Cache ZIP created: ${cache_zip} "
66+ else
67+ echo " Git status is not clean anymore; skipped caching the ZIP"
68+ fi
69+ fi
70+ fi
3371 popd
3472else # Download static public release and unzip into $dest
3573 if [ ! -d " ${dest_dir} " ] || [ ! -e " ${dest_dir} /libObjectBoxCore-iOS.a" ]; then
@@ -70,7 +108,14 @@ for filename in ./*.a; do
70108 # Match our version/date pattern like "2.6.1-2020-06-09"
71109 obx_version=$( strings " $filename " | grep " [0-9]\.[0-9]\.[0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" )
72110 echo " >> Version found: $obx_version "
73- obx_symbols=$( nm -gj " $filename " | grep -c obx_ || true)
74- obx_sync_symbols=$( nm -gj " $filename " | grep -c obx_sync_ || true)
75- echo " >> Symbols found: $obx_symbols obx, $obx_sync_symbols obx_sync"
111+ obx_symbols=$( nm -gj " $filename " | grep -c obx_) || true
112+ obx_sync_symbols=$( nm -gj " $filename " | grep -c obx_sync_) || true
113+ # Also include "external libs" to expose potential build problems
114+ obx_lws_symbols=$( nm -gj " $filename " | grep -c lws_) || true
115+ obx_mbedtls_symbols=$( nm -gj " $filename " | grep -c mbedtls_) || true
116+ echo " >> Symbols found: $obx_symbols obx, $obx_sync_symbols obx_sync, $obx_lws_symbols lws, $obx_mbedtls_symbols mbedtls"
117+ obx_archs=$( lipo -archs " $filename " )
118+ echo " >> Architectures: $obx_archs "
119+ sha=($( shasum -a 256 " $filename " ) )
120+ echo " >> SHA256: $sha "
76121done
0 commit comments