Skip to content

Commit 39fb61a

Browse files
authored
Merge pull request #151 from jonas/prepare-release
Add script to build the executables for linux and macOS
2 parents af54d3e + b343eb6 commit 39fb61a

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target/
22
scripts/.coursier
33
scripts/.scalafmt-*
4+
/scala-native-bindgen-*

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ This tool generates Scala Native bindings from C headers. It's built upon clang
88

99
## Releasing
1010

11-
To release version `x.y.z` run:
11+
First build the `scala-native-bindgen` executable for both macOS and
12+
Linux:
13+
14+
> scripts/prepare-release.sh
15+
16+
You should now have `scala-native-bindgen-linux` and
17+
`scala-native-bindgen-darwin` if you ran the script on a macOS machine.
18+
19+
Then release version `x.y.z` by running:
1220

1321
> sbt -Dproject.version=x.y.z release
1422

15-
Then build the `scala-native-bindgen` executable for both macOS and
16-
Linux and upload them to the GitHub release page with the suffix
17-
`-darwin` and `-linux`, respectively.
23+
Finally, upload the `scala-native-bindgen-linux` and
24+
`scala-native-bindgen-darwin` executables to the release page at:
25+
<https://github.com/kornilova-l/scala-native-bindgen/releases/tag/vx.y.z>
1826

1927
## License
2028

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
args:
99
- UBUNTU_VERSION=18.04
1010
- LLVM_VERSION=6.0
11-
entrypoint: [scala-native-bindgen]
11+
entrypoint: [/scala-native-bindgen]
1212

1313
ubuntu-18.04-llvm-6.0:
1414
image: scalabindgen/scala-native-bindgen-builder:ubuntu-18.04-llvm-6.0

scripts/prepare-release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build Linux and if possible macOS executables.
4+
5+
# Bash strict mode
6+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
7+
set -euo pipefail
8+
IFS=$'\n\t'
9+
10+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11+
12+
LINUX_EXEC="$ROOT/scala-native-bindgen-linux"
13+
if [[ ! -e "$LINUX_EXEC" ]]; then
14+
docker-compose build bindgen
15+
local container="$(docker container create "scalabindgen/scala-native-bindgen:${VERSION:-latest}")"
16+
docker cp "$container:/scala-native-bindgen" "$LINUX_EXEC"
17+
docker container rm "$container"
18+
fi
19+
20+
MACOS_EXEC="$ROOT/scala-native-bindgen-darwin"
21+
if [[ "$(uname -s)" = "Darwin" ]] && [[ ! -e "$MACOS_EXEC" ]]; then
22+
json_dir="$(ls /usr/local/Cellar/nlohmann_json/ | sort | tail -n 1)/include"
23+
rm -rf bindgen/target
24+
mkdir -p bindgen/target
25+
(cd bindgen/target && cmake -DSTATIC_LINKING=ON -DCMAKE_CXX_FLAGS="-isystem $json_dir" ..)
26+
make -C bindgen/target
27+
cp bindgen/target/scala-native-bindgen "$MACOS_EXEC"
28+
fi

0 commit comments

Comments
 (0)