Skip to content

Commit

Permalink
Add build directory existence check in compile scripts for Swift proj…
Browse files Browse the repository at this point in the history
…ects.
  • Loading branch information
rohitpaulk committed Sep 30, 2024
1 parent 5cc0c06 commit 59edd88
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiled_starters/swift/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@

set -e # Exit on failure

# Check if the build directory exists
if [ -d "/tmp/codecrafters-build-redis-swift" ]; then
echo "Build directory already exists. Proceeding with the build..."

# This does NOT trigger a rebuild
mv /tmp/codecrafters-build-redis-swift /tmp/codecrafters-build-redis-swift-old
mv /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift

# This DOES trigger a rebuild! inode changes?
# cp -R /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
else
echo "Build directory does not exist."
fi

swift build -c release --build-path /tmp/codecrafters-build-redis-swift
10 changes: 10 additions & 0 deletions compiled_starters/swift/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ set -e # Exit early if any commands fail
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
if [ -d "/tmp/codecrafters-build-redis-swift" ]; then
echo "Build directory already exists. Proceeding with the build..."
# This does NOT trigger a rebuild
mv /tmp/codecrafters-build-redis-swift /tmp/codecrafters-build-redis-swift-old
mv /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
# This DOES trigger a rebuild! inode changes?
# cp -R /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
else
echo "Build directory does not exist."
fi
swift build -c release --build-path /tmp/codecrafters-build-redis-swift
)

Expand Down
14 changes: 14 additions & 0 deletions solutions/swift/01-jm1/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@

set -e # Exit on failure

# Check if the build directory exists
if [ -d "/tmp/codecrafters-build-redis-swift" ]; then
echo "Build directory already exists. Proceeding with the build..."

# This does NOT trigger a rebuild
mv /tmp/codecrafters-build-redis-swift /tmp/codecrafters-build-redis-swift-old
mv /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift

# This DOES trigger a rebuild! inode changes?
# cp -R /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
else
echo "Build directory does not exist."
fi

swift build -c release --build-path /tmp/codecrafters-build-redis-swift
10 changes: 10 additions & 0 deletions solutions/swift/01-jm1/code/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ set -e # Exit early if any commands fail
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
if [ -d "/tmp/codecrafters-build-redis-swift" ]; then
echo "Build directory already exists. Proceeding with the build..."
# This does NOT trigger a rebuild
mv /tmp/codecrafters-build-redis-swift /tmp/codecrafters-build-redis-swift-old
mv /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
# This DOES trigger a rebuild! inode changes?
# cp -R /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
else
echo "Build directory does not exist."
fi
swift build -c release --build-path /tmp/codecrafters-build-redis-swift
)

Expand Down
14 changes: 14 additions & 0 deletions starter_templates/swift/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@

set -e # Exit on failure

# Check if the build directory exists
if [ -d "/tmp/codecrafters-build-redis-swift" ]; then
echo "Build directory already exists. Proceeding with the build..."

# This does NOT trigger a rebuild
mv /tmp/codecrafters-build-redis-swift /tmp/codecrafters-build-redis-swift-old
mv /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift

# This DOES trigger a rebuild! inode changes?
# cp -R /tmp/codecrafters-build-redis-swift-old /tmp/codecrafters-build-redis-swift
else
echo "Build directory does not exist."
fi

swift build -c release --build-path /tmp/codecrafters-build-redis-swift

0 comments on commit 59edd88

Please sign in to comment.