Skip to content

Commit 6a31184

Browse files
authored
Handle warnings as errors (#271)
To handle warnings as errors when building, use `make`. To allow warnings, use `make WARNINGS_AS_ERRORS=false test`. Also see apple/container#535.
1 parent f92c0cd commit 6a31184

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Build configuration variables
1616
# The default version ID 0.0.0 indicates a local development build or PRB
1717
BUILD_CONFIGURATION ?= debug
18+
WARNINGS_AS_ERRORS ?= true
19+
SWIFT_CONFIGURATION = $(if $(filter-out false,$(WARNINGS_AS_ERRORS)),-Xswiftc -warnings-as-errors)
1820

1921
# Commonly used locations
2022
SWIFT := "/usr/bin/swift"
@@ -42,7 +44,7 @@ release: all
4244
.PHONY: containerization
4345
containerization:
4446
@echo Building containerization binaries...
45-
@$(SWIFT) build -c $(BUILD_CONFIGURATION)
47+
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)
4648

4749
@echo Copying containerization binaries...
4850
@mkdir -p bin
@@ -71,7 +73,7 @@ cross-prep:
7173
.PHONY: vminitd
7274
vminitd:
7375
@mkdir -p ./bin
74-
@"$(MAKE)" -C vminitd BUILD_CONFIGURATION=$(BUILD_CONFIGURATION)
76+
@"$(MAKE)" -C vminitd BUILD_CONFIGURATION=$(BUILD_CONFIGURATION) WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS)
7577

7678
.PHONY: update-libarchive-source
7779
update-libarchive-source:
@@ -85,7 +87,7 @@ update-libarchive-source:
8587
.PHONY: test
8688
test:
8789
@echo Testing all test targets...
88-
@$(SWIFT) test --enable-code-coverage
90+
@$(SWIFT) test --enable-code-coverage $(SWIFT_CONFIGURATION)
8991

9092
.PHONY: integration
9193
integration:

vminitd/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# limitations under the License.
1414

1515
BUILD_CONFIGURATION := debug
16-
SWIFT_CONFIGURATION := --swift-sdk aarch64-swift-linux-musl
16+
WARNINGS_AS_ERRORS ?= true
17+
SWIFT_WARNING_CONFIG = $(if $(filter-out false,$(WARNINGS_AS_ERRORS)),-Xswiftc -warnings-as-errors)
18+
SWIFT_CONFIGURATION := --swift-sdk aarch64-swift-linux-musl $(SWIFT_WARNING_CONFIG)
1719

1820
SWIFT_VERSION = 6.2-snapshot-2025-06-25
1921
SWIFT_SDK_URL = https://download.swift.org/swift-6.2-branch/static-sdk/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-25-a/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-25-a_static-linux-0.0.1.artifactbundle.tar.gz

0 commit comments

Comments
 (0)