Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Dec 7, 2023
1 parent 8b94ccd commit dec865c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on: push

jobs:
ubuntu-20-04:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Build Soup
run: php Sun/vendor/Soup/build_lib.php

- name: Build Sun
run: clang -o suncli Sun/sun.cpp -ISun/vendor/Soup libsoup.a -std=c++20

- name: Upload Sun
uses: actions/upload-artifact@v3
with:
name: "Ubuntu 20.04"
path: suncli
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin/
*.lib
*.o
*.nupkg
libsoup.a
7 changes: 7 additions & 0 deletions Sun/vendor/Soup/build_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$clang = "clang -std=c++17 -fno-rtti";
$clanglink = $clang." -lstdc++ -pthread -lresolv -lm -ldl";
if (PHP_OS_FAMILY != "Darwin")
{
$clanglink .= " -fuse-ld=lld -lstdc++fs";
}
14 changes: 7 additions & 7 deletions Sun/vendor/Soup/build_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
require "build_config.php";

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

// Find work
$files = [];
foreach(scandir("soup") as $file)
foreach(scandir(__DIR__."/soup") as $file)
{
if(substr($file, -4) == ".cpp")
{
Expand All @@ -26,8 +26,8 @@
foreach($files as $file)
{
echo $file."\n";
passthru("$clang -c soup/$file.cpp -o bin/int/$file.o");
array_push($objects, escapeshellarg("bin/int/$file.o"));
passthru("$clang -c ".__DIR__."/soup/$file.cpp -o ".__DIR__."/bin/int/$file.o");
array_push($objects, escapeshellarg(__DIR__."/bin/int/$file.o"));
}

echo "Bundling static lib...\n";
Expand Down
2 changes: 1 addition & 1 deletion docs/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cd Soup
php build_lib.php
cd ..
cd Sun
clang -o suncli Sun/main.cpp -I../Soup ../Soup/libsoup.a -std=c++20 -fuse-ld=lld -lstdc++ -lstdc++fs -pthreads
clang -o suncli Sun/sun.cpp -I../Soup ../Soup/libsoup.a -std=c++20 -fuse-ld=lld -lstdc++ -lstdc++fs -pthreads
```

You can then use the following command to make the "suncli" executable globally available as "sun":
Expand Down

0 comments on commit dec865c

Please sign in to comment.