Skip to content

Commit

Permalink
Merge remote-tracking branch 'kate/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurSonzogni committed Mar 26, 2021
2 parents c28085a + f41cbe0 commit fbf5122
Show file tree
Hide file tree
Showing 51 changed files with 846 additions and 263 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [ katef ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
29 changes: 0 additions & 29 deletions .github/workflows/ci.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/emcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Emscripten

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
cc: [ emcc ]

steps:
- uses: actions/checkout@v1
with:
submodules: recursive

# the xenial emscripten package is old (and doesn't support wasm);
# this brings in emsdk which is more recent, and does.
- uses: mymindstorm/setup-emsdk@v7

- name: dependencies
run: |
sudo apt-get update
sudo apt-get install bmake # wabt is not in xenial
# emcc -v # first run to generate ~/.emscripten only needed for system package
emcc -v # informational
curl https://wasmtime.dev/install.sh -sSf | bash # not packaged for ubuntu
# . ~/.bashrc for the paths added by wasmtime's installation does not work here
# I can't figure out why, so I'm just setting the paths by hand.
export WASMTIME_HOME="$HOME/.wasmtime"
export PATH="$WASMTIME_HOME/bin:$PATH"
wasmtime --version
- name: make
run: |
# note: lexer.h first, because parser.? depends on it
find . -name 'lexer.?' -exec touch '{}' \; # workaround for git checkout timestamps
find . -name 'parser.?' -exec touch '{}' \; # workaround for git checkout timestamps
bmake -r -j 2 DEBUG=1 PKGCONF=pkg-config CC=${{ matrix.cc }}
- name: test
# I don't want to build SID or lx just for sake of their -l test
# and wasm-validate is not packaged for xenial
run: |
export WASMTIME_HOME="$HOME/.wasmtime"
export PATH="$WASMTIME_HOME/bin:$PATH"
bmake -r -j 2 PKGCONF=pkg-config SID='true; echo sid' LX='true; echo lx' WASM_VALIDATE='true; echo wasm-validate' CC=${{ matrix.cc }} test
- uses: actions/upload-artifact@v2
with:
name: kgt-${{ github.sha }}.wasm
path: build/bin/kgt.wasm

58 changes: 58 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# testing different bmake dialects
# the goal here is to excercise the build system, not the code
# we don't care about e.g. different compilers here

name: Makefiles

on: [push]

jobs:
build:
name: "${{ matrix.make }} ${{ matrix.os }} ${{ matrix.debug }}"
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos ]
cc: [ clang ]
make: [ bmake, pmake ]
debug: [ DEBUG, RELEASE ] # RELEASE=1 is a no-op
exclude:
- os: macos
make: pmake

steps:
- uses: actions/checkout@v1
with:
submodules: recursive

- name: dependencies (Ubuntu)
if: matrix.os == 'ubuntu'
run: |
uname -a
sudo apt-get install pmake bmake
${{ matrix.cc }} --version
- name: dependencies (MacOS)
if: matrix.os == 'macos'
run: |
uname -a
brew install bmake
${{ matrix.cc }} --version
- name: make
run: |
# note: lexer.h first, because parser.? depends on it
find . -name 'lexer.?' -exec touch '{}' \; # workaround for git checkout timestamps
find . -name 'parser.?' -exec touch '{}' \; # workaround for git checkout timestamps
${{ matrix.make }} -r -j 2 ${{ matrix.debug }}=1 PKGCONF=pkg-config CC=${{ matrix.cc }}
- name: test
# I don't want to build SID just for sake of its -l test
# Same for lx
run: bmake -r -j 2 ${{ matrix.debug }}=1 PKGCONF=pkg-config SID='true; echo sid' LX='true; echo lx' CC=${{ matrix.cc }} test

- name: install
run: ${{ matrix.make }} -r -j 2 ${{ matrix.debug }}=1 PKGCONF=pkg-config PREFIX=/tmp/p-${{ matrix.debug }} install

113 changes: 113 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# packaging for release builds

name: Package

on: [push]

jobs:
fpm:
name: ${{ matrix.pkg }}
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
# others: cpan, gem, npm, osxpkg, p5p, pacman, pear, pkgin, pleaserun, puppet, python, snap, solaris, virtualenv ]
pkg: [ apk, deb, dir, freebsd, rpm, sh, tar, zip ]
os: [ ubuntu ]
cc: [ gcc ]

steps:
- uses: actions/checkout@v1
with:
submodules: recursive

- name: dependencies (Ubuntu)
if: matrix.os == 'ubuntu'
run: |
uname -a
sudo apt-get install bmake
sudo gem install --no-document fpm
fpm -v
${{ matrix.cc }} --version
- name: make
run: |
# note: lexer.h first, because parser.? depends on it
find . -name 'lexer.?' -exec touch '{}' \; # workaround for git checkout timestamps
find . -name 'parser.?' -exec touch '{}' \; # workaround for git checkout timestamps
bmake -r -j 2 PKGCONF=pkg-config CC=${{ matrix.cc }}
- name: test
# I don't want to build SID just for sake of its -l test
# Same for lx
run: bmake -r -j 2 PKGCONF=pkg-config NOSTRIP=1 SID='true; echo sid' LX='true; echo lx' CC=${{ matrix.cc }} test

