-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from automerge/small-binaries
Rebuild with new smaller shared libraries
- Loading branch information
Showing
17 changed files
with
73 additions
and
24 deletions.
There are no files selected for viewing
Submodule automerge-rs
updated
from 44fa7a to 905c7d
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Package deps exists because shared libraries must be in the same directory | ||
// as a go package for `go mod vendor` to work. | ||
// (c.f. https://github.com/golang/go/issues/26366#issuecomment-405683150) | ||
package deps | ||
|
||
/* | ||
#cgo LDFLAGS: -L${SRCDIR} | ||
#cgo darwin,arm64 LDFLAGS: -lautomerge_core_darwin_arm64 | ||
#cgo darwin,amd64 LDFLAGS: -lautomerge_core_darwin_amd64 | ||
#cgo linux,arm64 LDFLAGS: -lautomerge_core_linux_arm64 -lm | ||
#cgo linux,amd64 LDFLAGS: -lautomerge_core_linux_amd64 -lm | ||
*/ | ||
import "C" |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,12 @@ then | |
exit 1 | ||
fi | ||
|
||
which cargo || ( | ||
which cargo || which cmake || ( | ||
echo "Missing dependencies!" | ||
echo "See https://github.com/automerge/automerge-rs for instructions on setting up the build environment." | ||
exit 1 | ||
) | ||
|
||
# [email protected] is broken on my machine: https://github.com/cross-rs/cross/issues/1214 | ||
which cross || cargo install [email protected] | ||
|
||
deps="$(realpath "$(dirname "$0")")" | ||
automerge_c="$deps/automerge-rs/rust/automerge-c" | ||
|
||
|
@@ -33,24 +30,28 @@ elif [[ "$1" != "" ]]; then | |
fi | ||
|
||
mkdir -p "$deps/build" | ||
mkdir -p "$deps/darwin_arm64" | ||
mkdir -p "$deps/darwin_amd64" | ||
mkdir -p "$deps/linux_arm64" | ||
mkdir -p "$deps/linux_amd64" | ||
|
||
CBINDGEN_TARGET_DIR="$deps/.." cargo build -r --manifest-path="$automerge_c/Cargo.toml" --target aarch64-apple-darwin --target-dir "$deps/build" | ||
cp "$deps/build/aarch64-apple-darwin/release/libautomerge_core.a" "$deps/darwin_arm64/" | ||
cmake -B "$deps/build" -S "$automerge_c" | ||
cmake --build "$deps/build" | ||
cp "$deps/build/include/automerge-c/automerge.h" "$deps/.." | ||
cp "$deps/build/Cargo/target/aarch64-apple-darwin/release/libautomerge_core.a" "$deps/libautomerge_core_darwin_arm64.a" | ||
|
||
if [[ "$1" == "local" ]]; then | ||
exit | ||
fi | ||
|
||
cargo build -r --manifest-path="$automerge_c/Cargo.toml" --target x86_64-apple-darwin --target-dir "$deps/build" | ||
cp "$deps/build/x86_64-apple-darwin/release/libautomerge_core.a" "$deps/darwin_amd64/" | ||
# [email protected] is broken on my machine: https://github.com/cross-rs/cross/issues/1214 | ||
which cross || cargo install [email protected] | ||
|
||
function build() { | ||
target="$1" | ||
output="$2" | ||
|
||
cross build -r --manifest-path="$automerge_c/Cargo.toml" --target aarch64-unknown-linux-gnu --target-dir "$deps/build" | ||
cp "$deps/build/aarch64-unknown-linux-gnu/release/libautomerge_core.a" "$deps/linux_arm64/" | ||
RUSTFLAGS="-C panic=abort" cross +nightly build --release --manifest-path="$automerge_c/Cargo.toml" -Z build-std=std,panic_abort --target "$target" --target-dir "$deps/build" | ||
|
||
cross build -r --manifest-path="$automerge_c/Cargo.toml" --target x86_64-unknown-linux-gnu --target-dir "$deps/build" | ||
cp "$deps/build/x86_64-unknown-linux-gnu/release/libautomerge_core.a" "$deps/linux_amd64/" | ||
cp "$deps/build/$target/release/libautomerge_core.a" "$deps/$output" | ||
} | ||
|
||
build x86_64-apple-darwin libautomerge_core_darwin_amd64.a | ||
build aarch64-unknown-linux-gnu libautomerge_core_linux_arm64.a | ||
build x86_64-unknown-linux-gnu libautomerge_core_linux_amd64.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package deps | ||
|
||
import "os" | ||
import "os/exec" | ||
import "testing" | ||
|
||
func TestVendored(t *testing.T) { | ||
os.Chdir("vendor_test") | ||
|
||
run := func(c string, args ...string) { | ||
cmd := exec.Command(c, args...) | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
os.Stdout.Write(output) | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
run("go", "mod", "tidy") | ||
run("go", "mod", "vendor") | ||
run("go", "test") | ||
run("git", "checkout", "go.mod") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor/ | ||
go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.19 | ||
|
||
module github.com/automerge/vendor-test | ||
|
||
require github.com/automerge/automerge-go v0.0.0 | ||
replace github.com/automerge/automerge-go => ../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "github.com/automerge/automerge-go" | ||
import "testing" | ||
|
||
func TestWorking(t *testing.T) { | ||
automerge.New() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters