Skip to content

Commit

Permalink
chore: add build flow for xcc-router smart contract (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed May 11, 2023
1 parent 5b00548 commit da2ce44
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env/mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CARGO_FEATURES_TEST="mainnet-test"
RUSTC_FLAGS_BUILD="-C link-arg=-s"
NEAR_EVM_ACCOUNT="aurora"
WASM_FILE="aurora-mainnet.wasm"
XCC_ROUTER_WASM_FILE="aurora-factory-mainnet.wasm"
WASM_FILE_TEST="aurora-mainnet-test.wasm"
NEAR_CLI="near"
PROFILE="mainnet"
Expand Down
1 change: 1 addition & 0 deletions .env/testnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CARGO_FEATURES_TEST="testnet-test"
RUSTC_FLAGS_BUILD="-C link-arg=-s"
NEAR_EVM_ACCOUNT="aurora"
WASM_FILE="aurora-testnet.wasm"
XCC_ROUTER_WASM_FILE="aurora-factory-testnet.wasm"
WASM_FILE_TEST="aurora-testnet-test.wasm"
NEAR_CLI="near"
PROFILE="testnet"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- name: Clone the repository
uses: actions/checkout@v3
- run: cargo make --profile ${{ matrix.profile }} build-docker
- run: cargo make --profile ${{ matrix.profile }} build-xcc-docker
- run: ls -lH bin/aurora-${{ matrix.profile }}.wasm
- name: Upload the aurora-${{ matrix.profile }}.wasm artifact
uses: actions/upload-artifact@v2
Expand Down
53 changes: 53 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ rm -Rf etc/eth-contracts/cache
rm -Rf etc/tests/benchmark-contract/target
rm -Rf etc/tests/ft-receiver/target
rm -Rf etc/tests/self-contained-5bEgfRQ/target
rm -Rf etc/xcc-router/target
'''

[tasks.clean-bin]
Expand Down Expand Up @@ -173,6 +174,21 @@ echo " CARGO_MAKE_PROFILE: ${CARGO_MAKE_PROFILE}"
echo " IS_PROD: ${IS_PROD}"
echo " CARGO_FEATURES: ${CARGO_FEATURES}"
echo " WASM_FILE: ${WASM_FILE}"
echo " SIZE_WASM_FILE: $(du -h bin/${WASM_FILE} | cut -f1)"
echo " TARGET_DIR: ${TARGET_DIR}"
echo " RUSTFLAGS: ${RUSTFLAGS}"
echo " Extra build args: ${RELEASE} ${@}"
'''

[tasks.post-xcc-router-build-env]
category = "Tools"
script = '''
echo "Environment:"
echo " CARGO_MAKE_PROFILE: ${CARGO_MAKE_PROFILE}"
echo " IS_PROD: ${IS_PROD}"
echo " CARGO_FEATURES: ${CARGO_FEATURES}"
echo " WASM_FILE: ${XCC_ROUTER_WASM_FILE}"
echo " SIZE_WASM_FILE: $(du -h bin/${XCC_ROUTER_WASM_FILE} | cut -f1)"
echo " TARGET_DIR: ${TARGET_DIR}"
echo " RUSTFLAGS: ${RUSTFLAGS}"
echo " Extra build args: ${RELEASE} ${@}"
Expand All @@ -186,6 +202,14 @@ args = [
"bin/${WASM_FILE}",
]

[tasks.copy-xcc-router-build]
category = "Post"
command = "cp"
args = [
"etc/xcc-router/target/wasm32-unknown-unknown/${TARGET_DIR}/xcc_router.wasm",
"bin/${XCC_ROUTER_WASM_FILE}",
]

[tasks.make-bin-directory]
category = "Post"
command = "mkdir"
Expand Down Expand Up @@ -219,6 +243,14 @@ args = [
"${@}",
]

[tasks.build-xcc-router]
category = "Build"
script = '''
cd etc/xcc-router
cargo build --verbose --target ${ENGINE_CARGO_TARGET} -Z avoid-dev-deps ${@} --release
cd ../..
'''

[tasks.build-engine-flow]
category = "Build"
dependencies = [
Expand All @@ -238,6 +270,15 @@ dependencies = [
"post-engine-build-env",
]

[tasks.build-xcc-router-flow-docker]
category = "Build"
dependencies = [
"build-xcc-router",
"make-bin-directory",
"copy-xcc-router-build",
"post-xcc-router-build-env",
]

[tasks.build-test]
condition = { profiles = ["mainnet", "testnet", "custom"] }
env = { "RUSTFLAGS" = "${RUSTC_FLAGS_BUILD}", "CARGO_FEATURES" = "${CARGO_FEATURES_BUILD_TEST}", "WASM_FILE" = "${WASM_FILE_TEST}", "RELEASE" = "--release", "TARGET_DIR" = "release" }
Expand All @@ -262,6 +303,18 @@ script = '''
docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-b8fc60809b907543d909ee75fcc1bd7b68cbe2fd-amd64 ./scripts/docker-entrypoint.sh ${PROFILE}
'''

[tasks.build-xcc-router-docker-inner]
condition = { profiles = ["mainnet", "testnet"] }
env = { "RUSTFLAGS" = "-C strip=symbols --remap-path-prefix ${HOME}=/path/to/home/ --remap-path-prefix ${PWD}=/path/to/source/", "CARGO_FEATURES" = "${CARGO_FEATURES_BUILD}", "RELEASE" = "--release", "TARGET_DIR" = "release" }
category = "Build"
run_task = "build-xcc-router-flow-docker"

[tasks.build-xcc-docker]
category = "Build"
script = '''
docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-b8fc60809b907543d909ee75fcc1bd7b68cbe2fd-amd64 ./scripts/docker-xcc-router-entrypoint.sh ${PROFILE}
'''

[tasks.test-contracts]
category = "Test"
script = '''
Expand Down
3 changes: 3 additions & 0 deletions scripts/docker-xcc-router-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cargo install --no-default-features --force cargo-make
cargo make --profile "$1" build-xcc-router-docker-inner

0 comments on commit da2ce44

Please sign in to comment.