Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: goose windows (highly WIP) #880

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
14 changes: 12 additions & 2 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
operating-systems:
type: string
required: false
default: '["ubuntu-latest","macos-latest"]'
default: '["ubuntu-latest","macos-latest","windows-latest"]'
architectures:
type: string
required: false
Expand All @@ -36,6 +36,8 @@ jobs:
target-suffix: unknown-linux-gnu
- os: macos-latest
target-suffix: apple-darwin
- os: windows-latest
target-suffix: pc-windows-gnu

steps:
- name: Checkout code
Expand All @@ -58,12 +60,20 @@ jobs:
- name: Build CLI
env:
CROSS_NO_WARNINGS: 0
RUST_LOG: debug
RUST_BACKTRACE: 1
CROSS_VERBOSE: 1
run: |
export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}"
rustup target add "${TARGET}"
echo "Building for target: ${TARGET}"
echo "Rust toolchain info:"
rustup show
echo "Cross version:"
cross --version

# 'cross' is used to cross-compile for different architectures (see Cross.toml)
cross build --release --target ${TARGET} -p goose-cli
cross build --release --target ${TARGET} -p goose-cli -vv

# tar the goose binary as goose-<TARGET>.tar.bz2
cd target/${TARGET}/release
Expand Down
7 changes: 6 additions & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pre-build = [
libxcb1-dev:arm64
"""
]
env = { PKG_CONFIG_PATH = "/usr/lib/aarch64-linux-gnu/pkgconfig" }

[target.x86_64-unknown-linux-gnu]
xargo = false
Expand All @@ -27,3 +26,9 @@ pre-build = [
libxcb1-dev \
"""
]

[target.x86_64-pc-windows-gnu]
image = "dockcross/windows-static-x64:latest"
# Enable verbose output for Windows builds
build-std = true
env = { "RUST_LOG" = "debug", "RUST_BACKTRACE" = "1", "CROSS_VERBOSE" = "1" }
60 changes: 59 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ release:
cargo build --release
@just copy-binary

# Build Windows executable
release-windows:
#!/usr/bin/env sh
if [ "$(uname)" = "Darwin" ] || [ "$(uname)" = "Linux" ]; then
echo "Building Windows executable using Docker..."
docker run --rm -v "$(pwd)":/usr/src/myapp -w /usr/src/myapp \
rust:latest \
sh -c "rustup target add x86_64-pc-windows-gnu && \
apt-get update && \
apt-get install -y mingw-w64 && \
cargo build --release --target x86_64-pc-windows-gnu && \
cp /usr/lib/gcc/x86_64-w64-mingw32/*/libstdc++-6.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \
cp /usr/lib/gcc/x86_64-w64-mingw32/*/libgcc_s_seh-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/"
else
echo "Building Windows executable natively..."
powershell.exe -Command "docker run --rm -v ${PWD}:/usr/src/myapp -w /usr/src/myapp rust:latest sh -c 'rustup target add x86_64-pc-windows-gnu && apt-get update && apt-get install -y mingw-w64 && cargo build --release --target x86_64-pc-windows-gnu && cp /usr/lib/gcc/x86_64-w64-mingw32/*/libstdc++-6.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && cp /usr/lib/gcc/x86_64-w64-mingw32/*/libgcc_s_seh-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/'"
fi
echo "Windows executable and required DLLs created at ./target/x86_64-pc-windows-gnu/release/"

# Copy binary command
copy-binary:
@if [ -f ./target/release/goosed ]; then \
Expand All @@ -16,12 +36,30 @@ copy-binary:
exit 1; \
fi

# Copy Windows binary command
copy-binary-windows:
@powershell.exe -Command "if (Test-Path ./target/x86_64-pc-windows-gnu/release/goosed.exe) { \
Write-Host 'Copying Windows binary and DLLs to ui/desktop/src/bin...'; \
Copy-Item -Path './target/x86_64-pc-windows-gnu/release/goosed.exe' -Destination './ui/desktop/src/bin/' -Force; \
Copy-Item -Path './target/x86_64-pc-windows-gnu/release/*.dll' -Destination './ui/desktop/src/bin/' -Force; \
} else { \
Write-Host 'Windows binary not found.' -ForegroundColor Red; \
exit 1; \
}"

# Run UI with latest
run-ui:
@just release
@echo "Running UI..."
cd ui/desktop && npm install && npm run start-gui

# Run UI with latest (Windows version)
run-ui-windows:
@just release-windows
@powershell.exe -Command "Write-Host 'Copying Windows binary...'"
@just copy-binary-windows
@powershell.exe -Command "Write-Host 'Running UI...'; Set-Location ui/desktop; npm install; npm run start-gui"

# Run Docusaurus server for documentation
run-docs:
@echo "Running docs server..."
Expand All @@ -37,7 +75,27 @@ make-ui:
@just release
cd ui/desktop && npm run bundle:default

# make GUI with latest Windows binary
make-ui-windows:
@just release-windows
#!/usr/bin/env sh
if [ -f "./target/x86_64-pc-windows-gnu/release/goosed.exe" ]; then \
echo "Copying Windows binary and DLLs to ui/desktop/src/bin..."; \
mkdir -p ./ui/desktop/src/bin; \
cp -f ./target/x86_64-pc-windows-gnu/release/goosed.exe ./ui/desktop/src/bin/; \
cp -f ./target/x86_64-pc-windows-gnu/release/*.dll ./ui/desktop/src/bin/; \
echo "Building Windows package..."; \
cd ui/desktop && \
npm run bundle:windows && \
mkdir -p out/Goose-win32-x64/resources/bin && \
cp -f src/bin/goosed.exe out/Goose-win32-x64/resources/bin/ && \
cp -f src/bin/*.dll out/Goose-win32-x64/resources/bin/; \
else \
echo "Windows binary not found."; \
exit 1; \
fi

# Setup langfuse server
langfuse-server:
#!/usr/bin/env bash
./scripts/setup_langfuse.sh
./scripts/setup_langfuse.sh
4 changes: 4 additions & 0 deletions crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ tracing = "0.1"
chrono = "0.4"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json", "time"] }
tracing-appender = "0.2"
winapi = { version = "0.3", features = ["wincred"], optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["wincred"] }

[dev-dependencies]
tempfile = "3"
Expand Down
17 changes: 17 additions & 0 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,29 @@ pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
);
}
Some(ConfigError::KeyringError(msg)) => {
#[cfg(target_os = "macos")]
println!(
"\n {} Failed to access secure storage (keyring): {} \n Please check your system keychain and run '{}' again. \n If your system is unable to use the keyring, please try setting secret key(s) via environment variables.",
style("Error").red().italic(),
msg,
style("goose configure").cyan()
);

#[cfg(target_os = "windows")]
println!(
"\n {} Failed to access Windows Credential Manager: {} \n Please check Windows Credential Manager and run '{}' again. \n If your system is unable to use the Credential Manager, please try setting secret key(s) via environment variables.",
style("Error").red().italic(),
msg,
style("goose configure").cyan()
);

#[cfg(not(any(target_os = "macos", target_os = "windows")))]
println!(
"\n {} Failed to access secure storage: {} \n Please check your system's secure storage and run '{}' again. \n If your system is unable to use secure storage, please try setting secret key(s) via environment variables.",
style("Error").red().italic(),
msg,
style("goose configure").cyan()
);
}
Some(ConfigError::DeserializeError(msg)) => {
println!(
Expand Down
Loading
Loading