Skip to content

Commit

Permalink
move build-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Jan 19, 2025
1 parent 6e33d11 commit 3cb0b47
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:

- name: Building Go Binaries
run: |
bash src/cmd/build.sh
bash src/lib/build.sh
bash scripts/build_cli.sh
bash scripts/build_cgo.sh
- name: Running Unit Tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You first need to either [download](https://github.com/O-X-L/opensimplex/release

1. [Golang download/install](https://go.dev/doc/install)

2. Build them: `bash src/cmd/build.sh` and/or `bash src/lib/build.sh`
2. Build them: `bash scripts/build_cli.sh` and/or `bash scripts/build_cgo.sh`

----

Expand Down
2 changes: 1 addition & 1 deletion src/lib/build.sh → scripts/build_cgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

cd "$(dirname "$0")"
cd "$(dirname "$0")/../src/lib"

PATH_OUT="$(pwd)/../.."

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/build.sh → scripts/build_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

cd "$(dirname "$0")"
cd "$(dirname "$0")../src/cmd"

PATH_OUT="$(pwd)/../.."

Expand Down
64 changes: 64 additions & 0 deletions scripts/build_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -uo pipefail

cd "$(dirname "$0")/../src"
PATH_SRC="$(pwd)"
PATH_BUILD="${PATH_SRC}/../build"
mkdir -p "$PATH_BUILD"
rm -f "${PATH_BUILD}/"*

function compile() {
os="$1" arch="$2"
echo "COMPILING BINARIES FOR ${os}-${arch}"

cd "$PATH_SRC"
name_out_lib="noise_cgo_${os}_${arch}"
path_out_lib="${PATH_BUILD}/${name_out_lib}"
GOOS="$os" GOARCH="$arch" go build -buildmode=c-shared -o "${path_out_lib}.so" "${PATH_SRC}/lib/noise_cgo.go"

name_out_cli="noise_cli_${os}_${arch}"
GOOS="$os" GOARCH="$arch" go build -o "${PATH_BUILD}/${name_out_cli}" "${PATH_SRC}/cmd/noise_cli.go"
GOOS="$os" GOARCH="$arch" CGO_ENABLED=0 go build -o "${PATH_BUILD}/${name_out_cli}-CGO0" "${PATH_SRC}/cmd/noise_cli.go"

cd "$PATH_BUILD"
if [[ "$os" == "windows" ]]
then
if [ -f "${name_out_lib}.so" ]
then
zip "${name_out_lib}.zip" "${name_out_lib}"*
fi
zip "${name_out_cli}.zip" "${name_out_cli}"
zip "${name_out_cli}-CGO0.zip" "${name_out_cli}-CGO0"
else
if [ -f "${name_out_lib}.so" ]
then
tar -czf "${name_out_lib}.tar.gz" "${name_out_lib}"*
fi
tar -czf "${name_out_cli}.tar.gz" "${name_out_cli}"
tar -czf "${name_out_cli}-CGO0.tar.gz" "${name_out_cli}-CGO0"
fi
}

compile "linux" "amd64"

# untested:
compile "linux" "386"
compile "linux" "arm"
compile "linux" "arm64"

compile "freebsd" "386"
compile "freebsd" "amd64"
compile "freebsd" "arm"

compile "openbsd" "386"
compile "openbsd" "amd64"
compile "openbsd" "arm"

compile "darwin" "amd64"
compile "darwin" "arm64"

compile "windows" "386"
compile "windows" "amd64"

ls -l "$PATH_BUILD"
26 changes: 0 additions & 26 deletions src/build_release.sh

This file was deleted.

0 comments on commit 3cb0b47

Please sign in to comment.