Skip to content

Commit 934d254

Browse files
marcomagdyMarco Magdy
and
Marco Magdy
authored
Use the Lambda executable as the bootstrap when glibc is not required (#191)
* Use the Lambda executable as the bootstrap when glibc is not required * Fix integration tests --------- Co-authored-by: Marco Magdy <[email protected]>
1 parent e08ca6e commit 934d254

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

packaging/packager

+2-11
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,11 @@ exec \$LAMBDA_TASK_ROOT/lib/$PKG_LD --library-path \$LAMBDA_TASK_ROOT/lib \$LAMB
171171
EOF
172172
)
173173

174-
bootstrap_script_no_libc=$(cat <<EOF
175-
#!/bin/bash
176-
set -euo pipefail
177-
export AWS_EXECUTION_ENV=lambda-cpp
178-
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$LAMBDA_TASK_ROOT/lib
179-
exec \$LAMBDA_TASK_ROOT/bin/$PKG_BIN_FILENAME \${_HANDLER}
180-
EOF
181-
)
182-
183-
cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
184174
if [[ $INCLUDE_LIBC == true ]]; then
175+
cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
185176
echo -e "$bootstrap_script" > "$PKG_DIR/bootstrap"
186177
else
187-
echo -e "$bootstrap_script_no_libc" > "$PKG_DIR/bootstrap"
178+
cp "$PKG_BIN_PATH" "$PKG_DIR/bootstrap"
188179
fi
189180
chmod +x "$PKG_DIR/bootstrap"
190181
# some shenanigans to create the right layout in the zip file without extraneous directories

tests/resources/lambda_function.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ int main(int argc, char* argv[])
4141
handlers.emplace("binary_response", binary_response);
4242
handlers.emplace("crash_backtrace", crash_backtrace);
4343

44-
if (argc < 2) {
45-
aws::logging::log_error("lambda_fun", "Missing handler argument. Exiting.");
46-
return -1;
47-
}
48-
49-
auto it = handlers.find(argv[1]);
44+
// Read the handler from the environment variable
45+
const char* handler_name = std::getenv("_HANDLER");
46+
auto it = handlers.find(handler_name == nullptr ? "" : handler_name);
5047
if (it == handlers.end()) {
5148
aws::logging::log_error("lambda_fun", "Handler %s not found. Exiting.", argv[1]);
5249
return -2;

0 commit comments

Comments
 (0)