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

feat(flags): add support for feature flags #37

Merged
merged 5 commits into from
Sep 5, 2023
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
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,22 @@ jobs:
- run: nargo new project
- run: nargo check
working-directory: ./project
- run: nargo compile test-circuit
- run: |
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
# 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
name: nargo compile
working-directory: ./project
shell: bash
- run: nargo test
if: matrix.toolchain != '0.1.0'
working-directory: ./project
20 changes: 18 additions & 2 deletions noirup
Original file line number Diff line number Diff line change
Expand Up @@ -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;;
Expand All @@ -28,6 +29,16 @@ main() {
esac; shift
done

# 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
NOIRUP_BRANCH="refs/pull/$NOIRUP_PR/head"
Expand All @@ -48,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 # 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"
Expand All @@ -60,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)"
Expand Down Expand Up @@ -146,7 +161,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

# Remove prior installations if they exist
rm -f "$NARGO_BIN_DIR/nargo"
Expand Down Expand Up @@ -177,6 +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: "feature1 feature2"
EOF
}

Expand Down