forked from solderparty/i2c_puppet
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update comments * rename to beepy * Create Dockerfile * Update dbuild.sh * Create lib.sh * improve * Update and rename initialize-repo.sh to initialize-submodules.sh * reset submodules * +x * improve init * reset * build * rename * init when needed * improve readme * improve scripts * Delete Dockerfile
- Loading branch information
Showing
5 changed files
with
223 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env bash | ||
|
||
ORIGINAL_PWD=$(pwd) # Store the current working directory | ||
DIR="$(realpath "$( dirname "${BASH_SOURCE[0]}" )")" | ||
|
||
get_submodule_status() { | ||
submodule_path="$1" | ||
submodule_status=$(git submodule status "${submodule_path}") | ||
|
||
# Check the first character of the output to determine the status | ||
case "${submodule_status:0:1}" in | ||
'-') | ||
return 0 | ||
;; | ||
' ') | ||
return 1 | ||
;; | ||
'+') | ||
return 2 | ||
;; | ||
*) | ||
return 3 | ||
;; | ||
esac | ||
} | ||
|
||
echo_submodule_status() { | ||
submodule_path="$1" | ||
status_code="$2" | ||
|
||
case ${status_code} in | ||
0) | ||
echo "The submodule at ${submodule_path} is not initialized." | ||
;; | ||
1) | ||
echo "The submodule at ${submodule_path} is initialized and in-sync with superproject." | ||
;; | ||
2) | ||
echo "The submodule at ${submodule_path} is initialized and has changes." | ||
;; | ||
*) | ||
echo "Unknown status for the submodule at ${submodule_path}." | ||
;; | ||
esac | ||
} | ||
|
||
submodule_status() { | ||
submodule_path="$1" | ||
get_submodule_status "${submodule_path}" | ||
status_code=$? | ||
echo_submodule_status "${submodule_path}" "${status_code}" | ||
return "${status_code}" | ||
} | ||
|
||
initialize_submodule_if_not_initialized() { | ||
submodule_path="$1" | ||
original_pwd=$(pwd) # Store the current working directory | ||
|
||
# Navigate to the submodule's directory | ||
cd "${submodule_path}" || return 1 | ||
|
||
# Run the submodule_status function to get the status | ||
submodule_status "${submodule_path}" | ||
status_code=$? | ||
|
||
# If the status code is 0 (uninitialized), initialize the submodule | ||
if [[ ${status_code} -eq 0 ]]; then | ||
git submodule update --init | ||
echo "The submodule at ${submodule_path} has been initialized." | ||
fi | ||
|
||
# Return to the original working directory | ||
cd "${original_pwd}" || return 1 | ||
|
||
return 0 | ||
} | ||
|
||
initialize_submodule_if_not_initialized "${DIR}" | ||
initialize_submodule_if_not_initialized "${DIR}/3rdparty/pico-sdk" | ||
|
||
cd "${ORIGINAL_PWD}" || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
ORIGINAL_PWD=$(pwd) # Store the current working directory | ||
DIR="$(realpath "$( dirname "${BASH_SOURCE[0]}" )")" | ||
|
||
if [[ "${#}" -gt 0 ]]; then | ||
printf "%s\n" "Arguments passed to \`build-with-docker.sh\`." | ||
printf "%s\n" "\"Clean Run\" triggered." | ||
if [[ "${EUID}" -ne 0 ]]; then | ||
printf "%s\n" "Triggered behavior requires root access." | ||
printf "%s\n" "Please re-execute using \`sudo\` command." | ||
printf "%s\n" "Example: sudo !!" | ||
printf "%s\n" "Example: sudo $0 $@" | ||
exit 1 | ||
fi | ||
printf "%s\n" "Executing: \`rm -rf \"${DIR}/build\"\`" | ||
rm -rf "${DIR}/build" | ||
printf "%s\n" "Build directory deleted for \"Clean Run\"." | ||
fi | ||
|
||
"${DIR}/initialize-submodules.sh" | ||
|
||
docker run --rm -it \ | ||
-v "${DIR}/3rdparty/pico-sdk:/pico-sdk" \ | ||
-v "${DIR}:/project" \ | ||
djflix/rpi-pico-builder:latest \ | ||
bash -c 'mkdir -p build && cd build && cmake -DPICO_BOARD=beepy .. && make clean && make' | ||
|
||
cd "${ORIGINAL_PWD}" || exit 1 | ||
|
||
# DOCKER IMAGE DETAILS: | ||
# https://github.com/DJFliX/rpi-pico-builder (fork of original, smaller size, newer ubuntu version, available on docker hub) | ||
# https://github.com/xingrz/rpi-pico-builder (original, public archive repo, available on docker hub) | ||
# | ||
# Here is the entire Dockerfile as of 2023-08-25: | ||
# | ||
# BEGIN of DJFliX/rpi-pico-builder Dockerfile | ||
# FROM ubuntu:22.04 | ||
# | ||
# ENV DEBIAN_FRONTEND=noninteractive | ||
# RUN apt-get update | ||
# RUN apt-get install -y build-essential | ||
# RUN apt-get install -y python3 | ||
# RUN apt-get install -y cmake | ||
# RUN apt-get install -y gcc-arm-none-eabi libnewlib-arm-none-eabi \ | ||
# && rm -rf /usr/lib/arm-none-eabi/newlib/thumb/v8* \ | ||
# /usr/lib/arm-none-eabi/newlib/thumb/v7e* \ | ||
# /usr/lib/arm-none-eabi/newlib/thumb/v7ve+simd \ | ||
# /usr/lib/arm-none-eabi/newlib/thumb/v7-a* \ | ||
# /usr/lib/arm-none-eabi/newlib/thumb/v7-r+fp.sp \ | ||
# /usr/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e* \ | ||
# /usr/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-a* \ | ||
# /usr/lib/gcc/arm-none-eabi/10.3.1/thumb/v7+fp* \ | ||
# /usr/lib/gcc/arm-none-eabi/10.3.1/thumb/v8* | ||
# | ||
# VOLUME [ "/pico-sdk", "/project" ] | ||
# | ||
# ENV PICO_SDK_PATH=/pico-sdk | ||
# | ||
# WORKDIR /project | ||
# END of DJFliX/rpi-pico-builder Dockerfile | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
ORIGINAL_PWD=$(pwd) # Store the current working directory | ||
DIR="$(realpath "$( dirname "${BASH_SOURCE[0]}" )")" | ||
|
||
cd "${DIR}" || exit 1 | ||
|
||
git submodule foreach git submodule foreach git submodule foreach git reset --hard | ||
git submodule foreach git submodule foreach git reset --hard | ||
git submodule foreach git reset --hard | ||
git submodule update --recursive | ||
|
||
cd "${ORIGINAL_PWD}" || exit 1 |