Skip to content

Commit

Permalink
Regenerate changed flatbuffer definitions
Browse files Browse the repository at this point in the history
Signed-off-by: David Son <[email protected]>
  • Loading branch information
sondavidb committed May 13, 2024
1 parent 071a911 commit 2924990
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ GO_LD_FLAGS+='

SOCI_SNAPSHOTTER_PROJECT_ROOT ?= $(shell pwd)
LTAG_TEMPLATE_FLAG=-t ./.headers
FBS_FILE_PATH=$(CURDIR)/ztoc/fbs/ztoc.fbs
FBS_FILE_PATH_COMPRESSION=$(CURDIR)/ztoc/compression/fbs/zinfo.fbs
ZTOC_FBS_DIR=$(CURDIR)/ztoc/fbs
ZTOC_FBS_FILE=$(ZTOC_FBS_DIR)/ztoc.fbs
ZTOC_FBS_GO_FILES=$(wildcard $(ZTOC_FBS_DIR)/ztoc/*.go)
COMPRESSION_FBS_DIR=$(CURDIR)/ztoc/compression/fbs
COMPRESSION_FBS_FILE=$(COMPRESSION_FBS_DIR)/zinfo.fbs
COMPRESSION_FBS_GO_FILES=$(wildcard $(COMPRESSION_FBS_DIR)/zinfo/*.go)

COMMIT=$(shell git rev-parse HEAD)
STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc

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

GO_BENCHMARK_TESTS?=.

.PHONY: all build check add-ltag install uninstall tidy vendor clean \
.PHONY: all build check flatc add-ltag install uninstall tidy vendor clean \
test integration release benchmarks build-benchmarks \
benchmarks-perf-test benchmarks-comparison-test

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

FORCE:

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

soci: FORCE
Expand All @@ -65,11 +70,15 @@ soci: FORCE
check:
cd scripts/ ; ./check-all.sh

flatc:
rm -rf $(CURDIR)/ztoc/fbs/ztoc
flatc -o $(CURDIR)/ztoc/fbs -g $(FBS_FILE_PATH)
rm -rf $(CURDIR)/ztoc/compression/fbs/zinfo
flatc -o $(CURDIR)/ztoc/compression/fbs -g $(FBS_FILE_PATH_COMPRESSION)
flatc: $(ZTOC_FBS_GO_FILES) $(COMPRESSION_FBS_GO_FILES)

$(ZTOC_FBS_GO_FILES): $(ZTOC_FBS_FILE)
rm -rf $(ZTOC_FBS_DIR)/ztoc
flatc -o $(ZTOC_FBS_DIR) -g $(ZTOC_FBS_FILE)

$(COMPRESSION_FBS_GO_FILES): $(COMPRESSION_FBS_FILE)
rm -rf $(COMPRESSION_FBS_DIR)/zinfo
flatc -o $(COMPRESSION_FBS_DIR) -g $(COMPRESSION_FBS_FILE)

install:
@echo "$@"
Expand Down Expand Up @@ -98,7 +107,6 @@ test:
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) $(GO_LD_FLAGS) -race ./...


integration: build
@echo "$@"
@echo "SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT)"
Expand Down
27 changes: 18 additions & 9 deletions scripts/check-flatc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@

set -eux -o pipefail

CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOCI_SNAPSHOTTER_PROJECT_ROOT="${CUR_DIR}/.."
FBS_FILE_PATH=${SOCI_SNAPSHOTTER_PROJECT_ROOT}/ztoc/fbs/ztoc.fbs

# check if flatbuffers needs to be generated again
TMPDIR=$(mktemp -d)
flatc -o "${TMPDIR}" -g "${FBS_FILE_PATH}"
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)
rm -rf "${TMPDIR}"
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
soci_snapshotter_project_root="${cur_dir}/.."
ztoc_fbs_dir="${soci_snapshotter_project_root}"/ztoc/fbs
ztoc_fbs_file="${ztoc_fbs_dir}"/ztoc.fbs
compression_fbs_dir="${soci_snapshotter_project_root}"/ztoc/compression/fbs
compression_fbs_file="${compression_fbs_dir}"/zinfo.fbs

# check if ztoc flatbuffers needs to be generated again
tmpdir=$(mktemp -d)
flatc -o "${tmpdir}" -g "${ztoc_fbs_file}"
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)
rm -rf "${tmpdir}"

# check if zinfo flatbuffers needs to be generated again
tmpdir=$(mktemp -d)
flatc -o "${tmpdir}" -g "${compression_fbs_file}"
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)
rm -rf "${tmpdir}"

0 comments on commit 2924990

Please sign in to comment.