mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 21:04:52 +08:00
use extra COMPILER_EXTRA env variable to make sure it's actually passed to compiler
This commit is contained in:
parent
aa516522aa
commit
61274cb865
@ -16,20 +16,14 @@ trait libaom
|
|||||||
*/
|
*/
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
$cc = getenv('CC');
|
if (getenv('SPC_LIBC') === 'musl' && str_contains(getenv('CC'), 'zig')) {
|
||||||
$cxx = getenv('CXX');
|
f_putenv('COMPILER_EXTRA=-D_POSIX_SOURCE');
|
||||||
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
|
|
||||||
f_putenv('CC=' . $cc . ' -D_POSIX_SOURCE');
|
|
||||||
f_putenv('CXX=' . $cxx . ' -D_POSIX_SOURCE');
|
|
||||||
}
|
}
|
||||||
UnixCMakeExecutor::create($this)
|
UnixCMakeExecutor::create($this)
|
||||||
->setBuildDir("{$this->source_dir}/builddir")
|
->setBuildDir("{$this->source_dir}/builddir")
|
||||||
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
|
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
|
||||||
->build();
|
->build();
|
||||||
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
|
f_putenv('COMPILER_EXTRA');
|
||||||
f_putenv('CC=' . $cc);
|
|
||||||
f_putenv('CXX=' . $cxx);
|
|
||||||
}
|
|
||||||
$this->patchPkgconfPrefix(['aom.pc']);
|
$this->patchPkgconfPrefix(['aom.pc']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,38 +61,33 @@ if [ "$SPC_LIBC" = "glibc" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
|
if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
|
||||||
exec zig cc "${PARSED_ARGS[@]}"
|
exec zig cc "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
|
||||||
elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
|
elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
|
||||||
exec zig cc -target ${SPC_TARGET} "${PARSED_ARGS[@]}"
|
exec zig cc -target "${SPC_TARGET}" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
|
||||||
else
|
else
|
||||||
TARGET="${SPC_TARGET}-${SPC_LIBC}"
|
TARGET="${SPC_TARGET}-${SPC_LIBC}"
|
||||||
[ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}"
|
[ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}"
|
||||||
|
|
||||||
output=$(zig cc -target "$TARGET" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
|
output=$(zig cc -target "$TARGET" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
|
|
||||||
|
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
echo "$filtered_output"
|
echo "$output" | grep -v "version '.*' in target triple"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$output" | grep -q "version '.*' in target triple"; then
|
if echo "$output" | grep -q "version '.*' in target triple"; then
|
||||||
TARGET_FALLBACK="${SPC_TARGET}-${SPC_LIBC}"
|
TARGET_FALLBACK="${SPC_TARGET}-${SPC_LIBC}"
|
||||||
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
|
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
|
|
||||||
|
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
echo "$filtered_output"
|
echo "$output"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
exec zig cc -target "$TARGET_FALLBACK" "${PARSED_ARGS[@]}"
|
exec zig cc -target "$TARGET_FALLBACK" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$filtered_output"
|
exec zig cc -target "$TARGET" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
|
||||||
exec zig cc -target "$TARGET" "${PARSED_ARGS[@]}"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user