Skip to content

Commit ca45688

Browse files
committed
build(extract): run containerized under CONTAINER=1
This no longer requires a local Dockerfile to layer Make on top of cryspen/hax's Dockerfile, but I'll leave that commit in history in case it's useful in the future.
1 parent 93e6ee4 commit ca45688

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

securedrop-protocol/protocol-minimal/Makefile

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
include versions.env
66

7-
HAX_IMAGE = securedrop-protocol-hax
87
HAX_VERSION = $(shell cargo pkgid hax-lib 2>/dev/null | sed 's/.*@//')
9-
HAX_BASE_IMAGE = hax:$(HAX_VERSION)
8+
HAX_IMAGE = hax:$(HAX_VERSION)
109

1110
HAX_TARGETS := +**
1211
HAX_TARGETS += -securedrop_protocol_minimal::storage::**
@@ -23,6 +22,19 @@ HAX_ADMITS += Securedrop_protocol_minimal.Ciphertext.fst
2322
REPO_ROOT = $(shell git rev-parse --show-toplevel)
2423
PROOF_DIR = proofs/fstar/extraction
2524

25+
# Targets below MAY prefix their commands with `$(CONTAINER_RUN)` to run inside
26+
# the $HAX_IMAGE when $CONTAINER is set. Targets that do so SHOULD be redefined
27+
# here to establish a dependency on `hax-compat`.
28+
ifdef CONTAINER
29+
CONTAINER_RUN = docker run --rm \
30+
--volume $(REPO_ROOT):/work \
31+
--workdir /work/$(CURDIR:$(REPO_ROOT)/%=%) \
32+
--env CARGO_TARGET_DIR=/work/securedrop-protocol/target/container \
33+
$(HAX_IMAGE)
34+
35+
extract: compat-hax
36+
endif
37+
2638
.DEFAULT_GOAL := help
2739

2840
.PHONY: clean
@@ -44,32 +56,25 @@ compat-fstar: # Internal: Check F* version.
4456
{ echo "Error: expected fstar.exe version '$(FSTAR_EXPECTED_VERSION)', got '$(FSTAR_ACTUAL_VERSION)'"; exit 1; }
4557

4658
.PHONY: compat-hax-image
47-
compat-hax-image: # Internal: Check that $HAX_BASE_IMAGE is present.
59+
compat-hax-image: # Internal: Check that $HAX_IMAGE is present.
4860
@[ -n "$(HAX_VERSION)" ] || \
4961
{ echo "Error: could not determine the hax-lib version; is Cargo working?"; exit 1; }
50-
@docker image inspect $(HAX_BASE_IMAGE) >/dev/null 2>&1 || \
51-
{ echo "Error: missing image '$(HAX_BASE_IMAGE)'; build and tag it per <https://github.com/cryspen/hax#installation>."; exit 1; }
62+
@docker image inspect $(HAX_IMAGE) >/dev/null 2>&1 || \
63+
{ echo "Error: missing image '$(HAX_IMAGE)'; build and tag it per <https://github.com/cryspen/hax#installation>."; exit 1; }
5264

5365
.PHONY: compat-hax
54-
compat-hax: compat-hax-image # Internal: Check that $HAX_BASE_IMAGE has the expected $HAX_VERSION.
55-
@actual=$$(docker run --rm $(HAX_BASE_IMAGE) cargo-hax --version 2>/dev/null | sed -n 's/^version=//p'); \
66+
compat-hax: compat-hax-image # Internal: Check that $HAX_IMAGE has the expected $HAX_VERSION.
67+
@actual=$$(docker run --rm $(HAX_IMAGE) cargo-hax --version 2>/dev/null | sed -n 's/^version=//p'); \
5668
[ "$$actual" = "$(HAX_VERSION)" ] || \
5769
{ echo "Error: expected cargo-hax version '$(HAX_VERSION)', got '$$actual'"; exit 1; }
5870

5971
.PHONY: extract
60-
extract: # Internal/CI: Run hax extraction.
61-
cargo-hax into -i '$(HAX_TARGETS)' fstar
72+
extract: ## Run hax extraction, without verifying. (Prefix with "CONTAINER=1" to run containerized.)
73+
$(CONTAINER_RUN) cargo-hax into -i '$(HAX_TARGETS)' fstar
6274

6375
.PHONY: hax
6476
hax: compat extract verify ## Run hax extraction, then type-check and verify extracted proofs.
6577

66-
.PHONY: hax-image
67-
hax-image: compat-hax ## Build a container image for hax extraction.
68-
docker build \
69-
--build-arg HAX_BASE_IMAGE=$(HAX_BASE_IMAGE) \
70-
-t $(HAX_IMAGE):$(HAX_VERSION) \
71-
- < hax.Dockerfile
72-
7378
.PHONY: verify
7479
verify: # Internal/CI: Type-check and verify extracted proofs.
7580
# Type-check (fail fast):

securedrop-protocol/protocol-minimal/hax.Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)