-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass RUSTFLAGS in dependency build (#687)
* Pass RUSTFLAGS in dependency build This instructs the Dockerfile to use the official build script, which now takes an extra option for building only rust dependencies. When introducing `--remap-path-prefix` I forgot to set the build flag during the dependency build, the actual build in Docker would rebuild most of the crates. Now the Dockerfile uses the build file as well. I've also added a new script, `./scripts/build`, for ease of use. * Drop src/i...dentity/build.sh This moves all the build logic to ./scripts/build, which is more standard than src/.../build.sh.
- Loading branch information
Showing
7 changed files
with
127 additions
and
60 deletions.
There are no files selected for viewing
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
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,118 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Make sure we always run from the root | ||
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
cd "$SCRIPTS_DIR/.." | ||
|
||
######### | ||
# USAGE # | ||
######### | ||
|
||
function title() { | ||
echo "Build Internet Identity" | ||
} | ||
|
||
function usage() { | ||
cat << EOF | ||
Usage: | ||
$0 [--only-dependencies] | ||
Options: | ||
--only-dependencies only build rust dependencies (no js build, no wasm optimization) | ||
EOF | ||
} | ||
|
||
function help() { | ||
cat << EOF | ||
Builds the Internet Identity canister. | ||
NOTE: This requires a working rust toolchain as well as ic-cdk-optimizer. | ||
EOF | ||
|
||
} | ||
|
||
ONLY_DEPS= | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
case "$1" in | ||
-h|--help) | ||
title | ||
usage | ||
help | ||
exit 0 | ||
;; | ||
--only-dependencies) | ||
ONLY_DEPS=1 | ||
shift | ||
;; | ||
*) | ||
echo "ERROR: unknown argument $1" | ||
usage | ||
echo | ||
echo "Use 'build --help' for more information" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Checking for dependencies | ||
# XXX: we currently cannot check for the exact version of ic-cdk-optimizer | ||
# because of https://github.com/dfinity/cdk-rs/issues/181 | ||
# Once the issue is fixed, we can ensure that the correct version is installed | ||
if ! command -v ic-cdk-optimizer | ||
then | ||
echo could not find ic-cdk-optimizer | ||
echo "ic-cdk-optimizer version 0.3.1 is needed, please run the following command:" | ||
echo " cargo install ic-cdk-optimizer --version 0.3.1" | ||
exit 1 | ||
fi | ||
|
||
if [ "$ONLY_DEPS" != "1" ] | ||
then | ||
# Compile frontend assets to dist | ||
echo Compiling frontend assets | ||
npm run build | ||
fi | ||
|
||
II_DIR="$PWD/src/internet_identity" | ||
TARGET="wasm32-unknown-unknown" | ||
|
||
# standardize source references | ||
CARGO_HOME="${CARGO_HOME:-"$HOME/.cargo"}" | ||
RUSTFLAGS="--remap-path-prefix $CARGO_HOME=/cargo" | ||
|
||
cargo_build_args=( | ||
--manifest-path "$II_DIR/Cargo.toml" | ||
--target "$TARGET" | ||
--release | ||
-j1 | ||
) | ||
|
||
# This enables the "dummy_captcha" feature which makes sure the captcha string | ||
# is always "a". | ||
# WARNING: this MUST be opt-in, because we DO NOT want this in production, | ||
# EVAR. | ||
if [ "${II_DUMMY_CAPTCHA:-}" == "1" ] | ||
then | ||
echo "USING DUMMY CAPTCHA" | ||
cargo_build_args+=( --features dummy_captcha ) | ||
fi | ||
|
||
echo Running cargo build "${cargo_build_args[@]}" | ||
echo RUSTFLAGS: "$RUSTFLAGS" | ||
|
||
RUSTFLAGS="$RUSTFLAGS" cargo build "${cargo_build_args[@]}" | ||
|
||
if [ "$ONLY_DEPS" != "1" ] | ||
then | ||
CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$II_DIR/../../target/}" | ||
|
||
ic-cdk-optimizer \ | ||
"$CARGO_TARGET_DIR/$TARGET/release/internet_identity.wasm" \ | ||
-o "./internet_identity.wasm" | ||
fi |
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
This file was deleted.
Oops, something went wrong.