Skip to content

Commit 6abaa1b

Browse files
committed
Merge remote-tracking branch 'origin/staging' into apple-updates
2 parents 025404b + a9fa467 commit 6abaa1b

File tree

4 files changed

+130
-3
lines changed

4 files changed

+130
-3
lines changed

scripts/app_config/templates/configure_template_files.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ for TF in "${TEMPLATE_FILES[@]}"; do
6565
rm "${FILE}"
6666
fi
6767
cp -rp "${TEMPLATES_DIR}/${TF}" "${FILE}"
68-
done
68+
done
69+
70+
if [ "$BUILD_ISAR_FROM_SOURCE" -eq 1 ]; then
71+
source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/isar_build.sh"
72+
build_isar_source
73+
fi
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
find_isar_core_lib() {
4+
local isar_core_path
5+
isar_core_path=$(find "${HOME}/.pub-cache/git" -type d -path "*/isar_core_ffi" -print -quit 2>/dev/null)
6+
[[ -z "${isar_core_path}" ]] && return 1
7+
echo "${isar_core_path}"
8+
}
9+
10+
detect_isar_version() {
11+
local version="unknown"
12+
local lock_file="${APP_PROJECT_ROOT_DIR}/pubspec.lock"
13+
[[ -f "${lock_file}" ]] && version=$(grep -A1 "isar_community:" "${lock_file}" 2>/dev/null | grep version | awk -F'"' '{print $2}' | head -n1)
14+
echo "${version:-3.3.0-dev.2}"
15+
}
16+
17+
copy_isar_lib() {
18+
local lib_src="$1"
19+
local lib_dest="$2"
20+
21+
if [[ ! -f "${lib_src}" ]]; then
22+
echo "Warning: libisar.so not found at ${lib_src}"
23+
return 1
24+
fi
25+
26+
mkdir -p "${lib_dest}"
27+
cp -f "${lib_src}" "${lib_dest}/"
28+
echo "Copied libisar.so to ${lib_dest}"
29+
}
30+
31+
build_isar_core() {
32+
local isar_core_path="$1"
33+
local workspace_root="$2"
34+
35+
echo "Building Isar core from: ${isar_core_path}"
36+
37+
if [[ ! -f "${isar_core_path}/Cargo.toml" ]]; then
38+
echo "Error: Cargo.toml not found" >&2
39+
return 1
40+
fi
41+
42+
if [[ -f "${workspace_root}/target/release/libisar.so" ]] || \
43+
[[ -f "${workspace_root}/target/release/deps/libisar.so" ]]; then
44+
echo "Note: libisar.so already built, skipping build step"
45+
return 0
46+
fi
47+
48+
(cd "${isar_core_path}" && cargo build --release) || {
49+
echo "Error: cargo build failed for isar_core_ffi" >&2
50+
return 1
51+
}
52+
}
53+
54+
find_isar_library() {
55+
local workspace_root="$1"
56+
57+
if [[ -f "${workspace_root}/target/release/libisar.so" ]]; then
58+
echo "${workspace_root}/target/release/libisar.so"
59+
return 0
60+
fi
61+
62+
if [[ -f "${workspace_root}/target/release/deps/libisar.so" ]]; then
63+
echo "${workspace_root}/target/release/deps/libisar.so"
64+
return 0
65+
fi
66+
67+
echo "Error: could not produce libisar.so" >&2
68+
return 1
69+
}
70+
71+
build_isar_source() {
72+
echo "------------------------------------------------------------"
73+
echo "Building Isar database library from source (BUILD_ISAR_FROM_SOURCE=1)"
74+
echo "------------------------------------------------------------"
75+
76+
local isar_core_path
77+
isar_core_path=$(find_isar_core_lib) || {
78+
echo "Error: could not locate isar_core_ffi inside ~/.pub-cache/git."
79+
return 1
80+
}
81+
82+
echo "Found isar_core_ffi at: ${isar_core_path}"
83+
84+
local workspace_root=$(dirname $(dirname "${isar_core_path}"))
85+
86+
build_isar_core "${isar_core_path}" "${workspace_root}" || return 1
87+
88+
local lib_src
89+
lib_src=$(find_isar_library "${workspace_root}") || return 1
90+
91+
local plugin_path="${APP_PROJECT_ROOT_DIR}/linux/flutter/ephemeral/.plugin_symlinks/isar_community_flutter_libs/linux"
92+
if [[ -d "$(dirname "${plugin_path}")" ]]; then
93+
copy_isar_lib "${lib_src}" "${plugin_path}" || return 1
94+
fi
95+
96+
local bundle_path="${APP_PROJECT_ROOT_DIR}/build/linux/x64/release/bundle/lib"
97+
if [[ -d "$(dirname "${bundle_path}")" ]]; then
98+
copy_isar_lib "${lib_src}" "${bundle_path}" || return 1
99+
fi
100+
}

scripts/app_config/templates/pubspec.template.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,24 @@ dependency_overrides:
323323
pinenacl: ^0.6.0
324324
http: ^0.13.0
325325

326+
# %%ENABLE_ISAR%%
327+
# isar_community:
328+
# git:
329+
# url: https://github.com/isar-community/isar-community.git
330+
# path: packages/isar_community
331+
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
332+
# isar_community_flutter_libs:
333+
# git:
334+
# url: https://github.com/isar-community/isar-community.git
335+
# path: packages/isar_community_flutter_libs
336+
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
337+
# isar_community_generator:
338+
# git:
339+
# url: https://github.com/isar-community/isar-community.git
340+
# path: packages/isar_community_generator
341+
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
342+
# %%END_ENABLE_ISAR%%
343+
326344
# For information on the generic Dart part of this file, see the
327345
# following page: https://dart.dev/tools/pub/pubspec
328346

scripts/build_app.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ APP_NAMED_IDS=("stack_wallet" "stack_duo" "campfire")
99

1010
# Function to display usage.
1111
usage() {
12-
echo "Usage: $0 -v <version> -b <build_number> -p <platform> -a <app>"
12+
echo "Usage: $0 -v <version> -b <build_number> -p <platform> -a <app> [-i] [-f]"
1313
exit 1
1414
}
1515

@@ -33,15 +33,17 @@ unset -v APP_NAMED_ID
3333

3434
# optional args (with defaults)
3535
BUILD_CRYPTO_PLUGINS=0
36+
BUILD_ISAR_FROM_SOURCE=0
3637

3738
# Parse command-line arguments.
38-
while getopts "v:b:p:a:i" opt; do
39+
while getopts "v:b:p:a:i:f" opt; do
3940
case "${opt}" in
4041
v) APP_VERSION_STRING="$OPTARG" ;;
4142
b) APP_BUILD_NUMBER="$OPTARG" ;;
4243
p) APP_BUILD_PLATFORM="$OPTARG" ;;
4344
a) APP_NAMED_ID="$OPTARG" ;;
4445
i) BUILD_CRYPTO_PLUGINS=1 ;;
46+
f) BUILD_ISAR_FROM_SOURCE=1 ;;
4547
*) usage ;;
4648
esac
4749
done
@@ -71,6 +73,8 @@ set -x
7173

7274
source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/configure_template_files.sh"
7375

76+
export BUILD_ISAR_FROM_SOURCE
77+
7478
# checks for the correct platform dir and pushes it for later
7579
if printf '%s\0' "${APP_PLATFORMS[@]}" | grep -Fxqz -- "${APP_BUILD_PLATFORM}"; then
7680
pushd "${APP_PROJECT_ROOT_DIR}/scripts/${APP_BUILD_PLATFORM}"

0 commit comments

Comments
 (0)