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

Commit

Permalink
hallelujah (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Aug 6, 2024
1 parent 314df3d commit df2f55c
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: ci

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-24.04
env:
EMSCRIPTEN_VERSION: '3.1.64'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo apt install -y ninja-build
- name: Install emsdk
run: |
git clone https://github.com/emscripten-core/emsdk
cd emsdk
./emsdk install ${{ env.EMSCRIPTEN_VERSION }}
./emsdk activate ${{ env.EMSCRIPTEN_VERSION }}
- name: Build
run: |
. emsdk/emsdk_env.sh
python scripts/fmt.py
python scripts/json-c.py
python scripts/marisa.py
- name: Release
if: ${{ github.ref == 'refs/heads/master' }}
uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: true
title: "Nightly Build"
files: |
build/*.tar.bz2
47 changes: 47 additions & 0 deletions scripts/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os

INSTALL_PREFIX = '/usr'


def ensure(program: str, args: list[str]):
command = " ".join([program, *args])
print(command)
if os.system(command) != 0:
raise Exception("Command failed")


class Builder:
def __init__(self, name: str, options: list[str] | None=None):
self.name = name
self.root = os.getcwd()
self.destdir = f'{self.root}/build/{self.name}'
self.options = options or []

def configure(self):
os.chdir(f'{self.root}/{self.name}')
ensure('emcmake', ['cmake',
'-B', 'build', '-G', 'Ninja',
'-DBUILD_SHARED_LIBS=OFF',
f'-DCMAKE_INSTALL_PREFIX={INSTALL_PREFIX}',
'-DCMAKE_BUILD_TYPE=Release',
'-DCMAKE_C_FLAGS=-fPIC',
'-DCMAKE_CXX_FLAGS=-fPIC',
*self.options
])

def build(self):
ensure('cmake', ['--build', 'build'])

def install(self):
os.environ['DESTDIR'] = self.destdir
ensure('cmake', ['--install', 'build'])

def package(self):
os.chdir(f'{self.destdir}{INSTALL_PREFIX}')
ensure('tar', ['cjvf', f'{self.destdir}.tar.bz2', '*'])

def exec(self):
self.configure()
self.build()
self.install()
self.package()
6 changes: 6 additions & 0 deletions scripts/fmt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from common import Builder

Builder('fmt', [
'-DFMT_TEST=OFF',
'-DFMT_DOC=OFF'
]).exec()
5 changes: 5 additions & 0 deletions scripts/json-c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from common import Builder

Builder('json-c', [
'-DDISABLE_EXTRA_LIBS=ON'
]).exec()
3 changes: 3 additions & 0 deletions scripts/marisa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from common import Builder

Builder('marisa').exec()

0 comments on commit df2f55c

Please sign in to comment.