From 3d16c2fbc515b3877d99abbd84db420b0418502c Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 22 Aug 2023 15:56:11 +0000 Subject: [PATCH 1/5] feat(flags): add support for feature flags --- noirup | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/noirup b/noirup index 46513c2..a57ce64 100755 --- a/noirup +++ b/noirup @@ -16,6 +16,7 @@ main() { -r|--repo) shift; NOIRUP_REPO=$1;; -b|--branch) shift; NOIRUP_BRANCH=$1;; -v|--version) shift; NOIRUP_VERSION=$1;; + -f|--features) shift; NOIRUP_FEATURES=$1;; -p|--path) shift; NOIRUP_LOCAL_REPO=$1;; -P|--pr) shift; NOIRUP_PR=$1;; -C|--commit) shift; NOIRUP_COMMIT=$1;; @@ -28,6 +29,8 @@ main() { esac; shift done + FEATURES=${NOIRUP_FEATURES:-"default"} + if [ -n "$NOIRUP_PR" ]; then if [ -z "$NOIRUP_BRANCH" ]; then NOIRUP_BRANCH="refs/pull/$NOIRUP_PR/head" @@ -48,7 +51,7 @@ main() { # Enter local repo and build say "installing from $NOIRUP_LOCAL_REPO" cd $NOIRUP_LOCAL_REPO - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release # need 4 speed + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --features $FEATURES # need 4 speed # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" @@ -146,7 +149,7 @@ main() { ensure git checkout ${NOIRUP_COMMIT} fi - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --features $FEATURES # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" @@ -177,6 +180,7 @@ OPTIONS: -C, --commit Install a specific commit -r, --repo Install from a remote GitHub repo (uses default branch if no other options are set) -p, --path Install a local repository + -f, --features Activates feature flags when building from source EOF } From 67fc5eba0187cebd69105780badf7e3825784f11 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 22 Aug 2023 17:50:28 +0000 Subject: [PATCH 2/5] fix: update workflow to account for new versions --- .github/workflows/ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1b2df6..7657b0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,8 +115,22 @@ jobs: - run: nargo new project - run: nargo check working-directory: ./project - - run: nargo compile test-circuit + - run: | + if [[ "${{ matrix.toolchain }}" == "stable" || "${{ matrix.toolchain }}" == "nightly" ]]; then + nargo compile + else + minor=$(echo "${{ matrix.toolchain }}" | cut -d '.' -f 2) + + # The version in which the compile syntax changed + if [ "$minor" -lt 10 ]; then + nargo compile test-circuit + else + nargo compile + fi + fi + name: nargo compile working-directory: ./project + shell: bash - run: nargo test if: matrix.toolchain != '0.1.0' working-directory: ./project From 060b0251d5df42ac8423fe9e9d5cb8699756e5e7 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:05:54 +0000 Subject: [PATCH 3/5] fix: review comments, support multiple flags --- noirup | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/noirup b/noirup index a57ce64..b767488 100755 --- a/noirup +++ b/noirup @@ -16,7 +16,7 @@ main() { -r|--repo) shift; NOIRUP_REPO=$1;; -b|--branch) shift; NOIRUP_BRANCH=$1;; -v|--version) shift; NOIRUP_VERSION=$1;; - -f|--features) shift; NOIRUP_FEATURES=$1;; + -f|--features) shift; NOIRUP_FEATURES=$1;; -p|--path) shift; NOIRUP_LOCAL_REPO=$1;; -P|--pr) shift; NOIRUP_PR=$1;; -C|--commit) shift; NOIRUP_COMMIT=$1;; @@ -29,7 +29,15 @@ main() { esac; shift done - FEATURES=${NOIRUP_FEATURES:-"default"} + # Input string is a space delimited list of features + # Build a string of feature flags to pass to cargo + FEATURES="" + if [ -n "$NOIRUP_FEATURES" ]; then + # "aztec bn254" -> "--features aztec --features bn254" + for feature in $NOIRUP_FEATURES; do + FEATURES+="--features $feature " + done + fi if [ -n "$NOIRUP_PR" ]; then if [ -z "$NOIRUP_BRANCH" ]; then @@ -51,7 +59,7 @@ main() { # Enter local repo and build say "installing from $NOIRUP_LOCAL_REPO" cd $NOIRUP_LOCAL_REPO - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --features $FEATURES # need 4 speed + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --no-default-features $FEATURES # need 4 speed # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" @@ -63,6 +71,10 @@ main() { exit 0 fi + if [ -n "${NOIRUP_FEATURES}" ]; then + echo "Warning: [-f | --features] flag has no effect when installing a prebuilt binary" + fi + NOIRUP_REPO=${NOIRUP_REPO-noir-lang/noir} if [[ "$NOIRUP_REPO" == "noir-lang/noir" && -z "$NOIRUP_BRANCH" && -z "$NOIRUP_COMMIT" ]]; then PLATFORM="$(uname -s)" @@ -149,7 +161,7 @@ main() { ensure git checkout ${NOIRUP_COMMIT} fi - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --features $FEATURES + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --no-default-features $FEATURES # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" @@ -180,7 +192,7 @@ OPTIONS: -C, --commit Install a specific commit -r, --repo Install from a remote GitHub repo (uses default branch if no other options are set) -p, --path Install a local repository - -f, --features Activates feature flags when building from source + -f, --features Activates feature flags when building from source: "feature1 feature2" EOF } From 1c46e12119580720b75913cf4933b95e9d0fa1aa Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:12:57 +0000 Subject: [PATCH 4/5] revert: --no-default-features --- noirup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noirup b/noirup index b767488..c78a3b9 100755 --- a/noirup +++ b/noirup @@ -59,7 +59,7 @@ main() { # Enter local repo and build say "installing from $NOIRUP_LOCAL_REPO" cd $NOIRUP_LOCAL_REPO - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --no-default-features $FEATURES # need 4 speed + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES # need 4 speed # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" @@ -161,7 +161,7 @@ main() { ensure git checkout ${NOIRUP_COMMIT} fi - RUSTFLAGS="-C target-cpu=native" ensure cargo build --release --no-default-features $FEATURES + RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES # Remove prior installations if they exist rm -f "$NARGO_BIN_DIR/nargo" From 46b9d013dfd90e7089d90e725d7f43eff20306b8 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:44:14 +0000 Subject: [PATCH 5/5] fix: use version output rather than reading from matrix, reducing branches --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7657b0b..056404f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,17 +116,17 @@ jobs: - run: nargo check working-directory: ./project - run: | - if [[ "${{ matrix.toolchain }}" == "stable" || "${{ matrix.toolchain }}" == "nightly" ]]; then - nargo compile - else - minor=$(echo "${{ matrix.toolchain }}" | cut -d '.' -f 2) + # Extract the minor version number from the version output + version=$(nargo --version) + version="${version#* }" + version="${version%% (*}" + minor=$(echo $version | cut -d '.' -f 2) - # The version in which the compile syntax changed - if [ "$minor" -lt 10 ]; then - nargo compile test-circuit - else - nargo compile - fi + # The version in which the compile syntax changed + if [ "$minor" -lt 10 ]; then + nargo compile test-circuit + else + nargo compile fi name: nargo compile working-directory: ./project