Skip to content

Commit 2924990

Browse files
committed
Regenerate changed flatbuffer definitions
Signed-off-by: David Son <[email protected]>
1 parent 071a911 commit 2924990

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

Makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ GO_LD_FLAGS+='
3535

3636
SOCI_SNAPSHOTTER_PROJECT_ROOT ?= $(shell pwd)
3737
LTAG_TEMPLATE_FLAG=-t ./.headers
38-
FBS_FILE_PATH=$(CURDIR)/ztoc/fbs/ztoc.fbs
39-
FBS_FILE_PATH_COMPRESSION=$(CURDIR)/ztoc/compression/fbs/zinfo.fbs
38+
ZTOC_FBS_DIR=$(CURDIR)/ztoc/fbs
39+
ZTOC_FBS_FILE=$(ZTOC_FBS_DIR)/ztoc.fbs
40+
ZTOC_FBS_GO_FILES=$(wildcard $(ZTOC_FBS_DIR)/ztoc/*.go)
41+
COMPRESSION_FBS_DIR=$(CURDIR)/ztoc/compression/fbs
42+
COMPRESSION_FBS_FILE=$(COMPRESSION_FBS_DIR)/zinfo.fbs
43+
COMPRESSION_FBS_GO_FILES=$(wildcard $(COMPRESSION_FBS_DIR)/zinfo/*.go)
44+
4045
COMMIT=$(shell git rev-parse HEAD)
4146
STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc
4247

@@ -46,7 +51,7 @@ CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))
4651

4752
GO_BENCHMARK_TESTS?=.
4853

49-
.PHONY: all build check add-ltag install uninstall tidy vendor clean \
54+
.PHONY: all build check flatc add-ltag install uninstall tidy vendor clean \
5055
test integration release benchmarks build-benchmarks \
5156
benchmarks-perf-test benchmarks-comparison-test
5257

@@ -56,7 +61,7 @@ build: $(CMD)
5661

5762
FORCE:
5863

59-
soci-snapshotter-grpc: FORCE
64+
soci-snapshotter-grpc: flatc FORCE
6065
cd cmd/ ; GO111MODULE=$(GO111MODULE_VALUE) go build -o $(OUTDIR)/$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) $(GO_TAGS) ./soci-snapshotter-grpc
6166

6267
soci: FORCE
@@ -65,11 +70,15 @@ soci: FORCE
6570
check:
6671
cd scripts/ ; ./check-all.sh
6772

68-
flatc:
69-
rm -rf $(CURDIR)/ztoc/fbs/ztoc
70-
flatc -o $(CURDIR)/ztoc/fbs -g $(FBS_FILE_PATH)
71-
rm -rf $(CURDIR)/ztoc/compression/fbs/zinfo
72-
flatc -o $(CURDIR)/ztoc/compression/fbs -g $(FBS_FILE_PATH_COMPRESSION)
73+
flatc: $(ZTOC_FBS_GO_FILES) $(COMPRESSION_FBS_GO_FILES)
74+
75+
$(ZTOC_FBS_GO_FILES): $(ZTOC_FBS_FILE)
76+
rm -rf $(ZTOC_FBS_DIR)/ztoc
77+
flatc -o $(ZTOC_FBS_DIR) -g $(ZTOC_FBS_FILE)
78+
79+
$(COMPRESSION_FBS_GO_FILES): $(COMPRESSION_FBS_FILE)
80+
rm -rf $(COMPRESSION_FBS_DIR)/zinfo
81+
flatc -o $(COMPRESSION_FBS_DIR) -g $(COMPRESSION_FBS_FILE)
7382

7483
install:
7584
@echo "$@"
@@ -98,7 +107,6 @@ test:
98107
@echo "$@"
99108
@GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) $(GO_LD_FLAGS) -race ./...
100109

101-
102110
integration: build
103111
@echo "$@"
104112
@echo "SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT)"

scripts/check-flatc.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@
1616

1717
set -eux -o pipefail
1818

19-
CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20-
SOCI_SNAPSHOTTER_PROJECT_ROOT="${CUR_DIR}/.."
21-
FBS_FILE_PATH=${SOCI_SNAPSHOTTER_PROJECT_ROOT}/ztoc/fbs/ztoc.fbs
22-
23-
# check if flatbuffers needs to be generated again
24-
TMPDIR=$(mktemp -d)
25-
flatc -o "${TMPDIR}" -g "${FBS_FILE_PATH}"
26-
diff -qr "${TMPDIR}/ztoc" "${SOCI_SNAPSHOTTER_PROJECT_ROOT}/ztoc/fbs/ztoc" || (printf "\n\nThe Ztoc schema seems to be modified. Please run 'make flatc' to re-generate Go files\n\n"; rm -rf "${TMPDIR}"; exit 1)
27-
rm -rf "${TMPDIR}"
19+
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20+
soci_snapshotter_project_root="${cur_dir}/.."
21+
ztoc_fbs_dir="${soci_snapshotter_project_root}"/ztoc/fbs
22+
ztoc_fbs_file="${ztoc_fbs_dir}"/ztoc.fbs
23+
compression_fbs_dir="${soci_snapshotter_project_root}"/ztoc/compression/fbs
24+
compression_fbs_file="${compression_fbs_dir}"/zinfo.fbs
25+
26+
# check if ztoc flatbuffers needs to be generated again
27+
tmpdir=$(mktemp -d)
28+
flatc -o "${tmpdir}" -g "${ztoc_fbs_file}"
29+
diff -qr "${tmpdir}/ztoc" "${ztoc_fbs_dir}/ztoc" || (printf "\n\nThe Ztoc schema seems to be modified. Please run 'make flatc' to re-generate Go files\n\n"; rm -rf "${tmpdir}"; exit 1)
30+
rm -rf "${tmpdir}"
31+
32+
# check if zinfo flatbuffers needs to be generated again
33+
tmpdir=$(mktemp -d)
34+
flatc -o "${tmpdir}" -g "${compression_fbs_file}"
35+
diff -qr "${tmpdir}/zinfo" "${compression_fbs_dir}/zinfo" || (printf "\n\nThe Zinfo schema seems to be modified. Please run 'make flatc' to re-generate Go files\n\n"; rm -rf "${tmpdir}"; exit 1)
36+
rm -rf "${tmpdir}"

0 commit comments

Comments
 (0)