Files
static-php-cli/src/Package/Library/watcher.php
henderkes 0807e9e253 watcher: drop ldflags from compile-only invocation
The shell invocation runs `$CXX -c` to compile watcher-c.cpp to a .o,
which never links. Passing linker flags to a compile-only step is
either ignored or, with some flags, an error. Drop them.
2026-05-24 20:54:44 +07:00

32 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Util\FileSystem;
#[Library('watcher')]
class watcher extends LibraryPackage
{
#[BuildFor('Darwin')]
#[BuildFor('Linux')]
public function build(): void
{
$cflags = $this->getLibExtraCXXFlags();
if (stripos($cflags, '-fpic') === false) {
$cflags .= ' -fPIC';
}
shell()->cd("{$this->getSourceDir()}/watcher-c")
->exec(getenv('CXX') . " -c -o libwatcher-c.o ./src/watcher-c.cpp -I ./include -I ../include -std=c++17 -Wall -Wextra {$cflags}")
->exec(getenv('AR') . ' rcs libwatcher-c.a libwatcher-c.o');
copy("{$this->getSourceDir()}/watcher-c/libwatcher-c.a", "{$this->getLibDir()}/libwatcher-c.a");
FileSystem::createDir("{$this->getIncludeDir()}/wtr");
copy("{$this->getSourceDir()}/watcher-c/include/wtr/watcher-c.h", "{$this->getIncludeDir()}/wtr/watcher-c.h");
}
}