mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Add watcher
This commit is contained in:
parent
b6d8bf5639
commit
ca9dc25f9a
15
config/pkg/lib/watcher.yml
Normal file
15
config/pkg/lib/watcher.yml
Normal file
@ -0,0 +1,15 @@
|
||||
watcher:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: ghtar
|
||||
repo: e-dant/watcher
|
||||
prefer-stable: true
|
||||
metadata:
|
||||
license-files: [license]
|
||||
license: MIT
|
||||
headers:
|
||||
- wtr/watcher-c.h
|
||||
lang: cpp
|
||||
static-libs@unix:
|
||||
- libwatcher-c.a
|
||||
32
src/Package/Library/watcher.php
Normal file
32
src/Package/Library/watcher.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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';
|
||||
}
|
||||
$ldflags = $this->getLibExtraLdFlags() ? ' ' . $this->getLibExtraLdFlags() : '';
|
||||
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}{$ldflags}")
|
||||
->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");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user