From 98a802552b365c2d2a4b81736396d0bb179e9583 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Sat, 16 Aug 2025 09:34:57 -0400 Subject: [PATCH] Fix build script path resolution for customer Makefile usage - Added BUILD_DIR=/home/teknari/Sync/Programming/VibeCoding/nostr_core_lib to capture absolute build directory - Changed relative paths to absolute paths in archive extraction - Fixes 'No such file or directory' error when build.sh is called from customer Makefiles - Maintains backward compatibility for all existing use cases --- build.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 6134d430..43b7fc8d 100755 --- a/build.sh +++ b/build.sh @@ -146,6 +146,27 @@ if [ "$HELP" = true ]; then fi print_info "NOSTR Core Library - Customer Build Script" + +# Check if we're running from the correct directory +if [ ! -d "nostr_core" ] || [ ! -f "nostr_core/utils.c" ] || [ ! -d "secp256k1" ]; then + print_error "Build script must be run from the nostr_core_lib directory" + echo "" + echo "It looks like you're trying to run this script from your project directory." + echo "Please change to the nostr_core_lib directory first, then run the build script." + echo "" + echo "Correct usage:" + echo " cd nostr_core_lib" + echo " ./build.sh" + echo "" + echo "Or if nostr_core_lib is in your project directory:" + echo " cd nostr_core_lib" + echo " ./build.sh" + echo " cd .." + echo " gcc your_app.c nostr_core_lib/libnostr_core_x64.a -lz -ldl -lpthread -lm -o your_app" + echo "" + exit 1 +fi + print_info "Auto-detecting needed NIPs from your source code..." @@ -367,6 +388,9 @@ done ########################################################################################### print_info "Creating self-contained static library: $OUTPUT" +# Store the build directory to ensure correct paths when extracting from subdirectories +BUILD_DIR=$(pwd) + # Create temporary directories for extracting objects TMP_SECP256K1=".tmp_secp256k1_$$" TMP_OPENSSL=".tmp_openssl_$$" @@ -379,21 +403,21 @@ if [ -f "$SECP256K1_LIB" ]; then if [ "$VERBOSE" = true ]; then print_info "Extracting secp256k1 objects..." fi - (cd "$TMP_SECP256K1" && ar x "../$SECP256K1_LIB") + (cd "$TMP_SECP256K1" && ar x "$BUILD_DIR/$SECP256K1_LIB") fi # Extract OpenSSL objects if [ "$VERBOSE" = true ]; then print_info "Extracting OpenSSL objects..." fi -(cd "$TMP_OPENSSL" && ar x "../openssl-install/lib64/libssl.a") -(cd "$TMP_OPENSSL" && ar x "../openssl-install/lib64/libcrypto.a") +(cd "$TMP_OPENSSL" && ar x "$BUILD_DIR/openssl-install/lib64/libssl.a") +(cd "$TMP_OPENSSL" && ar x "$BUILD_DIR/openssl-install/lib64/libcrypto.a") # Extract curl objects if [ "$VERBOSE" = true ]; then print_info "Extracting curl objects..." fi -(cd "$TMP_CURL" && ar x "../curl-install/lib/libcurl.a") +(cd "$TMP_CURL" && ar x "$BUILD_DIR/curl-install/lib/libcurl.a") # Combine all objects into final library if [ "$VERBOSE" = true ]; then