Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/buid_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
4 changes: 2 additions & 2 deletions docs/turbo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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.
4 changes: 3 additions & 1 deletion src/Turbo/EcsGoBinaryLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/Turbo/EcsGoBinaryLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading