Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup build commands in Makefile #550

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ jobs:
- cargocache-v3-build_shared_library-rust:1.74.0-
- run:
name: Create release build of libwasmvm
command: make build-rust
command: make build-libwasmvm
- persist_to_workspace:
root: ./internal/api
paths:
Expand Down
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.PHONY: all build build-rust build-go test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decentralize .PHONY to avoid outdated list

# Builds the Rust library libwasmvm
BUILDERS_PREFIX := cosmwasm/libwasmvm-builder:0100
# Contains a full Go dev environment including CGO support in order to run Go tests on the built shared library
Expand Down Expand Up @@ -30,33 +28,37 @@ test-filenames:
echo $(SHARED_LIB_DST)
echo $(SHARED_LIB_SRC)

all: build test

build: build-rust build-go

build-rust: build-rust-release
.PHONY: build
build:
make build-libwasmvm
make build-go

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the dependency notation we had before they may run in parallel (make build -j 2 would run both jobs at the same time)

# Use debug build for quick testing.
# In order to use "--features backtraces" here we need a Rust nightly toolchain, which we don't have by default
build-rust-debug:
.PHONY: build-libwasmvm-debug
build-libwasmvm-debug:
(cd libwasmvm && cargo build)
cp libwasmvm/target/debug/$(SHARED_LIB_SRC) internal/api/$(SHARED_LIB_DST)
make update-bindings

# use release build to actually ship - smaller and much faster
build-rust-release:
.PHONY: build-libwasmvm
build-libwasmvm:
(cd libwasmvm && cargo build --release)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need two different commands for the release build

cp libwasmvm/target/release/$(SHARED_LIB_SRC) internal/api/$(SHARED_LIB_DST)
make update-bindings

.PHONY: build-go
build-go:
go build ./...
go build -o build/demo ./cmd/demo

.PHONY: test
test:
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
RUST_BACKTRACE=1 go test -v -count=1 ./...

.PHONY: test-safety
test-safety:
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
GOEXPERIMENT=cgocheck2 go test -race -v -count=1 ./...
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library that can be used via FFI. It is compiled like this:

# Create release build for your current system. Uses whatever default Rust
# version you have installed.
make build-rust
make build-libwasmvm

# Create reproducible release builds for other systems (slow, don't use for development)
make release-build-alpine
Expand Down Expand Up @@ -135,7 +135,7 @@ which for example excludes all 32 bit systems.
| macOS | x86_64 | static | ✅​libwasmvmstatic_darwin.a | Fat/universal library with multiple archs ([#407]) |
| macOS | aarch64 | shared | ✅​libwasmvm.dylib | Fat/universal library with multiple archs ([#294]) |
| macOS | aarch64 | static | ✅​libwasmvmstatic_darwin.a | Fat/universal library with multiple archs ([#407]) |
| Windows (mingw) | x86_64 | shared | 🏗​wasmvm.dll | Shared library linking not working on Windows ([#389]) |
| Windows (mingw) | x86_64 | shared | 🏗​wasmvm.dll | Shared library linking not working on Windows ([#389]) |
| Windows (mingw) | x86_64 | static | 🚫​ | Unclear if this can work using a cross compiler; needs research on .lib (MSVC toolchain) vs. .a (GNU toolchain). ([#389]) |
| Windows (mingw) | aarch64 | shared | 🚫​ | Shared library linking not working on Windows ([#389]) |
| Windows (mingw) | aarch64 | static | 🚫​ | Unclear if this can work using a cross compiler; needs research on .lib (MSVC toolchain) vs. .a (GNU toolchain). ([#389]) |
Expand Down Expand Up @@ -171,6 +171,6 @@ import this code freely. If it is not present you will have to build it for your
system, and ideally add it to this repo with a PR (on your fork). We will set up
a proper CI system for building these binaries, but we are not there yet.

To build the rust side, try `make build-rust` and wait for it to compile. This
depends on `cargo` being installed with `rustc` version 1.47+. Generally, you
can just use `rustup` to install all this with no problems.
To build the rust side, try `make build-libwasmvm` and wait for it to compile.
This depends on `cargo` being installed with `rustc` version 1.47+. Generally,
you can just use `rustup` to install all this with no problems.
Loading