forked from apple/containerization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
166 lines (137 loc) · 5.22 KB
/
Makefile
File metadata and controls
166 lines (137 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Version and build configuration variables
# The default version ID 0.0.0 indicates a local development build or PRB
BUILD_CONFIGURATION ?= debug
# Commonly used locations
SWIFT := "/usr/bin/swift"
ROOT_DIR := $(shell git rev-parse --show-toplevel)
BUILD_BIN_DIR = $(shell $(SWIFT) build -c $(BUILD_CONFIGURATION) --show-bin-path)
# Variables for libarchive integration
LIBARCHIVE_UPSTREAM_REPO := https://github.com/libarchive/libarchive
LIBARCHIVE_UPSTREAM_VERSION := v3.7.7
LIBARCHIVE_LOCAL_DIR := workdir/libarchive
KATA_BINARY_PACKAGE := https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz
include Protobuf.Makefile
.DEFAULT_GOAL := all
.PHONY: all
all: swift-build
all: containerization
all: init
.PHONY: release
release: BUILD_CONFIGURATION = release
release: all
.PHONY: containerization
containerization: bin/cctl bin/containerization-integration
.PHONY: swift-build
swift-build:
@echo Building containerization binaries...
@$(SWIFT) build -c $(BUILD_CONFIGURATION)
$(BUILD_BIN_DIR)/cctl $(BUILD_BIN_DIR)/containerization-integration:
@"$(MAKE)" swift-build
bin/%: $(BUILD_BIN_DIR)/%
@mkdir -p bin/
@install $< bin/
@codesign --force --sign - --timestamp=none --entitlements=signing/vz.entitlements $@
init := bin/init.rootfs.tar.gz
.PHONY: init
init: $(init)
$(init): vminitd/bin/vminitd vminitd/bin/vmexec bin/cctl
@echo Creating init.ext4...
@rm -f $(init) bin/init.block
@./bin/cctl rootfs create --vminitd vminitd/bin/vminitd --labels org.opencontainers.image.source=https://github.com/apple/containerization --vmexec vminitd/bin/vmexec $(init) vminit:latest
.PHONY: cross-prep
cross-prep:
@"$(MAKE)" -C vminitd cross-prep
.PHONY: vminitd
vminitd: vminitd/bin/vminitd vminitd/bin/vmexec
vminitd/bin/%:
@"$(MAKE)" -C vminitd BUILD_CONFIGURATION=$(BUILD_CONFIGURATION) bin/$*
.PHONY: update-libarchive-source
update-libarchive-source:
@echo Updating the libarchive source files...
@git clone $(LIBARCHIVE_UPSTREAM_REPO) --depth 1 --branch $(LIBARCHIVE_UPSTREAM_VERSION) $(LIBARCHIVE_LOCAL_DIR)
@cp $(LIBARCHIVE_LOCAL_DIR)/libarchive/archive_entry.h Sources/ContainerizationArchive/CArchive/include
@cp $(LIBARCHIVE_LOCAL_DIR)/libarchive/archive.h Sources/ContainerizationArchive/CArchive/include
@cp $(LIBARCHIVE_LOCAL_DIR)/COPYING Sources/ContainerizationArchive/CArchive/COPYING
@rm -rf $(LIBARCHIVE_LOCAL_DIR)
.PHONY: test
test:
@echo Testing all test targets...
@$(SWIFT) test --enable-code-coverage
.PHONY: integration
integration:
ifeq (,$(wildcard bin/vmlinux))
@echo No bin/vmlinux kernel found. See fetch-default-kernel target.
@exit 1
endif
@"$(MAKE)" integration-kernel-checked
.PHONY: integration-kernel-checked
integration-kernel-checked: $(init) bin/containerization-integration
@echo Running the integration tests...
@./bin/containerization-integration --bootlog ./bin/boot.log
.PHONY: fetch-default-kernel
fetch-default-kernel:
@mkdir -p .local/ bin/
ifeq (,$(wildcard .local/kata.tar.gz))
@curl -SsL -o .local/kata.tar.gz ${KATA_BINARY_PACKAGE}
endif
ifeq (,$(wildcard .local/vmlinux))
@tar -zxf .local/kata.tar.gz -C .local/ --strip-components=1
@cp -L .local/opt/kata/share/kata-containers/vmlinux.container .local/vmlinux
endif
ifeq (,$(wildcard bin/vmlinux))
@cp .local/vmlinux bin/vmlinux
endif
.PHONY: fmt
fmt: swift-fmt update-licenses
.PHONY: swift-fmt
SWIFT_SRC = $(shell find . -type f -name '*.swift' -not -path "*/.*" -not -path "*.pb.swift" -not -path "*.grpc.swift" -not -path "*/checkouts/*")
swift-fmt:
@echo Applying the standard code formatting...
@$(SWIFT) format --recursive --configuration .swift-format -i $(SWIFT_SRC)
.PHONY: update-licenses
update-licenses:
@echo Updating license headers...
@./scripts/ensure-hawkeye-exists.sh
@.local/bin/hawkeye format --fail-if-unknown --fail-if-updated false
.PHONY: check-licenses
check-licenses:
@echo Checking license headers existence in source files...
@./scripts/ensure-hawkeye-exists.sh
@.local/bin/hawkeye check --fail-if-unknown
.PHONY: serve-docs
serve-docs:
@echo 'to browse: open http://127.0.0.1:8000/containerization/documentation/'
@rm -rf _serve
@mkdir -p _serve
@cp -a _site _serve/containerization
@python3 -m http.server --bind 127.0.0.1 --directory ./_serve
.PHONY: docs
docs:
@echo Updating API documentation...
@rm -rf _site
@scripts/make-docs.sh _site containerization
.PHONY: cleancontent
cleancontent:
@echo Cleaning the content...
@rm -rf ~/Library/Application\ Support/com.apple.containerization
.PHONY: clean
clean:
@echo Cleaning the build files...
@rm -rf bin/
@rm -rf _site/
@rm -rf _serve/
@$(SWIFT) package clean
@"$(MAKE)" -C vminitd clean