Skip to content

Commit

Permalink
Add libpluto
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Dec 30, 2023
1 parent 65c8626 commit 6ce1405
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
48 changes: 48 additions & 0 deletions build/libpluto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
$clang = "em++ -O3 -flto -std=c++17 -fvisibility=hidden -D PLUTO_ILP_ENABLE -D PLUTO_USE_SOUP -DPLUTO_C_LINKAGE";

// Setup folders
if(!is_dir("bin"))
{
mkdir("bin");
}
if(!is_dir("bin/int"))
{
mkdir("bin/int");
}

// Find work
$files = [];
foreach(scandir("src/vendor/Soup/soup") as $file)
{
if(substr($file, -4) == ".cpp")
{
$name = substr($file, 0, -4);
array_push($files, "vendor/Soup/soup/".$name);
}
}
foreach(scandir("src") as $file)
{
if(substr($file, -4) == ".cpp")
{
$name = substr($file, 0, -4);
if($name != "lua" && $name != "luac")
{
array_push($files, $name);
}
}
}

echo "Compiling...\n";
$objects = [];
foreach($files as $file)
{
echo $file."\n";
passthru("$clang -c src/$file.cpp -o bin/int/".basename($file).".o");
array_push($objects, escapeshellarg("bin/int/".basename($file).".o"));
}

echo "Linking...\n";
$clang .= " -s WASM=1 -s MODULARIZE=1 -s EXPORT_NAME=pluto -s EXPORTED_RUNTIME_METHODS=[\"FS\",\"cwrap\"] -s FS_DEBUG=1";
$clang .= " -s LINKABLE=1 -s EXPORT_ALL=1";
passthru("$clang -o libpluto.js ".join(" ", $objects));
1 change: 1 addition & 0 deletions common.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
$repos = [
"pluto" => "https://github.com/PlutoLang/Pluto",
"libpluto" => "https://github.com/PlutoLang/Pluto",
"lua" => "https://github.com/lua/lua",
];
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
passthru("cd repos/".$repo." && php ../../build/".$repo.".php");

// Deploy
mkdir("out/".$repo);
mkdir("out/".$repo."/".$tag);
copy("repos/".$repo."/".$repo.".js", "out/".$repo."/".$tag."/".$repo.".js");
copy("repos/".$repo."/".$repo.".wasm", "out/".$repo."/".$tag."/".$repo.".wasm");
Expand Down
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"0.7.4": "https://wasm.pluto.do/out/pluto/0.7.4/pluto.js",
"0.8.0": "https://wasm.pluto.do/out/pluto/0.8.0/pluto.js"
},
"libpluto": {
"0.8.0": "https://wasm.pluto.do/out/libpluto/0.8.0/libpluto.js"
},
"lua": {
"5.1.1": "https://wasm.pluto.do/out/lua/v5.1.1/lua.js",
"5.2.3": "https://wasm.pluto.do/out/lua/v5.2.3/lua.js",
Expand Down
21 changes: 21 additions & 0 deletions out/libpluto/0.8.0/libpluto.js

Large diffs are not rendered by default.

Binary file added out/libpluto/0.8.0/libpluto.wasm
Binary file not shown.

0 comments on commit 6ce1405

Please sign in to comment.