Skip to content

build with Zstandard >= 1.5.7 #41

@lazarusA

Description

@lazarusA
# Versions
ZSTD_VERSION="1.5.7"
# others...

# Download URLs
ZSTD_URL="https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz"

# Build Zstandard
log "Starting Zstandard build process..."
ZSTD_VERSION="1.5.7"
if [ ! -f "$INSTALL_DIR/lib/libzstd.a" ]; then
    log "Zstandard not found, building from source..."
    cd "$DEPS_DIR"
    log "Changed to deps directory: $(pwd)"
    
    if [ ! -d "zstd-$ZSTD_VERSION" ]; then
        log "Downloading Zstandard-$ZSTD_VERSION..."
        
        ZSTD_URL="https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz"
        
        if command -v wget &> /dev/null; then
            log "Using wget to download Zstandard..."
            check_command wget -v "$ZSTD_URL" -O "zstd-$ZSTD_VERSION.tar.gz"
        elif command -v curl &> /dev/null; then
            log "Using curl to download Zstandard..."
            check_command curl -L "$ZSTD_URL" -o "zstd-$ZSTD_VERSION.tar.gz"
        else
            error_exit "Neither wget nor curl available for downloading"
        fi
        
        log "Extracting Zstandard archive..."
        check_command tar -xzf "zstd-$ZSTD_VERSION.tar.gz"
        log "Zstandard extracted successfully"
    else
        log "Zstandard source directory already exists"
    fi
    
    cd "zstd-$ZSTD_VERSION/lib"
    log "Building Zstandard in directory: $(pwd)"
    
    # Build only the library with Emscripten
    log "Building Zstandard library with emmake..."
    check_command emmake make -j1 CC=emcc AR=emar ARFLAGS=rcs libzstd.a
    
    log "Installing Zstandard..."
    check_command cp libzstd.a "$INSTALL_DIR/lib/"
    check_command cp zstd.h zdict.h zstd_errors.h "$INSTALL_DIR/include/"
    
    log "Zstandard built and installed successfully"
    
    # Verify installation
    if [ -f "$INSTALL_DIR/lib/libzstd.a" ]; then
        log "Zstandard library verified at $INSTALL_DIR/lib/libzstd.a"
    else
        error_exit "Zstandard library not found after installation"
    fi
else
    log "Zstandard already built and installed"
fi

# and maybe with
-DHDF5_C_LIBRARY="$INSTALL_DIR/lib/libhdf5.a;$INSTALL_DIR/lib/libz.a;$INSTALL_DIR/lib/libzstd.a" \
-DHDF5_C_LIBRARY_hdf5="$INSTALL_DIR/lib/libhdf5.a" \
-DHDF5_HL_LIBRARY="$INSTALL_DIR/lib/libhdf5_hl.a;$INSTALL_DIR/lib/libz.a;$INSTALL_DIR/lib/libzstd.a" \

needed in EarthyScience/Browzarr#549

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions