-
Notifications
You must be signed in to change notification settings - Fork 95
129 lines (105 loc) · 4.43 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: build
on:
- push
- pull_request
jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
ocaml-version:
- 4.14.0
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.opam
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-flambda-musl-v6
- name: Install musl-compatible kernel headers
run: |
mkdir musl-kernel
curl -L https://github.com/sabotage-linux/kernel-headers/archive/refs/tags/v4.19.88-1.tar.gz | \
tar -xz -C musl-kernel --strip-components=1
echo "C_INCLUDE_PATH=$(pwd)/musl-kernel/x86/include" >> "$GITHUB_ENV"
- name: Install upx
run: |
# The version that comes with focal is broken for musl binaries, so we have to download
# from another location.
wget http://ftp.debian.org/debian/pool/main/u/upx-ucl/upx-ucl_3.96-2_amd64.deb
sudo dpkg -i upx-ucl_3.96-2_amd64.deb
- name: "Install apt packages"
run: |
sudo apt-get update
sudo apt-get install bubblewrap musl-tools
- name: Build zlib with musl
run: |
mkdir musl-zlib
curl -L https://zlib.net/zlib-1.3.1.tar.gz | tar -xz -C musl-zlib --strip-components=1
cd musl-zlib
CC=musl-gcc ./configure --libdir=/usr/lib/x86_64-linux-musl --includedir=/usr/include/x86_64-linux-musl
make
sudo make install
- name: Build zstd with musl
run: |
mkdir musl-zstd
curl -L https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz | \
tar -xz -C musl-zstd --strip-components=1
cd musl-zstd
INCLUDEDIR=/usr/include/x86_64-linux-musl LIBDIR=/usr/lib/x86_64-linux-musl CC=musl-gcc make
sudo make install
- name: Use OCaml ${{ matrix.ocaml-version }}
run: |
sudo wget -O /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux
sudo chmod a+x /usr/local/bin/opam
export OPAMYES=1
export OPAMJOBS=$(($(nproc) + 2))
echo "OPAMYES=1" >> "$GITHUB_ENV"
echo "OPAMJOBS=$OPAMJOBS" >> "$GITHUB_ENV"
opam init --bare -yav https://github.com/ocaml/opam-repository.git
opam switch set ${{ matrix.ocaml-version }}-flambda-musl 2>/dev/null || \
opam switch create ${{ matrix.ocaml-version }}-flambda-musl \
--packages=ocaml-variants.${{ matrix.ocaml-version }}+options,ocaml-option-flambda,ocaml-option-musl
echo "*************"
echo '#include <stdio.h>' | musl-gcc -xc -E -v - 2>&1 >/dev/null
echo "*************"
echo '#include <stdio.h>' | gcc -xc -E -v - 2>&1 >/dev/null
echo "*************"
readlink -f /usr/lib/gcc/x86_64-linux-gnu/11/include
readlink -f /usr/include/x86_64-linux-musl
#sudo ln -s /usr/include/zlib.h /usr/include/x86_64-linux-musl/zlib.h
#sudo ln -s /usr/lib/x86_64-linux-gnu/libz.a /usr/lib/x86_64-linux-musl/libz.a
#sudo ln -s /usr/include/zstd.h /usr/include/x86_64-linux-musl/zstd.h
#sudo ln -s /usr/include/zdict.h /usr/include/x86_64-linux-musl/zdict.h
#sudo ln -s /usr/lib/x86_64-linux-gnu/libzstd.a /usr/lib/x86_64-linux-musl/libzstd.a
echo "????"
gcc -print-search-dirs | grep libraries
echo "????"
ls /usr/lib/x86_64-linux-gnu | grep libz
- run: opam install ./magic-trace.opam --deps-only
- run: opam install ocamlformat
- run: opam exec -- dune build @fmt
- run: opam exec -- make PROFILE=static
- run: opam exec -- dune runtest
- name: Compress magic-trace executable
run: |
cp _build/install/default/bin/magic-trace .
ls -l magic-trace
strip magic-trace
upx -9 magic-trace
- uses: actions/upload-artifact@v3
with:
name: magic-trace
path: magic-trace
if-no-files-found: error
- name: Upload to GitHub releases
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magic-trace
asset_name: magic-trace
tag: ${{ github.ref }}
overwrite: true