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

Move NPM build step inside of client variant logic inside of build_example #1175

Merged
merged 1 commit into from
Jun 24, 2020
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
61 changes: 32 additions & 29 deletions scripts/build_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ readonly SCRIPTS_DIR="$(dirname "$0")"
source "${SCRIPTS_DIR}/common"

application_language="rust"
client_variant="bazel"
client_variants="bazel"
compilation_mode='fastbuild'
docker_config=''
while getopts "e:a:c:di:h" opt; do
case "${opt}" in
h)
echo -e "Usage: ${0} [-h] [-a rust|cpp] [-c cargo|bazel] [-i base|logless] [-d] -e EXAMPLE
echo -e "Usage: ${0} [-h] [-a rust|cpp] [-c [cargo|bazel|npm]...] [-i base|logless] [-d] -e EXAMPLE

Build the given example Oak Application and client.

Expand All @@ -20,9 +20,11 @@ Options:
-a Example application variant:
- rust (used by default)
- cpp
-c Example client variant:
- cargo
- bazel (used by default)
-c Example client variants. Multiple clients can be specified by space
separating them. Eg -c \"cargo bazel npm\".
- cargo
- bazel (used by default)
- npm
-d Build C++ code for example using debug mode
-i This flag enables packaging the application into a Docker image,
and specifies the version of the Oak server, used by the application:
Expand All @@ -35,7 +37,7 @@ Options:
a)
application_language="${OPTARG}";;
c)
client_variant="${OPTARG}";;
client_variants="${OPTARG}";;
d)
compilation_mode='dbg';;
i)
Expand Down Expand Up @@ -105,27 +107,28 @@ if [[ -n "${docker_config}" ]]; then
fi
fi

case "${client_variant}" in
cargo)
cargo build --release "--manifest-path=./examples/${EXAMPLE}/client/rust/Cargo.toml"
;;
bazel)
bazel_build_flags+=(
'--symlink_prefix=bazel-client-'
"--compilation_mode=${compilation_mode}"
)

# Build the client with a different output_base so that we don't lose incremental state.
# See https://docs.bazel.build/versions/master/command-line-reference.html#flag--output_base.
bazel --output_base="${CACHE_DIR}/client" build "${bazel_build_flags[@]}" "//examples/${EXAMPLE}/client:all"
;;
*)
echo "Invalid example client variant: ${client_variant}"
exit 1;;
esac
# Build the application clients.
for client_variant in $client_variants
do
case "${client_variant}" in
cargo)
cargo build --release "--manifest-path=./examples/${EXAMPLE}/client/rust/Cargo.toml"
;;
bazel)
bazel_build_flags+=(
'--symlink_prefix=bazel-client-'
"--compilation_mode=${compilation_mode}"
)

# If a node client exists, install its dependencies
nodejs_client="./examples/${EXAMPLE}/client/nodejs"
if [[ -d "${nodejs_client}" ]]; then
npm ci --prefix "${nodejs_client}"
fi
# Build the client with a different output_base so that we don't lose incremental state.
# See https://docs.bazel.build/versions/master/command-line-reference.html#flag--output_base.
bazel --output_base="${CACHE_DIR}/client" build "${bazel_build_flags[@]}" "//examples/${EXAMPLE}/client:all"
;;
npm)
npm ci --prefix "./examples/${EXAMPLE}/client/nodejs"
;;
*)
echo "Invalid example client variant: ${client_variant}"
exit 1;;
esac
done
2 changes: 1 addition & 1 deletion scripts/run_example
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi


if [[ "${server}" != "none" ]]; then
"${SCRIPTS_DIR}/build_example" ${buildargs} -a "${application_language}" -e "${EXAMPLE}"
"${SCRIPTS_DIR}/build_example" ${buildargs} -a "${application_language}" -c "${client_variants}" -e "${EXAMPLE}"

# Run a server in the background.
# The server is being built before running, so the build process will not happen in the
Expand Down