add edant/watcher, to make spc-packages easier

This commit is contained in:
DubbleClick 2025-06-13 22:51:35 +07:00
parent b265d6dd56
commit 962de5b25f
6 changed files with 82 additions and 0 deletions

View File

@ -854,5 +854,14 @@
"zstd.h",
"zstd_errors.h"
]
},
"watcher": {
"source": "watcher",
"static-libs-unix": [
"libwatcher-c.a"
],
"headers": [
"wtr/watcher-c.h"
]
}
}

View File

@ -1070,5 +1070,14 @@
"type": "file",
"path": "LICENSE"
}
},
"watcher": {
"type": "ghtar",
"repo": "e-dant/watcher",
"prefer-stable": true,
"license": {
"type": "file",
"path": "license"
}
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd\library;
class watcher extends BSDLibraryBase
{
use \SPC\builder\unix\library\watcher;
public const NAME = 'watcher';
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class watcher extends LinuxLibraryBase
{
use \SPC\builder\unix\library\watcher;
public const NAME = 'watcher';
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class watcher extends MacOSLibraryBase
{
use \SPC\builder\unix\library\watcher;
public const NAME = 'watcher';
}

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait watcher
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
shell()->cd($this->source_dir . '/watcher-c')
->initializeEnv($this)
->exec(getenv('CC') . ' -c -o libwatcher-c.o ./src/watcher-c.cpp -I ./include -I ../include -std=c++17 -Wall -Wextra -fPIC')
->exec(getenv('AR') . ' rcs libwatcher-c.a libwatcher-c.o');
copy($this->source_dir . '/watcher-c/libwatcher-c.a', BUILD_LIB_PATH . '/libwatcher-c.a');
FileSystem::createDir(BUILD_INCLUDE_PATH . '/wtr');
copy($this->source_dir . '/watcher-c/include/wtr/watcher-c.h', BUILD_INCLUDE_PATH . '/wtr/watcher-c.h');
}
}