mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
34 lines
789 B
PHP
34 lines
789 B
PHP
<?php
|
|
require_once "vendor/autoload.php";
|
|
|
|
$search_path = array(__DIR__, "/usr/local/lib", "/usr/lib", getenv("HOME")."/.local");
|
|
|
|
function generate($paths) {
|
|
for ($i = 0; $i < count($paths); $i++) {
|
|
try {
|
|
(new FFIMe\FFIMe("libextism.".soext()))
|
|
->include("extism.h")
|
|
->codeGen('Extism', 'Extism.php');
|
|
} catch (Exception $e) {
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
function soext() {
|
|
$platform = php_uname("s");
|
|
switch ($platform) {
|
|
case "Darwin":
|
|
return "dylib";
|
|
case "Linux":
|
|
return "so";
|
|
case "Windows":
|
|
return "dll";
|
|
default:
|
|
throw new Exeception("Extism: unsupported platform ".$patform);
|
|
}
|
|
}
|
|
|
|
generate($search_path);
|
|
|