Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit df2f55c

Browse files
authored
hallelujah (#1)
1 parent 314df3d commit df2f55c

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-24.04
13+
env:
14+
EMSCRIPTEN_VERSION: '3.1.64'
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.12'
23+
24+
- name: Install dependencies
25+
run: |
26+
sudo apt install -y ninja-build
27+
28+
- name: Install emsdk
29+
run: |
30+
git clone https://github.com/emscripten-core/emsdk
31+
cd emsdk
32+
./emsdk install ${{ env.EMSCRIPTEN_VERSION }}
33+
./emsdk activate ${{ env.EMSCRIPTEN_VERSION }}
34+
35+
- name: Build
36+
run: |
37+
. emsdk/emsdk_env.sh
38+
python scripts/fmt.py
39+
python scripts/json-c.py
40+
python scripts/marisa.py
41+
42+
- name: Release
43+
if: ${{ github.ref == 'refs/heads/master' }}
44+
uses: 'marvinpinto/action-automatic-releases@latest'
45+
with:
46+
repo_token: ${{ secrets.GITHUB_TOKEN }}
47+
automatic_release_tag: latest
48+
prerelease: true
49+
title: "Nightly Build"
50+
files: |
51+
build/*.tar.bz2

scripts/common.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os
2+
3+
INSTALL_PREFIX = '/usr'
4+
5+
6+
def ensure(program: str, args: list[str]):
7+
command = " ".join([program, *args])
8+
print(command)
9+
if os.system(command) != 0:
10+
raise Exception("Command failed")
11+
12+
13+
class Builder:
14+
def __init__(self, name: str, options: list[str] | None=None):
15+
self.name = name
16+
self.root = os.getcwd()
17+
self.destdir = f'{self.root}/build/{self.name}'
18+
self.options = options or []
19+
20+
def configure(self):
21+
os.chdir(f'{self.root}/{self.name}')
22+
ensure('emcmake', ['cmake',
23+
'-B', 'build', '-G', 'Ninja',
24+
'-DBUILD_SHARED_LIBS=OFF',
25+
f'-DCMAKE_INSTALL_PREFIX={INSTALL_PREFIX}',
26+
'-DCMAKE_BUILD_TYPE=Release',
27+
'-DCMAKE_C_FLAGS=-fPIC',
28+
'-DCMAKE_CXX_FLAGS=-fPIC',
29+
*self.options
30+
])
31+
32+
def build(self):
33+
ensure('cmake', ['--build', 'build'])
34+
35+
def install(self):
36+
os.environ['DESTDIR'] = self.destdir
37+
ensure('cmake', ['--install', 'build'])
38+
39+
def package(self):
40+
os.chdir(f'{self.destdir}{INSTALL_PREFIX}')
41+
ensure('tar', ['cjvf', f'{self.destdir}.tar.bz2', '*'])
42+
43+
def exec(self):
44+
self.configure()
45+
self.build()
46+
self.install()
47+
self.package()

scripts/fmt.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from common import Builder
2+
3+
Builder('fmt', [
4+
'-DFMT_TEST=OFF',
5+
'-DFMT_DOC=OFF'
6+
]).exec()

scripts/json-c.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from common import Builder
2+
3+
Builder('json-c', [
4+
'-DDISABLE_EXTRA_LIBS=ON'
5+
]).exec()

scripts/marisa.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from common import Builder
2+
3+
Builder('marisa').exec()

0 commit comments

Comments
 (0)