Skip to content

Commit 9da8c77

Browse files
authored
feat: Initial implementation (#1)
Release-As: 101.0.0
1 parent db3be01 commit 9da8c77

File tree

73 files changed

+4449
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4449
-1
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.github export-ignore
2+
.ocamlformat export-ignore

.github/workflows/esy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Esy
2+
on:
3+
- push
4+
- pull_request
5+
6+
jobs:
7+
build:
8+
name: Build and test
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
16+
steps:
17+
- name: Setup node.js
18+
uses: actions/[email protected]
19+
with:
20+
node-version: '14'
21+
check-latest: true
22+
23+
# Install `esy` to build the project
24+
- name: Setup environment
25+
run: |
26+
npm i -g esy
27+
28+
- name: Checkout project
29+
uses: actions/checkout@v2
30+
with:
31+
submodules: 'recursive'
32+
33+
- name: Esy build
34+
uses: esy/github-action@d859489ca96411749931bceb4d733a2bdea922f9
35+
with:
36+
cache-key: ${{ hashFiles('esy.lock/index.json') }}
37+
38+
- name: Run tests
39+
run: |
40+
esy test

.github/workflows/opam.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Opam
2+
on:
3+
- push
4+
- pull_request
5+
6+
jobs:
7+
build:
8+
name: Build and test
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
ocaml-compiler: [4.12.0]
16+
17+
steps:
18+
- name: Checkout project
19+
uses: actions/checkout@v2
20+
with:
21+
submodules: 'recursive'
22+
23+
- name: Setup OCaml ${{ matrix.ocaml-compiler }}
24+
uses: ocaml/setup-ocaml@v2
25+
with:
26+
ocaml-compiler: ${{ matrix.ocaml-compiler }}
27+
28+
- name: Install local dependencies
29+
run: opam install . --deps-only --with-test
30+
31+
- name: Build project
32+
run: opam exec -- dune build
33+
34+
- name: Run tests
35+
run: |
36+
opam exec -- dune runtest

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
release-please:
9+
name: Create Release
10+
runs-on: ubuntu-latest
11+
outputs:
12+
release_created: ${{ steps.release.outputs.release_created }}
13+
upload_url: ${{ steps.release.outputs.upload_url }}
14+
tag_name: ${{ steps.release.outputs.tag_name }}
15+
body: ${{ steps.release.outputs.body }}
16+
steps:
17+
- uses: GoogleCloudPlatform/[email protected]
18+
id: release
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
release-type: ocaml
22+
package-name: libbinaryen
23+
24+
add-archive:
25+
needs: [release-please]
26+
if: ${{ needs.release-please.outputs.release_created }}
27+
name: Add archive to release
28+
runs-on: macos-latest
29+
outputs:
30+
browser_download_url: ${{ steps.upload.outputs.browser_download_url }}
31+
steps:
32+
- name: Install git-archive-all
33+
run: |
34+
brew install git-archive-all
35+
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
with:
39+
submodules: 'recursive'
40+
41+
- name: Build archive
42+
run: |
43+
git-archive-all --force-submodules libbinaryen.tar.gz
44+
45+
- name: Upload Release Asset
46+
id: upload
47+
uses: actions/upload-release-asset@v1
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
upload_url: ${{ needs.release-please.outputs.upload_url }}
52+
asset_path: ./libbinaryen.tar.gz
53+
asset_name: libbinaryen-${{ needs.release-please.outputs.tag_name }}.tar.gz
54+
asset_content_type: application/gzip
55+
56+
opam-release:
57+
needs: [release-please, add-archive]
58+
name: Publish to opam registry
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Setup bot user
62+
run: |
63+
git config --global user.email "[email protected]"
64+
git config --global user.name "Grain Bot"
65+
66+
# Some hacks to make sure opam doesn't pull the repo in a way we can't deal with
67+
- name: Setup opam repository
68+
run: |
69+
mkdir -p ~/.opam/plugins/opam-publish/repos/
70+
git clone git://github.com/ocaml/opam-repository ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository
71+
cd ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository
72+
git remote add user https://${{ secrets.OPAM_RELEASE }}@github.com/grainbot/opam-repository
73+
74+
# Set up our token because opam doesn't support env var tokens
75+
- name: Setup token
76+
run: |
77+
mkdir -p ~/.opam/plugins/opam-publish/
78+
echo -n ${{ secrets.OPAM_RELEASE }} > ~/.opam/plugins/opam-publish/libbinaryen.token
79+
80+
- name: Generate CHANGES file
81+
env:
82+
CHANGES: ${{ needs.release-please.outputs.body }}
83+
run: |
84+
echo -n "$CHANGES" > CHANGES.md
85+
86+
- name: Setup OCaml
87+
uses: ocaml/setup-ocaml@v2
88+
with:
89+
ocaml-compiler: 4.12.0
90+
91+
- name: Install publish utils
92+
run: |
93+
opam install opam-publish
94+
95+
- name: Publish to opam
96+
run: |
97+
opam publish --no-browser --msg-file=CHANGES.md ${{ needs.add-archive.outputs.browser_download_url }}
98+
99+
npm-release:
100+
needs: [add-archive]
101+
name: Publish to npm registry
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Setup NodeJS
105+
uses: actions/setup-node@v2
106+
with:
107+
node-version: "14"
108+
registry-url: "https://registry.npmjs.org"
109+
110+
- name: Publish to npm
111+
run: npm publish ${{ needs.add-archive.outputs.browser_download_url }}
112+
env:
113+
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE }}

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ setup.log
2727

