Skip to content

Commit

Permalink
Revise Flatbuffers codegen style (#7964)
Browse files Browse the repository at this point in the history
* Rename the generated Flatbuffer headers

The Blaze/Bazel rules for Flatbuffers are inflexible and require this naming pattern :-/

* Also update the flags to flatc

* Fix lots of stuff

* exclude from clang-format

* ignore again
  • Loading branch information
steven-johnson authored Nov 29, 2023
1 parent b7468af commit 68f2bbd
Show file tree
Hide file tree
Showing 6 changed files with 31,834 additions and 307 deletions.
1 change: 1 addition & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
# mini_webgpu.h is copied from upstream with some local mods
./src/runtime/mini_webgpu.h
./dependencies/spirv
*.fbs.h
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1395,14 +1395,14 @@ $(BIN_DIR)/test_internal: $(ROOT_DIR)/test/internal.cpp $(BIN_DIR)/libHalide.$(S
$(CXX) $(TEST_CXX_FLAGS) $< -I$(SRC_DIR) $(TEST_LD_FLAGS) -o $@

ifneq (,$(shell which flatc))
$(BUILD_DIR)/Deserialization.o : $(BUILD_DIR)/halide_ir_generated.h
$(BUILD_DIR)/Serialization.o : $(BUILD_DIR)/halide_ir_generated.h
$(BUILD_DIR)/Deserialization.o : $(BUILD_DIR)/halide_ir.fbs.h
$(BUILD_DIR)/Serialization.o : $(BUILD_DIR)/halide_ir.fbs.h
endif

# Generated header for serialization/deserialization
$(BUILD_DIR)/halide_ir_generated.h: $(SRC_DIR)/halide_ir.fbs
$(BUILD_DIR)/halide_ir.fbs.h: $(SRC_DIR)/halide_ir.fbs
@mkdir -p $(@D)
flatc -o $(BUILD_DIR) -c $^
flatc --cpp --cpp-std C++17 --no-union-value-namespacing --keep-prefix --filename-suffix ".fbs" -o $(BUILD_DIR) $^

# Correctness test that link against libHalide
$(BIN_DIR)/correctness_%: $(ROOT_DIR)/test/correctness/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h $(RUNTIME_EXPORTED_INCLUDES)
Expand Down
Loading

0 comments on commit 68f2bbd

Please sign in to comment.