Skip to content

Commit cf05ec6

Browse files
authored
Add tee-sev-snp target and Katana build confirmation (#436)
* Adds a new `make tee-sev-snp` target that builds AMD SEV-SNP VM components via `misc/AMDSEV/build.sh`. * Updates `build.sh` so missing `--katana` now asks for confirmation before building the Katana binary from source.
1 parent affddaa commit cf05ec6

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SIMPLE_DB := $(DB_FIXTURES_DIR)/simple
2323
CONTRACTS_CRATE := crates/contracts
2424
CONTRACTS_DIR := $(CONTRACTS_CRATE)/contracts
2525
CONTRACTS_BUILD_DIR := $(CONTRACTS_CRATE)/build
26+
AMDSEV_DIR := misc/AMDSEV
2627

2728
VRF_DIR := $(CONTRACTS_DIR)/vrf
2829
AVNU_DIR := $(CONTRACTS_DIR)/avnu/contracts
@@ -41,14 +42,15 @@ SCARB_REQUIRED_VERSIONS := $(sort $(SCARB_VERSION) $(AVNU_SCARB_VERSION) $(VRF_S
4142

4243
.DEFAULT_GOAL := usage
4344
.SILENT: clean
44-
.PHONY: usage help check-llvm native-deps native-deps-macos native-deps-linux native-deps-windows build-explorer contracts clean deps install-scarb fixtures snos-artifacts db-compat-artifacts generate-db-fixtures install-pyenv
45+
.PHONY: usage help check-llvm native-deps native-deps-macos native-deps-linux native-deps-windows build-explorer contracts tee-sev-snp clean deps install-scarb fixtures snos-artifacts db-compat-artifacts generate-db-fixtures install-pyenv
4546

4647
usage help:
4748
@echo "Usage:"
4849
@echo " deps: Install all required dependencies for building Katana with all features (incl. tests)."
4950
@echo " snos-deps: Install SNOS test dependencies (pyenv, Python 3.9.15)."
5051
@echo " build-explorer: Build the explorer."
5152
@echo " contracts: Build the contracts."
53+
@echo " tee-sev-snp: Build AMD SEV-SNP TEE VM components (prompts y/N to build katana unless KATANA_BINARY is set)."
5254
@echo " fixtures: Prepare tests artifacts (including test database)."
5355
@echo " snos-artifacts: Prepare SNOS tests artifacts."
5456
@echo " db-compat-artifacts: Prepare database compatibility test artifacts."
@@ -94,6 +96,19 @@ build-explorer:
9496

9597
contracts: install-scarb $(CONTRACTS_BUILD_DIR)
9698

99+
tee-sev-snp:
100+
@echo "Building AMD SEV-SNP TEE VM components..."
101+
@if [ -n "$(KATANA_BINARY)" ]; then \
102+
echo "Using katana binary: $(KATANA_BINARY)"; \
103+
$(AMDSEV_DIR)/build.sh --katana "$(KATANA_BINARY)"; \
104+
elif [ ! -t 0 ]; then \
105+
echo "Error: non-interactive run requires KATANA_BINARY."; \
106+
echo "Example: make tee-sev-snp KATANA_BINARY=/path/to/katana"; \
107+
exit 1; \
108+
else \
109+
$(AMDSEV_DIR)/build.sh; \
110+
fi
111+
97112
# Generate the list of sources dynamically to make sure Make can track all files in all nested subdirs
98113
$(CONTRACTS_BUILD_DIR): $(shell find $(CONTRACTS_DIR) -type f)
99114
@mkdir -p $@

misc/AMDSEV/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Output is written to `misc/AMDSEV/output/qemu/`.
2626

2727
### Katana Binary
2828

29-
If `--katana` is not provided, `build.sh` automatically builds a statically linked katana binary using musl libc via `scripts/build-musl.sh`.
29+
If `--katana` is not provided, `build.sh` prompts for confirmation (`y/N`) before building a statically linked katana binary using musl libc via `scripts/build-musl.sh`.
3030

3131
**Important:** The initrd is minimal and contains no libc or shared libraries. Only statically linked binaries will work. If providing a custom binary with `--katana`, ensure it is statically linked (e.g., built with musl).
3232

misc/AMDSEV/build.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,24 @@ fi
101101

102102
# Build katana if needed for initrd and not provided
103103
if [ $BUILD_INITRD -eq 1 ] && [ -z "$KATANA_BINARY" ]; then
104-
echo "No --katana provided, building katana with musl..."
104+
echo "No --katana provided."
105+
if [ ! -t 0 ]; then
106+
echo "ERROR: Cannot prompt without an interactive terminal."
107+
echo "Pass --katana /path/to/katana to use a pre-built binary."
108+
exit 1
109+
fi
110+
111+
read -r -p "Build katana from source with musl now? [y/N] " CONFIRM_BUILD_KATANA
112+
case "$CONFIRM_BUILD_KATANA" in
113+
[yY]|[yY][eE][sS])
114+
echo "Building katana with musl..."
115+
;;
116+
*)
117+
echo "Aborting. Provide --katana /path/to/katana to use a pre-built binary."
118+
exit 1
119+
;;
120+
esac
121+
105122
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
106123
"${PROJECT_ROOT}/scripts/build-musl.sh"
107124
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)