- name: install
run: |
bmake -r -j 2 PKGCONF=pkg-config CC=${{ matrix.cc }} PREFIX=prefix/usr install
- name: Package
run: |
mkdir pkg
fpm -C prefix -p pkg/ -n kgt -t ${{ matrix.pkg }} -v 0.${{ github.sha }} -m [email protected] -s dir
- uses: actions/upload-artifact@v2
with:
name: ${{ github.sha }} ${{ matrix.pkg }}
path: pkg/* # single file here (because this is a matrix build), name format differs per package type

# this differs from the emcc CI in that it's a release build
wasm:
name: ${{ matrix.pkg }}
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
pkg: [ wasm ] # just so we can control the top-level name
os: [ ubuntu ]
cc: [ emcc ]

steps:
- uses: actions/checkout@v1
with:
submodules: recursive

# the xenial emscripten package is old (and doesn't support wasm);
# this brings in emsdk which is more recent, and does.
- uses: mymindstorm/setup-emsdk@v7

- name: dependencies
run: |
sudo apt-get update
sudo apt-get install bmake # wabt is not in xenial
# emcc -v # first run to generate ~/.emscripten only needed for system package
emcc -v # informational
curl https://wasmtime.dev/install.sh -sSf | bash # not packaged for ubuntu
# . ~/.bashrc for the paths added by wasmtime's installation does not work here
# I can't figure out why, so I'm just setting the paths by hand.
export WASMTIME_HOME="$HOME/.wasmtime"
export PATH="$WASMTIME_HOME/bin:$PATH"
wasmtime --version
- name: make
run: |
# note: lexer.h first, because parser.? depends on it
find . -name 'lexer.?' -exec touch '{}' \; # workaround for git checkout timestamps
find . -name 'parser.?' -exec touch '{}' \; # workaround for git checkout timestamps
bmake -r -j 2 NOSTRIP=1 PKGCONF=pkg-config CC=${{ matrix.cc }}
- name: test
# I don't want to build SID or lx just for sake of their -l test
# and wasm-validate is not packaged for xenial
run: |
export WASMTIME_HOME="$HOME/.wasmtime"
export PATH="$WASMTIME_HOME/bin:$PATH"
bmake -r -j 2 PKGCONF=pkg-config SID='true; echo sid' LX='true; echo lx' WASM_VALIDATE='true; echo wasm-validate' CC=${{ matrix.cc }} test
- uses: actions/upload-artifact@v2
with:
name: ${{ github.sha }} wasm
path: build/bin/*.wasm

59 changes: 59 additions & 0 deletions .github/workflows/san.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# testing different sanitizers
# the goal here is testing different sanitizers
# these are also run for non-debug mode to test optimisations

name: Sanitizers

on: [push]

jobs:
build:
name: "${{ matrix.san }} ${{ matrix.cc }} ${{ matrix.os }} ${{ matrix.debug }}"
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
san: [ ASAN, UBSAN, MSAN, EFENCE ]
os: [ ubuntu, macos ]
cc: [ clang, gcc ]
debug: [ DEBUG, RELEASE ] # RELEASE=1 is a no-op
exclude:
- os: macos
cc: gcc # it's clang anyway
- os: macos
san: EFENCE # not packaged
- os: macos
san: MSAN # not supported

steps:
- uses: actions/checkout@v1
with:
submodules: recursive

- name: dependencies (Ubuntu)
if: matrix.os == 'ubuntu'
run: |
uname -a
sudo apt-get install bmake electric-fence
${{ matrix.cc }} --version
- name: dependencies (MacOS)
if: matrix.os == 'macos'
run: |
uname -a
brew install bmake
${{ matrix.cc }} --version
- name: make
run: |
# note: lexer.h first, because parser.? depends on it
find . -name 'lexer.?' -exec touch '{}' \; # workaround for git checkout timestamps
find . -name 'parser.?' -exec touch '{}' \; # workaround for git checkout timestamps
bmake -r -j 2 ${{ matrix.san }}=1 ${{ matrix.debug }}=1 PKGCONF=pkg-config CC=${{ matrix.cc }}
- name: test
# I don't want to build SID just for sake of its -l test
# Same for lx
run: bmake -r -j 2 ${{ matrix.san }}=1 ${{ matrix.debug }}=1 PKGCONF=pkg-config SID='true; echo sid' LX='true; echo lx' CC=${{ matrix.cc }} test

12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ install:: all
clean::

# things to override
CC ?= gcc
BUILD ?= build
PREFIX ?= /usr/local
CC ?= gcc
BUILD ?= build
PREFIX ?= /usr/local
WASMTIME ?= wasmtime

# layout
SUBDIR += src/bnf
Expand Down Expand Up @@ -48,3 +49,8 @@ SUBDIR += src
.include <install.mk>
.include <clean.mk>

test::
.if ${CC:T:Memcc}
echo 'hello = world.' | ${WASMTIME} ${BUILD}/bin/kgt.wasm -- -l wsn -e rrutf8
.endif

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ examples for each dialect. kgt can't parse them all yet.
kgt reads from _stdin_ in dialect `-l ...` and writes to _stdout_
in format `-e ...`:

; kgt -l bnf -e rrutf8 < examples.expr.bnf
; kgt -l bnf -e rrutf8 < examples/expr.bnf
expr:
│├──╮── term ── "+" ── expr ──╭──┤│
│ │
Expand Down
5 changes: 4 additions & 1 deletion src/abnf/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef KGT_ABNF_IO_H
#define KGT_ABNF_IO_H

#include "../compiler_specific.h"

struct ast_rule;

/*
Expand All @@ -17,7 +19,8 @@ struct ast_rule;
struct ast_rule *
abnf_input(int (*f)(void *opaque), void *opaque);

void
WARN_UNUSED_RESULT
int
abnf_output(const struct ast_rule *grammar);

#endif
Expand Down
Loading

0 comments on commit fbf5122

Please sign in to comment.