-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild_lib.php
49 lines (43 loc) · 1.03 KB
/
build_lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
require "build_common.php";
$cd = getcwd();
chdir(__DIR__);
// Setup folders
if(!is_dir(__DIR__."/bin"))
{
mkdir(__DIR__."/bin");
}
if(!is_dir(__DIR__."/bin/int"))
{
mkdir(__DIR__."/bin/int");
}
echo "Compiling...\n";
$files = [];
$objects = [];
foreach(scandir(__DIR__."/soup") as $file)
{
if(substr($file, -4) == ".cpp")
{
$file = substr($file, 0, -4);
run_command_async("$clang -c ".__DIR__."/soup/$file.cpp -o ".__DIR__."/bin/int/$file.o -DSOUP_STANDALONE");
if ($file != "soup")
{
array_push($objects, escapeshellarg("bin/int/$file.o"));
}
}
}
await_commands();
echo "Bundling static lib...\n";
$archiver = "ar";
$libname = "libsoup.a";
$dllname = "libsoupbindings.so";
if (defined("PHP_WINDOWS_VERSION_MAJOR"))
{
$archiver = "llvm-ar";
$libname = "soup.lib";
$dllname = "soupbindings.dll";
}
passthru("$archiver rc $libname ".join(" ", $objects));
echo "Linking shared lib...\n";
passthru("$clang -o $dllname --shared bin/int/soup.o ".join(" ", $objects));
chdir($cd);