Skip to content

Commit

Permalink
Use the Lambda executable as the bootstrap when glibc is not required (
Browse files Browse the repository at this point in the history
…#191)

* Use the Lambda executable as the bootstrap when glibc is not required

* Fix integration tests

---------

Co-authored-by: Marco Magdy <[email protected]>
  • Loading branch information
marcomagdy and Marco Magdy authored Nov 16, 2023
1 parent e08ca6e commit 934d254
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
13 changes: 2 additions & 11 deletions packaging/packager
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,11 @@ exec \$LAMBDA_TASK_ROOT/lib/$PKG_LD --library-path \$LAMBDA_TASK_ROOT/lib \$LAMB
EOF
)

bootstrap_script_no_libc=$(cat <<EOF
#!/bin/bash
set -euo pipefail
export AWS_EXECUTION_ENV=lambda-cpp
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$LAMBDA_TASK_ROOT/lib
exec \$LAMBDA_TASK_ROOT/bin/$PKG_BIN_FILENAME \${_HANDLER}
EOF
)

cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
if [[ $INCLUDE_LIBC == true ]]; then
cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
echo -e "$bootstrap_script" > "$PKG_DIR/bootstrap"
else
echo -e "$bootstrap_script_no_libc" > "$PKG_DIR/bootstrap"
cp "$PKG_BIN_PATH" "$PKG_DIR/bootstrap"
fi
chmod +x "$PKG_DIR/bootstrap"
# some shenanigans to create the right layout in the zip file without extraneous directories
Expand Down
9 changes: 3 additions & 6 deletions tests/resources/lambda_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ int main(int argc, char* argv[])
handlers.emplace("binary_response", binary_response);
handlers.emplace("crash_backtrace", crash_backtrace);

if (argc < 2) {
aws::logging::log_error("lambda_fun", "Missing handler argument. Exiting.");
return -1;
}

auto it = handlers.find(argv[1]);
// Read the handler from the environment variable
const char* handler_name = std::getenv("_HANDLER");
auto it = handlers.find(handler_name == nullptr ? "" : handler_name);
if (it == handlers.end()) {
aws::logging::log_error("lambda_fun", "Handler %s not found. Exiting.", argv[1]);
return -2;
Expand Down

0 comments on commit 934d254

Please sign in to comment.