Skip to content

Commit

Permalink
Also provide static & shared libs in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Dec 3, 2024
1 parent 3d97f51 commit 916e4e8
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 42 deletions.
52 changes: 44 additions & 8 deletions .github/workflows/cli.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build CLI
name: Build

on: push

Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
28 changes: 0 additions & 28 deletions .github/workflows/lib-wasm.yml

This file was deleted.

10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -20,7 +24,7 @@ This will make it so that you have to use `#include <soup/NAME.hpp>` 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).

Expand Down
12 changes: 10 additions & 2 deletions build_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,28 @@
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();

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);
2 changes: 1 addition & 1 deletion soup/soup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class ServerWebServiceFfi : public ServerWebService
void setRequestHandled()
{
pending_request = nullptr;
notifyable.notify_all();
notifyable.wakeAll();
}
};
#endif
Expand Down

0 comments on commit 916e4e8

Please sign in to comment.