Skip to content

Commit 18d911b

Browse files
authored
feat(flags): add support for feature flags (#37)
1 parent 19af0e4 commit 18d911b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,22 @@ jobs:
115115
- run: nargo new project
116116
- run: nargo check
117117
working-directory: ./project
118-
- run: nargo compile test-circuit
118+
- run: |
119+
# Extract the minor version number from the version output
120+
version=$(nargo --version)
121+
version="${version#* }"
122+
version="${version%% (*}"
123+
minor=$(echo $version | cut -d '.' -f 2)
124+
125+
# The version in which the compile syntax changed
126+
if [ "$minor" -lt 10 ]; then
127+
nargo compile test-circuit
128+
else
129+
nargo compile
130+
fi
131+
name: nargo compile
119132
working-directory: ./project
133+
shell: bash
120134
- run: nargo test
121135
if: matrix.toolchain != '0.1.0'
122136
working-directory: ./project

noirup

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ main() {
1616
-r|--repo) shift; NOIRUP_REPO=$1;;
1717
-b|--branch) shift; NOIRUP_BRANCH=$1;;
1818
-v|--version) shift; NOIRUP_VERSION=$1;;
19+
-f|--features) shift; NOIRUP_FEATURES=$1;;
1920
-p|--path) shift; NOIRUP_LOCAL_REPO=$1;;
2021
-P|--pr) shift; NOIRUP_PR=$1;;
2122
-C|--commit) shift; NOIRUP_COMMIT=$1;;
@@ -28,6 +29,16 @@ main() {
2829
esac; shift
2930
done
3031

32+
# Input string is a space delimited list of features
33+
# Build a string of feature flags to pass to cargo
34+
FEATURES=""
35+
if [ -n "$NOIRUP_FEATURES" ]; then
36+
# "aztec bn254" -> "--features aztec --features bn254"
37+
for feature in $NOIRUP_FEATURES; do
38+
FEATURES+="--features $feature "
39+
done
40+
fi
41+
3142
if [ -n "$NOIRUP_PR" ]; then
3243
if [ -z "$NOIRUP_BRANCH" ]; then
3344
NOIRUP_BRANCH="refs/pull/$NOIRUP_PR/head"
@@ -48,7 +59,7 @@ main() {
4859
# Enter local repo and build
4960
say "installing from $NOIRUP_LOCAL_REPO"
5061
cd $NOIRUP_LOCAL_REPO
51-
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release # need 4 speed
62+
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES # need 4 speed
5263

5364
# Remove prior installations if they exist
5465
rm -f "$NARGO_BIN_DIR/nargo"
@@ -60,6 +71,10 @@ main() {
6071
exit 0
6172
fi
6273

74+
if [ -n "${NOIRUP_FEATURES}" ]; then
75+
echo "Warning: [-f | --features] flag has no effect when installing a prebuilt binary"
76+
fi
77+
6378
NOIRUP_REPO=${NOIRUP_REPO-noir-lang/noir}
6479
if [[ "$NOIRUP_REPO" == "noir-lang/noir" && -z "$NOIRUP_BRANCH" && -z "$NOIRUP_COMMIT" ]]; then
6580
PLATFORM="$(uname -s)"
@@ -146,7 +161,7 @@ main() {
146161
ensure git checkout ${NOIRUP_COMMIT}
147162
fi
148163

149-
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release
164+
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES
150165

151166
# Remove prior installations if they exist
152167
rm -f "$NARGO_BIN_DIR/nargo"
@@ -177,6 +192,7 @@ OPTIONS:
177192
-C, --commit Install a specific commit
178193
-r, --repo Install from a remote GitHub repo (uses default branch if no other options are set)
179194
-p, --path Install a local repository
195+
-f, --features Activates feature flags when building from source: "feature1 feature2"
180196
EOF
181197
}
182198

0 commit comments

Comments
 (0)