Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/app_config/templates/configure_template_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ for TF in "${TEMPLATE_FILES[@]}"; do
rm "${FILE}"
fi
cp -rp "${TEMPLATES_DIR}/${TF}" "${FILE}"
done
done

if [ "$BUILD_ISAR_FROM_SOURCE" -eq 1 ]; then
source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/isar_build.sh"
build_isar_source
fi
100 changes: 100 additions & 0 deletions scripts/app_config/templates/isar_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

find_isar_core_lib() {
local isar_core_path
isar_core_path=$(find "${HOME}/.pub-cache/git" -type d -path "*/isar_core_ffi" -print -quit 2>/dev/null)
[[ -z "${isar_core_path}" ]] && return 1
echo "${isar_core_path}"
}

detect_isar_version() {
local version="unknown"
local lock_file="${APP_PROJECT_ROOT_DIR}/pubspec.lock"
[[ -f "${lock_file}" ]] && version=$(grep -A1 "isar_community:" "${lock_file}" 2>/dev/null | grep version | awk -F'"' '{print $2}' | head -n1)
echo "${version:-3.3.0-dev.2}"
}

copy_isar_lib() {
local lib_src="$1"
local lib_dest="$2"

if [[ ! -f "${lib_src}" ]]; then
echo "Warning: libisar.so not found at ${lib_src}"
return 1
fi

mkdir -p "${lib_dest}"
cp -f "${lib_src}" "${lib_dest}/"
echo "Copied libisar.so to ${lib_dest}"
}

build_isar_core() {
local isar_core_path="$1"
local workspace_root="$2"

echo "Building Isar core from: ${isar_core_path}"

if [[ ! -f "${isar_core_path}/Cargo.toml" ]]; then
echo "Error: Cargo.toml not found" >&2
return 1
fi

if [[ -f "${workspace_root}/target/release/libisar.so" ]] || \
[[ -f "${workspace_root}/target/release/deps/libisar.so" ]]; then
echo "Note: libisar.so already built, skipping build step"
return 0
fi

(cd "${isar_core_path}" && cargo build --release) || {
echo "Error: cargo build failed for isar_core_ffi" >&2
return 1
}
}

find_isar_library() {
local workspace_root="$1"

if [[ -f "${workspace_root}/target/release/libisar.so" ]]; then
echo "${workspace_root}/target/release/libisar.so"
return 0
fi

if [[ -f "${workspace_root}/target/release/deps/libisar.so" ]]; then
echo "${workspace_root}/target/release/deps/libisar.so"
return 0
fi

echo "Error: could not produce libisar.so" >&2
return 1
}

build_isar_source() {
echo "------------------------------------------------------------"
echo "Building Isar database library from source (BUILD_ISAR_FROM_SOURCE=1)"
echo "------------------------------------------------------------"

local isar_core_path
isar_core_path=$(find_isar_core_lib) || {
echo "Error: could not locate isar_core_ffi inside ~/.pub-cache/git."
return 1
}

echo "Found isar_core_ffi at: ${isar_core_path}"

local workspace_root=$(dirname $(dirname "${isar_core_path}"))

build_isar_core "${isar_core_path}" "${workspace_root}" || return 1

local lib_src
lib_src=$(find_isar_library "${workspace_root}") || return 1

local plugin_path="${APP_PROJECT_ROOT_DIR}/linux/flutter/ephemeral/.plugin_symlinks/isar_community_flutter_libs/linux"
if [[ -d "$(dirname "${plugin_path}")" ]]; then
copy_isar_lib "${lib_src}" "${plugin_path}" || return 1
fi

local bundle_path="${APP_PROJECT_ROOT_DIR}/build/linux/x64/release/bundle/lib"
if [[ -d "$(dirname "${bundle_path}")" ]]; then
copy_isar_lib "${lib_src}" "${bundle_path}" || return 1
fi
}
18 changes: 18 additions & 0 deletions scripts/app_config/templates/pubspec.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ dependency_overrides:
pinenacl: ^0.6.0
http: ^0.13.0

# %%ENABLE_ISAR%%
# isar_community:
# git:
# url: https://github.com/isar-community/isar-community.git
# path: packages/isar_community
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
# isar_community_flutter_libs:
# git:
# url: https://github.com/isar-community/isar-community.git
# path: packages/isar_community_flutter_libs
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
# isar_community_generator:
# git:
# url: https://github.com/isar-community/isar-community.git
# path: packages/isar_community_generator
# ref: 39ea19ff035518aef4d0e776206d96a428f57789
# %%END_ENABLE_ISAR%%

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down
8 changes: 6 additions & 2 deletions scripts/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ APP_NAMED_IDS=("stack_wallet" "stack_duo" "campfire")

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

Expand All @@ -33,15 +33,17 @@ unset -v APP_NAMED_ID

# optional args (with defaults)
BUILD_CRYPTO_PLUGINS=0
BUILD_ISAR_FROM_SOURCE=0

# Parse command-line arguments.
while getopts "v:b:p:a:i" opt; do
while getopts "v:b:p:a:i:f" opt; do
case "${opt}" in
v) APP_VERSION_STRING="$OPTARG" ;;
b) APP_BUILD_NUMBER="$OPTARG" ;;
p) APP_BUILD_PLATFORM="$OPTARG" ;;
a) APP_NAMED_ID="$OPTARG" ;;
i) BUILD_CRYPTO_PLUGINS=1 ;;
f) BUILD_ISAR_FROM_SOURCE=1 ;;
*) usage ;;
esac
done
Expand Down Expand Up @@ -71,6 +73,8 @@ set -x

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

export BUILD_ISAR_FROM_SOURCE

# checks for the correct platform dir and pushes it for later
if printf '%s\0' "${APP_PLATFORMS[@]}" | grep -Fxqz -- "${APP_BUILD_PLATFORM}"; then
pushd "${APP_PROJECT_ROOT_DIR}/scripts/${APP_BUILD_PLATFORM}"
Expand Down
Loading