Skip to content

Commit 27f57cc

Browse files
committed
fix zig runtime
1 parent f6c6011 commit 27f57cc

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/SPC/store/scripts/zig-cc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ done
3737
TARGET=""
3838
if [ -n "$SPC_TARGET" ]; then
3939
TARGET="-target $SPC_TARGET"
40-
else
40+
fi
4141

4242
output=$(zig cc $TARGET -lstdc++ $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
4343
status=$?

src/SPC/toolchain/ZigToolchain.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ public function afterInit(): void
3030
if (!is_dir(Zig::getEnvironment()['PATH'])) {
3131
throw new WrongUsageException('You are building with zig, but zig is not installed, please install zig first. (You can use `doctor` command to install it)');
3232
}
33+
GlobalEnvManager::addPathIfNotExists(Zig::getEnvironment()['PATH']);
3334
}
3435
}

src/SPC/util/SPCTarget.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ public static function getTargetOS(): string
9696
if ($target === false) {
9797
return PHP_OS_FAMILY;
9898
}
99-
// TODO: zig target parser like below?
10099
return match (true) {
101-
str_contains($target, 'linux') => 'Linux',
102-
str_contains($target, 'macos') => 'Darwin',
103-
str_contains($target, 'windows') => 'Windows',
100+
str_contains($target, '-linux') => 'Linux',
101+
str_contains($target, '-macos') => 'Darwin',
102+
str_contains($target, '-windows') => 'Windows',
103+
str_contains($target, '-native') => PHP_OS_FAMILY,
104104
default => throw new WrongUsageException('Cannot parse target.'),
105105
};
106106
}

0 commit comments

Comments
 (0)