Skip to content

Commit bba9d83

Browse files
authored
Merge pull request #2 from blimmer/add-flag-to-strip-so-strip
Add a flag to skip .so file strip.
2 parents ac39cd9 + 175a1eb commit bba9d83

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Usage: build.sh [-p PYTHON_VER] [-n NAME] [-r] [-h] [-v]
5353
-n NAME : Name of the layer
5454
-r : Raw mode, don't zip layer contents
5555
-d : Don't install Python dependencies
56+
-s : Don't strip .so files
5657
-h : Help
5758
-v : Display build.sh version
5859
```

_make.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ rm -rf pip*
5656
find . -type d -name "tests" -exec rm -rf {} +
5757
find . -type d -name "test" -exec rm -rf {} +
5858
find . -type d -name "__pycache__" -exec rm -rf {} +
59-
find -name "*.so" -not -path "*/PIL/*" | xargs strip
60-
find -name "*.so.*" -not -path "*/PIL/*" | xargs strip
59+
if [[ "$STRIP" == true ]]; then
60+
find -name "*.so" -not -path "*/PIL/*" | xargs strip
61+
find -name "*.so.*" -not -path "*/PIL/*" | xargs strip
62+
fi
6163
find . -name '*.pyc' -delete
6264
if [[ -f "/temp/build/_clean.sh" ]]; then
6365
echo "Running custom cleaning script"

build.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ usage() {
3232
echo -e " -n NAME\t: Name of the layer"
3333
echo -e " -r\t\t: Raw mode, don't zip layer contents"
3434
echo -e " -d\t\t: Don't install Python dependencies"
35+
echo -e " -s\t\t: Don't strip .so files"
3536
echo -e " -h\t\t: Help"
3637
echo -e " -v\t\t: Display ${scriptname} version"
3738
}
3839

3940
# Handle configuration
40-
while getopts ":p:n:drhv" arg; do
41+
while getopts ":p:n:dsrhv" arg; do
4142
case "${arg}" in
4243
p) PYTHON_VER=${OPTARG};;
4344
n) NAME=${OPTARG};;
4445
r) RAW_MODE=true;;
4546
d) NO_DEPS=true;;
47+
s) STRIP=false;;
4648
h) usage; exit;;
4749
v) displayVer; exit;;
4850
\?) echo -e "Error - Invalid option: $OPTARG"; usage; exit;;
@@ -59,6 +61,7 @@ BASE_DIR=$(basename $CURRENT_DIR)
5961
PARENT_DIR=${CURRENT_DIR%"${BASE_DIR}"}
6062
RAW_MODE="${RAW_MODE:-false}"
6163
NO_DEPS="${NO_DEPS:-false}"
64+
STRIP="${STRIP:-true}"
6265

6366
# Find location of requirements.txt
6467
if [[ -f "${CURRENT_DIR}/requirements.txt" ]]; then
@@ -93,12 +96,12 @@ fi
9396

9497
if [[ "$RAW_MODE" = true ]]; then
9598
echo "Using RAW mode"
96-
else
99+
else
97100
echo "Using ZIP mode"
98101
fi
99102

100103
# Run build
101-
docker run --rm -e PYTHON_VER="$PYTHON_VER" -e NAME="$NAME" -e RAW_MODE="$RAW_MODE" -e NO_DEPS="$NO_DEPS" -e PARENT_DIR="${PARENT_DIR}" -e SUBDIR_MODE="$SUBDIR_MODE" -v "$CURRENT_DIR":/var/task -v "$REQ_PATH":/temp/build/requirements.txt -v "$CLEAN_PATH":/temp/build/_clean.sh "lambci/lambda:build-python${PYTHON_VER}" bash /var/task/_make.sh
104+
docker run --rm -e PYTHON_VER="$PYTHON_VER" -e NAME="$NAME" -e RAW_MODE="$RAW_MODE" -e NO_DEPS="$NO_DEPS" -e STRIP="$STRIP" -e PARENT_DIR="${PARENT_DIR}" -e SUBDIR_MODE="$SUBDIR_MODE" -v "$CURRENT_DIR":/var/task -v "$REQ_PATH":/temp/build/requirements.txt -v "$CLEAN_PATH":/temp/build/_clean.sh "lambci/lambda:build-python${PYTHON_VER}" bash /var/task/_make.sh
102105

103106
# Move ZIP to parent dir if SUBDIR_MODE set
104107
if [[ "$SUBDIR_MODE" ]]; then

0 commit comments

Comments
 (0)