diff --git a/.github/workflows/cli.yml b/.github/workflows/build.yml similarity index 67% rename from .github/workflows/cli.yml rename to .github/workflows/build.yml index da54797d..bbb18976 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build CLI +name: Build on: push @@ -57,8 +57,11 @@ jobs: - name: Upload soup uses: actions/upload-artifact@v4 with: - name: "Debian 10 and above" - path: CLI/soup + name: "Debian 10 and above (X64)" + path: | + CLI/soup + libsoup.a + libsoup.so arm64: runs-on: [ARM64] @@ -81,7 +84,10 @@ jobs: uses: actions/upload-artifact@v4 with: name: "Debian 12 (ARM64)" - path: CLI/soup + path: | + CLI/soup + libsoup.a + libsoup.so macos-13: runs-on: macos-13 @@ -103,8 +109,11 @@ jobs: - name: Upload soup uses: actions/upload-artifact@v4 with: - name: "MacOS (X86)" - path: CLI/soup + name: "MacOS (X64)" + path: | + CLI/soup + libsoup.a + libsoup.so windows-latest: runs-on: windows-latest @@ -129,5 +138,32 @@ jobs: - name: Upload soup uses: actions/upload-artifact@v4 with: - name: "Windows" - path: CLI/soup.exe + name: "Windows (X64)" + path: | + CLI/soup.exe + soup.lib + soup.dll + + emscripten: + runs-on: ubuntu-latest + steps: + - uses: mymindstorm/setup-emsdk@v13 + + - uses: actions/checkout@v4 + + - name: Build Soup + run: php wasm.php + + - name: Ensure files exist + uses: andstor/file-existence-action@v3 + with: + files: "bindings/libsoup.js, bindings/libsoup.wasm" + fail: true + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: "WASM" + path: | + bindings/libsoup.js + bindings/libsoup.wasm diff --git a/.github/workflows/lib-wasm.yml b/.github/workflows/lib-wasm.yml deleted file mode 100644 index fd063a81..00000000 --- a/.github/workflows/lib-wasm.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build WASM library - -on: push - -jobs: - emscripten: - runs-on: ubuntu-latest - steps: - - uses: mymindstorm/setup-emsdk@v13 - - - uses: actions/checkout@v4 - - - name: Build - run: php wasm.php - - - name: Ensure files exist - uses: andstor/file-existence-action@v3 - with: - files: "bindings/libsoup.js, bindings/libsoup.wasm" - fail: true - - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: "WASM" - path: | - bindings/libsoup.js - bindings/libsoup.wasm diff --git a/README.md b/README.md index 500adaad..940069aa 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,15 @@ The everything library for C++ 17 and up. ## Building -### Windows +### Visual Studio Simply open up Soup.sln using Visual Studio 2022 and run a batch build for the Soup project to compile the static libraries, then you can use it in your own projects by adding a compiler and linker include, respectively. -### All Operating Systems +### PHP Build Scripts + +You can build Soup using `build_lib.php` which will produce a static lib. + +### Sun Soup can be built using our own build system, [Sun](https://github.com/calamity-inc/Sun). To include it in your own projects, we recommend the directory structure such that your own project and Soup share the same parent, then you can simply add the following to the .sun file for your project: @@ -20,7 +24,7 @@ This will make it so that you have to use `#include ` in your cod ### Bindings -To build Soup as a DLL/SO with C ABI exports, you can use `sun dynamic` (in the "soup" folder). +To build Soup as a DLL/SO with C ABI exports, run `php build_lib.php` (in the root folder) or `sun dynamic` (in the "soup" folder). For WASM, it can be done via `php wasm.php` (in the root folder) or `sun wasm` (in the "soup" folder). diff --git a/build_lib.php b/build_lib.php index 956c4f04..bde9db1d 100644 --- a/build_lib.php +++ b/build_lib.php @@ -22,8 +22,11 @@ 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"); - array_push($objects, escapeshellarg("bin/int/$file.o")); + 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(); @@ -31,11 +34,16 @@ 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 = "soup-bindings.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); diff --git a/soup/soup.cpp b/soup/soup.cpp index 13304636..af3ac908 100644 --- a/soup/soup.cpp +++ b/soup/soup.cpp @@ -497,7 +497,7 @@ class ServerWebServiceFfi : public ServerWebService void setRequestHandled() { pending_request = nullptr; - notifyable.notify_all(); + notifyable.wakeAll(); } }; #endif