Merge branch 'build-improvement' into performance-optimizations-testing
This commit is contained in:
@@ -60,12 +60,16 @@ SYNC_ONLY=false
|
||||
ASSETS_ONLY=false
|
||||
DEPLOY_APP=false
|
||||
AUTO_RUN=false
|
||||
CUSTOM_API_IP=""
|
||||
|
||||
# Function to parse Android-specific arguments
|
||||
parse_android_args() {
|
||||
local args=("$@")
|
||||
local i=0
|
||||
|
||||
for arg in "${args[@]}"; do
|
||||
while [ $i -lt ${#args[@]} ]; do
|
||||
local arg="${args[$i]}"
|
||||
|
||||
case $arg in
|
||||
--dev|--development)
|
||||
BUILD_MODE="development"
|
||||
@@ -106,6 +110,18 @@ parse_android_args() {
|
||||
--auto-run)
|
||||
AUTO_RUN=true
|
||||
;;
|
||||
--api-ip)
|
||||
if [ $((i + 1)) -lt ${#args[@]} ]; then
|
||||
CUSTOM_API_IP="${args[$((i + 1))]}"
|
||||
i=$((i + 1)) # Skip the next argument
|
||||
else
|
||||
log_error "Error: --api-ip requires an IP address"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--api-ip=*)
|
||||
CUSTOM_API_IP="${arg#*=}"
|
||||
;;
|
||||
-h|--help)
|
||||
print_android_usage
|
||||
exit 0
|
||||
@@ -117,6 +133,7 @@ parse_android_args() {
|
||||
log_warn "Unknown argument: $arg"
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
@@ -138,6 +155,7 @@ print_android_usage() {
|
||||
echo " --assets Generate assets only"
|
||||
echo " --deploy Deploy APK to connected device"
|
||||
echo " --auto-run Auto-run app after build"
|
||||
echo " --api-ip <ip> Custom IP address for claim API (defaults to 10.0.2.2)"
|
||||
echo ""
|
||||
echo "Common Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
@@ -151,6 +169,8 @@ print_android_usage() {
|
||||
echo " $0 --clean # Clean only"
|
||||
echo " $0 --sync # Sync only"
|
||||
echo " $0 --deploy # Build and deploy to device"
|
||||
echo " $0 --dev # Dev build with default 10.0.2.2"
|
||||
echo " $0 --dev --api-ip 192.168.1.100 # Dev build with custom API IP"
|
||||
echo ""
|
||||
}
|
||||
|
||||
@@ -166,6 +186,21 @@ log_info "Build type: $BUILD_TYPE"
|
||||
# Setup environment for Capacitor build
|
||||
setup_build_env "capacitor"
|
||||
|
||||
# Override API servers for Android development
|
||||
if [ "$BUILD_MODE" = "development" ]; then
|
||||
if [ -n "$CUSTOM_API_IP" ]; then
|
||||
# Use custom IP for physical device development
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="http://${CUSTOM_API_IP}:3000"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="http://${CUSTOM_API_IP}:3000"
|
||||
log_info "Android development mode: Using custom IP ${CUSTOM_API_IP} for physical device"
|
||||
else
|
||||
# Use Android emulator IP (10.0.2.2) for Android development
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="http://10.0.2.2:3000"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="http://10.0.2.2:3000"
|
||||
log_debug "Android development mode: Using 10.0.2.2 for emulator"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup application directories
|
||||
setup_app_directories
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ SYNC_ONLY=false
|
||||
ASSETS_ONLY=false
|
||||
DEPLOY_APP=false
|
||||
AUTO_RUN=false
|
||||
CUSTOM_API_IP=""
|
||||
|
||||
# Function to print iOS-specific usage
|
||||
print_ios_usage() {
|
||||
@@ -41,6 +42,7 @@ print_ios_usage() {
|
||||
echo " --assets Generate assets only"
|
||||
echo " --deploy Deploy app to connected device"
|
||||
echo " --auto-run Auto-run app after build"
|
||||
echo " --api-ip <ip> Custom IP address for claim API (uses Capacitor default)"
|
||||
echo ""
|
||||
echo "Common Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
@@ -54,12 +56,19 @@ print_ios_usage() {
|
||||
echo " $0 --clean # Clean only"
|
||||
echo " $0 --sync # Sync only"
|
||||
echo " $0 --deploy # Build and deploy to device"
|
||||
echo " $0 --dev # Dev build with Capacitor default"
|
||||
echo " $0 --dev --api-ip 192.168.1.100 # Dev build with custom API IP"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to parse iOS-specific arguments
|
||||
parse_ios_args() {
|
||||
for arg in "$@"; do
|
||||
local args=("$@")
|
||||
local i=0
|
||||
|
||||
while [ $i -lt ${#args[@]} ]; do
|
||||
local arg="${args[$i]}"
|
||||
|
||||
case $arg in
|
||||
--dev|--development)
|
||||
BUILD_MODE="development"
|
||||
@@ -100,6 +109,18 @@ parse_ios_args() {
|
||||
--auto-run)
|
||||
AUTO_RUN=true
|
||||
;;
|
||||
--api-ip)
|
||||
if [ $((i + 1)) -lt ${#args[@]} ]; then
|
||||
CUSTOM_API_IP="${args[$((i + 1))]}"
|
||||
i=$((i + 1)) # Skip the next argument
|
||||
else
|
||||
log_error "Error: --api-ip requires an IP address"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--api-ip=*)
|
||||
CUSTOM_API_IP="${arg#*=}"
|
||||
;;
|
||||
-h|--help)
|
||||
print_ios_usage
|
||||
exit 0
|
||||
@@ -111,6 +132,7 @@ parse_ios_args() {
|
||||
log_warn "Unknown argument: $arg"
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
@@ -291,6 +313,14 @@ log_info "Build type: $BUILD_TYPE"
|
||||
# Setup environment for Capacitor build
|
||||
setup_build_env "capacitor"
|
||||
|
||||
# Override API servers for iOS development when custom IP is specified
|
||||
if [ "$BUILD_MODE" = "development" ] && [ -n "$CUSTOM_API_IP" ]; then
|
||||
# Use custom IP for physical device development
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="http://${CUSTOM_API_IP}:3000"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="http://${CUSTOM_API_IP}:3000"
|
||||
log_info "iOS development mode: Using custom IP ${CUSTOM_API_IP} for physical device"
|
||||
fi
|
||||
|
||||
# Setup application directories
|
||||
setup_app_directories
|
||||
|
||||
|
||||
@@ -51,10 +51,18 @@ log_step() {
|
||||
# Function to measure and log execution time
|
||||
measure_time() {
|
||||
local start_time=$(date +%s)
|
||||
"$@"
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
log_success "Completed in ${duration} seconds"
|
||||
if "$@"; then
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
log_success "Completed in ${duration} seconds"
|
||||
return 0
|
||||
else
|
||||
local exit_code=$?
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
log_error "Failed after ${duration} seconds (exit code: ${exit_code})"
|
||||
return $exit_code
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to print section headers
|
||||
@@ -197,20 +205,22 @@ setup_build_env() {
|
||||
|
||||
# Set API server environment variables based on build mode
|
||||
if [ "$BUILD_MODE" = "development" ]; then
|
||||
# For Capacitor development, use localhost by default
|
||||
# Android builds will override this in build-android.sh
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000"
|
||||
log_debug "Development mode: Using localhost for Endorser and Partner APIs"
|
||||
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
|
||||
log_debug "Development mode: Using localhost for Endorser API, production for Image/Partner APIs"
|
||||
elif [ "$BUILD_MODE" = "test" ]; then
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="https://test-api.endorser.ch"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="https://test-partner-api.endorser.ch"
|
||||
log_debug "Test mode: Using test Endorser and Partner APIs"
|
||||
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
|
||||
log_debug "Test mode: Using test Endorser API, production for Image/Partner APIs"
|
||||
elif [ "$BUILD_MODE" = "production" ]; then
|
||||
export VITE_DEFAULT_ENDORSER_API_SERVER="https://api.endorser.ch"
|
||||
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
|
||||
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
|
||||
log_debug "Production mode: Using production API servers"
|
||||
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
|
||||
fi
|
||||
|
||||
# Log environment setup
|
||||
|
||||
Reference in New Issue
Block a user