diff --git a/.github/workflows/buid_release.yaml b/.github/workflows/buid_release.yaml index 4a9a6d3364..fe580dd06d 100644 --- a/.github/workflows/buid_release.yaml +++ b/.github/workflows/buid_release.yaml @@ -101,8 +101,10 @@ jobs: git clone --depth 1 https://github.com/TomasVotruba/ecs-go.git ecs-go-local mkdir -p ecs-prefixed-downgraded/bin/turbo - for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do - (cd ecs-go-local/ecs-go && CGO_ENABLED=0 GOOS=${target%/*} GOARCH=${target#*/} go build -trimpath -ldflags="-s -w" -o "$GITHUB_WORKSPACE/ecs-prefixed-downgraded/bin/turbo/ecs-go-${target%/*}-${target#*/}" .) + for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do + suffix="" + if [ "${target%/*}" = "windows" ]; then suffix=".exe"; fi + (cd ecs-go-local/ecs-go && CGO_ENABLED=0 GOOS=${target%/*} GOARCH=${target#*/} go build -trimpath -ldflags="-s -w" -o "$GITHUB_WORKSPACE/ecs-prefixed-downgraded/bin/turbo/ecs-go-${target%/*}-${target#*/}${suffix}" .) done chmod 755 ecs-prefixed-downgraded/bin/turbo/* diff --git a/docs/turbo.md b/docs/turbo.md index cf60bf1d5f..e8fefabae6 100644 --- a/docs/turbo.md +++ b/docs/turbo.md @@ -49,7 +49,7 @@ Configured fixer options are read off the fixer instance; sniff properties are n The ecs-go binary is looked up in this order: 1. the `ECS_TURBO_BIN` environment variable, if it points to an existing file; -2. the binary bundled with ECS in `bin/turbo/` (Linux and macOS, amd64 and arm64); +2. the binary bundled with ECS in `bin/turbo/` (Linux, macOS and Windows, amd64 and arm64); 3. `vendor/bin/ecs-go`, if present; 4. `ecs-go` on the `PATH`. @@ -61,4 +61,4 @@ This is an RFC-stage prototype. ecs-go reads the rules and skips from your `ecs. ## Bundled binary -The release build cross-compiles ecs-go from its `main` branch and ships it in `bin/turbo/`, so `--turbo` works out of the box on Linux and macOS - no Go toolchain needed. Windows is not bundled yet, as ecs-go does not build there; use `ECS_TURBO_BIN` or WSL. +The release build cross-compiles ecs-go from its `main` branch and ships it in `bin/turbo/`, so `--turbo` works out of the box on Linux, macOS and Windows - no Go toolchain needed. diff --git a/src/Turbo/EcsGoBinaryLocator.php b/src/Turbo/EcsGoBinaryLocator.php index f9f6fd4742..63151e8a64 100644 --- a/src/Turbo/EcsGoBinaryLocator.php +++ b/src/Turbo/EcsGoBinaryLocator.php @@ -60,7 +60,9 @@ private function resolvePlatform(): string $machine = strtolower(php_uname('m')); $arch = in_array($machine, ['aarch64', 'arm64'], true) ? 'arm64' : 'amd64'; - return strtolower(PHP_OS_FAMILY) . '-' . $arch; + $suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : ''; + + return strtolower(PHP_OS_FAMILY) . '-' . $arch . $suffix; } private function findOnPath(string $binaryName): ?string diff --git a/tests/Turbo/EcsGoBinaryLocatorTest.php b/tests/Turbo/EcsGoBinaryLocatorTest.php index b4c4ff9643..409945c96b 100644 --- a/tests/Turbo/EcsGoBinaryLocatorTest.php +++ b/tests/Turbo/EcsGoBinaryLocatorTest.php @@ -34,7 +34,8 @@ public function testBundledBinaryWinsOverPath(): void mkdir($bundledDirectory); $arch = in_array(strtolower(php_uname('m')), ['aarch64', 'arm64'], true) ? 'arm64' : 'amd64'; - $bundledBinary = $bundledDirectory . '/ecs-go-' . strtolower(PHP_OS_FAMILY) . '-' . $arch; + $suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : ''; + $bundledBinary = $bundledDirectory . '/ecs-go-' . strtolower(PHP_OS_FAMILY) . '-' . $arch . $suffix; touch($bundledBinary); $ecsGoBinaryLocator = new EcsGoBinaryLocator($bundledDirectory);