2828
# Local OPAM switch
2929
_opam/
30+
31+
# Esy
32+
node_modules/
33+
_esy/
34+
35+
# Other
36+
META
37+
.vscode/
38+
.DS_Store
39+
*.tar.gz
40+
*.install
41+
*.zip

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "binaryen"]
2+
path = binaryen
3+
url = https://github.com/WebAssembly/binaryen

.ocamlformat

Whitespace-only changes.

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
11
# libbinaryen
2-
libbinaryen packaged for OCaml
2+
3+
Libbinaryen packaged for OCaml.
4+
5+
This is just the low-level C library. If you are looking for OCaml *bindings* to Binaryen, check out [Binaryen.ml](https://github.com/grain-lang/binaryen.ml)!
6+
7+
## Usage
8+
9+
Inside your dune file, you can depend on `libbinaryen` as such:
10+
11+
```
12+
(library
13+
(name binaryen)
14+
(public_name binaryen)
15+
(libraries libbinaryen.c)
16+
(foreign_stubs
17+
(language c)
18+
(names binaryen_stubs)
19+
(flags :standard -O2 -Wall -Wextra))
20+
(c_library_flags :standard -lstdc++ -lpthread))
21+
```
22+
23+
## Library flags
24+
25+
This package attempts to smooth over configuration frustrations by providing specific `library_flags` when built.
26+
27+
### MacOS
28+
29+
In order to support Mac M1, this package assumes you are using `clang++` on MacOS and applies the flags `-cc clang++` to the built library.
30+
31+
### Windows
32+
33+
On Windows, this package assumes libbinaryen is built under MinGW and applies the flags `-ccopt -- -ccopt -static` to the built library.
34+
35+
## Contributing
36+
37+
You'll need Node.js and [`esy`](https://esy.sh/docs/en/getting-started.html#install-esy) to build this project.
38+
You should be able to use Opam if you are more comfortable with it, but the core team does all development using esy.
39+
40+
`dune` will take care of compiling Binaryen, so to build the project you'll only need to run:
41+
42+
```bash
43+
esy
44+
```
45+
46+
This will take a while. Once it's done, you can run the tests:
47+
48+
```bash
49+
esy test
50+
```

binaryen

Submodule binaryen added at 423cf0b

config/dune

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(executable
2+
(name library_flags)
3+
(libraries dune.configurator))
4+
5+
(rule
6+
(targets library_flags.sexp)
7+
(action
8+
(run ./library_flags.exe)))

0 commit comments

Comments
 (0)