Skip to content

Commit

Permalink
fix shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rauhul committed Jan 3, 2025
1 parent 2efbf9d commit 1020c2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
20 changes: 10 additions & 10 deletions pico-blink/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ REPOROOT=$(git rev-parse --show-toplevel)
TOOLSROOT=$REPOROOT/Tools

# Setup tools and build flags
SWIFT_EXEC=${SWIFT_EXEC:-`xcrun -f swift`}
CLANG=${CLANG:-`xcrun -f clang`}
SWIFT_EXEC=${SWIFT_EXEC:-$(xcrun -f swift)}
CLANG=${CLANG:-$(xcrun -f clang)}
SWIFT_FLAGS="-enable-experimental-feature Embedded -disable-stack-protector"
CLANG_FLAGS="-D__MACH__ -ffreestanding -mcpu=cortex-m0plus -mthumb"
LD_FLAGS="-static -Wl,-e,_reset -dead_strip -Wl,-no_zero_fill_sections -Wl,-segalign,4 -Wl,-segaddr,__RESET,0x20000000 -Wl,-segaddr,__VECTORS,0x20000100 -Wl,-seg1addr,0x20000200 -Wl,-pagezero_size,0"

SWIFT_BUILD_FLAGS="--triple armv6m-apple-none-macho --configuration release --verbose"
for SWIFT_FLAG in $SWIFT_FLAGS; do
SWIFT_BUILD_FLAGS+=" -Xswiftc $SWIFT_FLAG"
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS -Xswiftc $SWIFT_FLAG"
done

for CLANG_FLAG in $CLANG_FLAGS; do
SWIFT_BUILD_FLAGS+=" -Xcc $CLANG_FLAG"
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS -Xcc $CLANG_FLAG"
done

PYTHON_EXEC=${PYTHON_EXEC:-`xcrun -f python3`}
PYTHON_EXEC=${PYTHON_EXEC:-$(xcrun -f python3)}
MACHO2UF2=$TOOLSROOT/macho2uf2.py

# Build with Swift package manager
$SWIFT_EXEC build $SWIFT_BUILD_FLAGS
$SWIFT_EXEC build "$SWIFT_BUILD_FLAGS"

# Get the output directory
BUILDROOT=$($SWIFT_EXEC build $SWIFT_BUILD_FLAGS --show-bin-path)
BUILDROOT=$($SWIFT_EXEC build "$SWIFT_BUILD_FLAGS" --show-bin-path)

# Link
$CLANG .build/release/Support.build/{Support.c,crt0.S}.o .build/release/Blinky.build/*.o -target armv6m-apple-none-macho -o $BUILDROOT/blinky $LD_FLAGS
$CLANG .build/release/Support.build/Support.c.o .build/release/Support.build/crt0.S.o .build/release/Blinky.build/*.o -target armv6m-apple-none-macho -o "$BUILDROOT"/blinky "$LD_FLAGS"

# Extract sections from executable into flashable binary
$PYTHON_EXEC $MACHO2UF2 --pico-family $PICO_FAMILY $BUILDROOT/blinky $BUILDROOT/blinky.uf2 --base-address 0x20000000 --segments '__TEXT,__DATA,__VECTORS,__RESET'
$PYTHON_EXEC "$MACHO2UF2" --pico-family $PICO_FAMILY "$BUILDROOT"/blinky "$BUILDROOT"/blinky.uf2 --base-address 0x20000000 --segments '__TEXT,__DATA,__VECTORS,__RESET'

# Echo final binary path
ls -al $BUILDROOT/blinky.uf2
ls -al "$BUILDROOT"/blinky.uf2
26 changes: 13 additions & 13 deletions stm32-blink/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ set -vex

# Determine file paths
REPOROOT=$(git rev-parse --show-toplevel)
TOOLSROOT=$REPOROOT/Tools
SRCROOT=$REPOROOT/stm32-blink
BUILDROOT=$SRCROOT/.build
TOOLSROOT="$REPOROOT/Tools"
SRCROOT="$REPOROOT/stm32-blink"
BUILDROOT="$SRCROOT/.build"

# Setup tools and build flags
TARGET=armv7-apple-none-macho

SWIFT_EXEC=${SWIFT_EXEC:-`xcrun -f swiftc`}
SWIFT_EXEC=${SWIFT_EXEC:-$(xcrun -f swiftc)}
SWIFT_FLAGS="-target $TARGET -Osize -import-bridging-header $SRCROOT/BridgingHeader.h -wmo -enable-experimental-feature Embedded -Xcc -D__APPLE__ -Xcc -D__MACH__ -Xcc -ffreestanding"

CLANG_EXEC=${CLANG_EXEC:-`xcrun -f clang`}
CLANG_EXEC=${CLANG_EXEC:-$(xcrun -f clang)}
CLANG_FLAGS="-target $TARGET -Oz"

LD_EXEC=${LD_EXEC:-$CLANG_EXEC}
LD_FLAGS="-target $TARGET -nostdlib -static -Wl,-e,_reset -dead_strip -Wl,-no_zero_fill_sections -Wl,-segalign,4 -Wl,-segaddr,__VECTORS,0x00200000 -Wl,-seg1addr,0x00200200 -Wl,-pagezero_size,0"

PYTHON_EXEC=${PYTHON_EXEC:-`xcrun -f python3`}
MACHO2BIN=$TOOLSROOT/macho2bin.py
PYTHON_EXEC=${PYTHON_EXEC:-$(xcrun -f python3)}
MACHO2BIN="$TOOLSROOT/macho2bin.py"

# Create build directory
mkdir -p $BUILDROOT
mkdir -p "$BUILDROOT"

# Build Swift sources
$SWIFT_EXEC $SWIFT_FLAGS -c $SRCROOT/*.swift -o $BUILDROOT/blink.o
"$SWIFT_EXEC" "$SWIFT_FLAGS" -c "$SRCROOT/*.swift" -o "$BUILDROOT/blink.o"

# Build C sources
$CLANG_EXEC $CLANG_FLAGS -c $SRCROOT/Startup.c -o $BUILDROOT/Startup.o
"$CLANG_EXEC" "$CLANG_FLAGS" -c "$SRCROOT/Startup.c" -o "$BUILDROOT/Startup.o"

# Link objects into executable
$LD_EXEC $LD_FLAGS $BUILDROOT/blink.o $BUILDROOT/Startup.o -o $BUILDROOT/blink
"$LD_EXEC" "$LD_FLAGS" "$BUILDROOT/blink.o" "$BUILDROOT/Startup.o" -o "$BUILDROOT/blink"

# Extract sections from executable into flashable binary
$PYTHON_EXEC $MACHO2BIN $BUILDROOT/blink $BUILDROOT/blink.bin --base-address 0x00200000 --segments '__TEXT,__DATA,__VECTORS'
"$PYTHON_EXEC" "$MACHO2BIN" "$BUILDROOT/blink" "$BUILDROOT/blink.bin" --base-address 0x00200000 --segments '__TEXT,__DATA,__VECTORS'

# Echo final binary path
ls -al $BUILDROOT/blink.bin
ls -al "$BUILDROOT/blink.bin"
4 changes: 0 additions & 4 deletions stm32-lcd-logo/build.sh

This file was deleted.

0 comments on commit 1020c2a

Please sign in to comment.