File size: 2,225 Bytes
a4b70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Nuitka build script for g4f
# This script builds g4f executables using Nuitka for different platforms and architectures

set -e

# Default values
PLATFORM=${PLATFORM:-$(uname -s | tr '[:upper:]' '[:lower:]')}
ARCHITECTURE=${ARCHITECTURE:-$(uname -m)}
VERSION=${G4F_VERSION:-0.0.0-dev}
OUTPUT_DIR=${OUTPUT_DIR:-dist}

# Normalize architecture names
case "${ARCHITECTURE}" in
    "x86_64"|"amd64")
        ARCH="x64"
        ;;
    "arm64"|"aarch64")
        ARCH="arm64"
        ;;
    "armv7l"|"armhf")
        ARCH="armv7"
        ;;
    *)
        ARCH="${ARCHITECTURE}"
        ;;
esac

# Create output directory
mkdir -p "${OUTPUT_DIR}"

echo "Building g4f with Nuitka..."
echo "Platform: ${PLATFORM}"
echo "Architecture: ${ARCH} (${ARCHITECTURE})"
echo "Version: ${VERSION}"
echo "Output: ${OUTPUT_DIR}"

# Set output filename based on platform
case "${PLATFORM}" in
    "windows"|"win32")
        OUTPUT_NAME="g4f-windows-${VERSION}-${ARCH}.exe"
        NUITKA_ARGS="--windows-console-mode=attach --onefile"
        ;;
    "darwin"|"macos")
        OUTPUT_NAME="g4f-macos-${VERSION}-${ARCH}"
        NUITKA_ARGS="--macos-create-app-bundle --onefile"
        ;;
    "linux")
        OUTPUT_NAME="g4f-linux-${VERSION}-${ARCH}"
        NUITKA_ARGS="--onefile"
        ;;
    *)
        OUTPUT_NAME="g4f-${PLATFORM}-${VERSION}-${ARCH}"
        NUITKA_ARGS="--onefile"
        ;;
esac

# Basic Nuitka arguments
NUITKA_COMMON_ARGS="
    --standalone
    --output-filename=${OUTPUT_NAME}
    --output-dir=${OUTPUT_DIR}
    --remove-output
    --no-pyi-file
    --assume-yes-for-downloads
    --show-progress
    --show-memory
"

# Platform-specific optimizations
if [[ "${PLATFORM}" == "windows" ]] && [[ -f "projects/windows/icon.ico" ]]; then
    NUITKA_ARGS="${NUITKA_ARGS} --windows-icon-from-ico=projects/windows/icon.ico"
fi

# Build command
echo "Running Nuitka build..."
python -m nuitka ${NUITKA_COMMON_ARGS} ${NUITKA_ARGS} g4f_cli.py

echo "Build completed: ${OUTPUT_DIR}/${OUTPUT_NAME}"

# Verify the build
if [[ -f "${OUTPUT_DIR}/${OUTPUT_NAME}" ]]; then
    echo "βœ“ Build successful!"
    ls -la "${OUTPUT_DIR}/${OUTPUT_NAME}"
else
    echo "βœ— Build failed - output file not found"
    exit 1
fi