codegen: Remove preprocessor (#2355) The original idea for the codegen preprocessor was to perform init & prepare stages using a simulator and capture the output. This idea is being abandoned in favor of generating the necessary structures from python. BUG=cleanup
diff --git a/codegen/BUILD b/codegen/BUILD index 5daea9d..ae62c04 100644 --- a/codegen/BUILD +++ b/codegen/BUILD
@@ -64,7 +64,6 @@ deps = [ ":graph", ":inference_generator", - "//codegen/preprocessor:preprocessor_schema_py", "//tensorflow/lite/tools:flatbuffer_utils", "@absl_py//absl:app", "@absl_py//absl/flags",
diff --git a/codegen/code_generator.py b/codegen/code_generator.py index a1dbd6e..91cab73 100644 --- a/codegen/code_generator.py +++ b/codegen/code_generator.py
@@ -22,14 +22,12 @@ from tflite_micro.codegen import inference_generator from tflite_micro.codegen import graph -from tflite_micro.codegen.preprocessor import preprocessor_schema_py_generated as preprocessor_fb from tflite_micro.tensorflow.lite.tools import flatbuffer_utils # Usage information: # Default: # `bazel run codegen:code_generator -- \ -# --model=</path/to/my_model.tflite> \ -# --preprocessed_data=</path/to/preprocesser_output>` +# --model=</path/to/my_model.tflite> # Output will be located at: /path/to/my_model.h|cc _MODEL_PATH = flags.DEFINE_string(name="model", @@ -37,12 +35,6 @@ help="Path to the TFLite model file.", required=True) -_PREPROCESSED_DATA_PATH = flags.DEFINE_string( - name="preprocessed_data", - default=None, - help="Path to output of codegen_preprocessor.", - required=True) - _OUTPUT_DIR = flags.DEFINE_string( name="output_dir", default=None, @@ -57,27 +49,14 @@ required=False) -def _read_preprocessed_data( - preprocessed_data_file: str) -> preprocessor_fb.DataT: - with open(preprocessed_data_file, 'rb') as file: - data_byte_array = bytearray(file.read()) - return preprocessor_fb.DataT.InitFromObj( - preprocessor_fb.Data.GetRootAs(data_byte_array, 0)) - - def main(argv: Sequence[str]) -> None: output_dir = _OUTPUT_DIR.value or os.path.dirname(_MODEL_PATH.value) output_name = _OUTPUT_NAME.value or os.path.splitext( os.path.basename(_MODEL_PATH.value))[0] model = flatbuffer_utils.read_model(_MODEL_PATH.value) - preprocessed_data = _read_preprocessed_data(_PREPROCESSED_DATA_PATH.value) - print("Generating inference code for model:\n" - " model: {}\n" - " preprocessed_model: {}\n".format( - _MODEL_PATH.value, - preprocessed_data.inputModelPath.decode('utf-8'))) + print("Generating inference code for model: {}".format(_MODEL_PATH.value)) inference_generator.generate(output_dir, output_name, graph.OpCodeTable([model]), graph.Graph(model))
diff --git a/codegen/preprocessor/BUILD b/codegen/preprocessor/BUILD deleted file mode 100644 index 83e2d3b..0000000 --- a/codegen/preprocessor/BUILD +++ /dev/null
@@ -1,13 +0,0 @@ -load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library") - -package(default_visibility = ["//visibility:public"]) - -flatbuffer_cc_library( - name = "preprocessor_schema_fbs", - srcs = ["preprocessor_schema.fbs"], -) - -flatbuffer_py_library( - name = "preprocessor_schema_py", - srcs = ["preprocessor_schema.fbs"], -)
diff --git a/codegen/preprocessor/Makefile.inc b/codegen/preprocessor/Makefile.inc deleted file mode 100644 index b38d5ed..0000000 --- a/codegen/preprocessor/Makefile.inc +++ /dev/null
@@ -1,17 +0,0 @@ -# Copyright 2023 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -CODEGEN_PREPROCESSOR_SRCS := \ -$(TENSORFLOW_ROOT)codegen/preprocessor/main.cc
diff --git a/codegen/preprocessor/main.cc b/codegen/preprocessor/main.cc deleted file mode 100644 index d6b5638..0000000 --- a/codegen/preprocessor/main.cc +++ /dev/null
@@ -1,88 +0,0 @@ -/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#include <cstdlib> -#include <fstream> -#include <iostream> -#include <memory> - -#include "codegen/preprocessor/preprocessor_schema_generated.h" -#include "flatbuffers/flatbuffers.h" -#include "tensorflow/lite/schema/schema_generated.h" - -namespace { - -std::unique_ptr<char[]> ReadModelFile(const char* model_file_name) { - std::ifstream model_file(model_file_name, std::ios::binary); - if (!model_file.is_open()) { - std::cerr << "codegen_preprocessor: could not open model file: " - << model_file_name << std::endl; - return nullptr; - } - - model_file.seekg(0, std::ios::end); - size_t num_bytes = model_file.tellg(); - model_file.seekg(0, std::ios::beg); - std::unique_ptr<char[]> model_data(new char[num_bytes]); - model_file.read(model_data.get(), num_bytes); - - return model_data; -} - -int WriteOutputFile(const char* output_file_name, - flatbuffers::span<uint8_t> output) { - std::ofstream output_file(output_file_name, std::ios::trunc); - if (!output_file.is_open()) { - std::cerr << "codegen_preprocessor: could not open output file: " - << output_file_name << std::endl; - return EXIT_FAILURE; - } - - output_file.write(reinterpret_cast<char*>(output.data()), output.size()); - return 0; -} - -} // namespace - -int main(int argc, char* argv[]) { - if (argc < 2) { - std::cerr << "codegen_preprocessor: invalid usage!" << std::endl; - std::cerr << "usage: codegen_preprocessor <tflite_model> <output_file>" - << std::endl; - return EXIT_FAILURE; - } - - const char* model_file_name = argv[1]; - const char* output_file_name = argv[2]; - - const auto model_data = ReadModelFile(model_file_name); - if (!model_data) { - return EXIT_FAILURE; - } - - // We have to create our own allocator, as the typical TFLM runtime disables - // its use (to avoid dynamic allocation). - flatbuffers::DefaultAllocator allocator; - flatbuffers::FlatBufferBuilder builder{2048, &allocator}; - const auto input_model_path = builder.CreateString(model_file_name); - - // Do the preprocess work. - - tflm::codegen::preprocessor::DataBuilder data_builder(builder); - data_builder.add_input_model_path(input_model_path); - builder.Finish(data_builder.Finish()); - - return WriteOutputFile(output_file_name, builder.GetBufferSpan()); -}
diff --git a/codegen/preprocessor/preprocessor_schema.fbs b/codegen/preprocessor/preprocessor_schema.fbs deleted file mode 100644 index 25c7be8..0000000 --- a/codegen/preprocessor/preprocessor_schema.fbs +++ /dev/null
@@ -1,23 +0,0 @@ -// Copyright 2017 The TensorFlow Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace tflm.codegen.preprocessor; - -// TODO(rjascani): This needs a more descriptive name -table Data { - // The model path that was provided to the preprocessor - input_model_path:string; -} - -root_type Data;
diff --git a/codegen/preprocessor/preprocessor_schema_generated.h b/codegen/preprocessor/preprocessor_schema_generated.h deleted file mode 100644 index c483dd5..0000000 --- a/codegen/preprocessor/preprocessor_schema_generated.h +++ /dev/null
@@ -1,158 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_PREPROCESSORSCHEMA_TFLM_CODEGEN_PREPROCESSOR_H_ -#define FLATBUFFERS_GENERATED_PREPROCESSORSCHEMA_TFLM_CODEGEN_PREPROCESSOR_H_ - -#include "flatbuffers/flatbuffers.h" - -// Ensure the included flatbuffers.h is the same version as when this file was -// generated, otherwise it may not be compatible. -static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && - FLATBUFFERS_VERSION_MINOR == 5 && - FLATBUFFERS_VERSION_REVISION == 26, - "Non-compatible flatbuffers version included"); - -namespace tflm { -namespace codegen { -namespace preprocessor { - -struct Data; -struct DataBuilder; -struct DataT; - -struct DataT : public ::flatbuffers::NativeTable { - typedef Data TableType; - std::string input_model_path{}; -}; - -struct Data FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { - typedef DataT NativeTableType; - typedef DataBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_INPUT_MODEL_PATH = 4 - }; - const ::flatbuffers::String *input_model_path() const { - return GetPointer<const ::flatbuffers::String *>(VT_INPUT_MODEL_PATH); - } - bool Verify(::flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_INPUT_MODEL_PATH) && - verifier.VerifyString(input_model_path()) && - verifier.EndTable(); - } - DataT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const; - void UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const; - static ::flatbuffers::Offset<Data> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr); -}; - -struct DataBuilder { - typedef Data Table; - ::flatbuffers::FlatBufferBuilder &fbb_; - ::flatbuffers::uoffset_t start_; - void add_input_model_path(::flatbuffers::Offset<::flatbuffers::String> input_model_path) { - fbb_.AddOffset(Data::VT_INPUT_MODEL_PATH, input_model_path); - } - explicit DataBuilder(::flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ::flatbuffers::Offset<Data> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = ::flatbuffers::Offset<Data>(end); - return o; - } -}; - -inline ::flatbuffers::Offset<Data> CreateData( - ::flatbuffers::FlatBufferBuilder &_fbb, - ::flatbuffers::Offset<::flatbuffers::String> input_model_path = 0) { - DataBuilder builder_(_fbb); - builder_.add_input_model_path(input_model_path); - return builder_.Finish(); -} - -inline ::flatbuffers::Offset<Data> CreateDataDirect( - ::flatbuffers::FlatBufferBuilder &_fbb, - const char *input_model_path = nullptr) { - auto input_model_path__ = input_model_path ? _fbb.CreateString(input_model_path) : 0; - return tflm::codegen::preprocessor::CreateData( - _fbb, - input_model_path__); -} - -::flatbuffers::Offset<Data> CreateData(::flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr); - -inline DataT *Data::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const { - auto _o = std::unique_ptr<DataT>(new DataT()); - UnPackTo(_o.get(), _resolver); - return _o.release(); -} - -inline void Data::UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { - (void)_o; - (void)_resolver; - { auto _e = input_model_path(); if (_e) _o->input_model_path = _e->str(); } -} - -inline ::flatbuffers::Offset<Data> Data::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { - return CreateData(_fbb, _o, _rehasher); -} - -inline ::flatbuffers::Offset<Data> CreateData(::flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) { - (void)_rehasher; - (void)_o; - struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const DataT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; - auto _input_model_path = _o->input_model_path.empty() ? 0 : _fbb.CreateString(_o->input_model_path); - return tflm::codegen::preprocessor::CreateData( - _fbb, - _input_model_path); -} - -inline const tflm::codegen::preprocessor::Data *GetData(const void *buf) { - return ::flatbuffers::GetRoot<tflm::codegen::preprocessor::Data>(buf); -} - -inline const tflm::codegen::preprocessor::Data *GetSizePrefixedData(const void *buf) { - return ::flatbuffers::GetSizePrefixedRoot<tflm::codegen::preprocessor::Data>(buf); -} - -inline bool VerifyDataBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<tflm::codegen::preprocessor::Data>(nullptr); -} - -inline bool VerifySizePrefixedDataBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<tflm::codegen::preprocessor::Data>(nullptr); -} - -inline void FinishDataBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedDataBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) { - fbb.FinishSizePrefixed(root); -} - -inline std::unique_ptr<tflm::codegen::preprocessor::DataT> UnPackData( - const void *buf, - const ::flatbuffers::resolver_function_t *res = nullptr) { - return std::unique_ptr<tflm::codegen::preprocessor::DataT>(GetData(buf)->UnPack(res)); -} - -inline std::unique_ptr<tflm::codegen::preprocessor::DataT> UnPackSizePrefixedData( - const void *buf, - const ::flatbuffers::resolver_function_t *res = nullptr) { - return std::unique_ptr<tflm::codegen::preprocessor::DataT>(GetSizePrefixedData(buf)->UnPack(res)); -} - -} // namespace preprocessor -} // namespace codegen -} // namespace tflm - -#endif // FLATBUFFERS_GENERATED_PREPROCESSORSCHEMA_TFLM_CODEGEN_PREPROCESSOR_H_
diff --git a/codegen/preprocessor/preprocessor_schema_py_generated.py b/codegen/preprocessor/preprocessor_schema_py_generated.py deleted file mode 100644 index 2394bbf..0000000 --- a/codegen/preprocessor/preprocessor_schema_py_generated.py +++ /dev/null
@@ -1,85 +0,0 @@ -import flatbuffers - -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: preprocessor - -from flatbuffers.compat import import_numpy -np = import_numpy() - -class Data(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Data() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsData(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - # Data - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Data - def InputModelPath(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - -def DataStart(builder): - builder.StartObject(1) - -def DataAddInputModelPath(builder, inputModelPath): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputModelPath), 0) - -def DataEnd(builder): - return builder.EndObject() - - - -class DataT(object): - - # DataT - def __init__(self): - self.inputModelPath = None # type: str - - @classmethod - def InitFromBuf(cls, buf, pos): - data = Data() - data.Init(buf, pos) - return cls.InitFromObj(data) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, data): - x = DataT() - x._UnPack(data) - return x - - # DataT - def _UnPack(self, data): - if data is None: - return - self.inputModelPath = data.InputModelPath() - - # DataT - def Pack(self, builder): - if self.inputModelPath is not None: - inputModelPath = builder.CreateString(self.inputModelPath) - DataStart(builder) - if self.inputModelPath is not None: - DataAddInputModelPath(builder, inputModelPath) - data = DataEnd(builder) - return data - -
diff --git a/codegen/preprocessor/update_schema.sh b/codegen/preprocessor/update_schema.sh deleted file mode 100755 index d59f939..0000000 --- a/codegen/preprocessor/update_schema.sh +++ /dev/null
@@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# -# Updates the checked-generated source for the preprocessor schema -# - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR=${SCRIPT_DIR}/../.. -cd "${ROOT_DIR}" - -# We generate and check in the C++ and Python bindings for the schema to keep it -# working with the Makefiles. The makefiles do not support running flatc. -bazel build //codegen/preprocessor:preprocessor_schema_fbs_srcs -/bin/cp ./bazel-bin/codegen/preprocessor/preprocessor_schema_generated.h \ - codegen/preprocessor/preprocessor_schema_generated.h - -bazel build //codegen/preprocessor:preprocessor_schema_py -/bin/cp ./bazel-bin/codegen/preprocessor/preprocessor_schema_py_generated.py \ - codegen/preprocessor/preprocessor_schema_py_generated.py -
diff --git a/tensorflow/lite/micro/tools/make/Makefile b/tensorflow/lite/micro/tools/make/Makefile index 08eb057..9e550f2 100644 --- a/tensorflow/lite/micro/tools/make/Makefile +++ b/tensorflow/lite/micro/tools/make/Makefile
@@ -303,10 +303,6 @@ $(wildcard $(TENSORFLOW_ROOT)tensorflow/lite/micro/benchmarks/*benchmark.cc) \ $(wildcard $(TENSORFLOW_ROOT)tensorflow/lite/micro/tools/benchmarking/*benchmark.cc) -CODEGEN_PREPROCESSOR_PATH := $(BINDIR)codegen_preprocessor - -MICRO_LITE_CODEGEN_PREPROCESSOR := $(TENSORFLOW_ROOT)codegen/preprocessor/Makefile.inc - MICRO_LITE_CODEGEN_EXAMPLES := $(shell find $(TENSORFLOW_ROOT)codegen/examples/ -name Makefile.inc) MICROLITE_TEST_SRCS := \ @@ -762,9 +758,6 @@ # Load custom kernel tests. include $(MAKEFILE_DIR)/additional_tests.inc -# Load codegen preprocessor rules -include $(MICRO_LITE_CODEGEN_PREPROCESSOR) - # Create rules for downloading third-party dependencies. THIRD_PARTY_TARGETS := $(foreach DOWNLOAD,$(THIRD_PARTY_DOWNLOADS),$(eval $(call create_download_rule,$(DOWNLOAD)))) @@ -924,14 +917,6 @@ generated_micro_mutable_op_resolver: $(MICROLITE_GEN_OP_RESOLVER_TEST_TARGETS) endif -codegen_preprocessor: $(CODEGEN_PREPROCESSOR_PATH) - -$(CODEGEN_PREPROCESSOR_PATH): $(CODEGEN_PREPROCESSOR_SRCS) $(MICROLITE_LIB_PATH) - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) $(INCLUDES) \ - -o $@ $< \ - $(MICROLITE_LIB_PATH) $(LDFLAGS) $(MICROLITE_LIBS) - # Just build the test targets build: $(MICROLITE_BUILD_TARGETS)
diff --git a/tensorflow/lite/micro/tools/make/helper_functions.inc b/tensorflow/lite/micro/tools/make/helper_functions.inc index db4e686..e98c64b 100644 --- a/tensorflow/lite/micro/tools/make/helper_functions.inc +++ b/tensorflow/lite/micro/tools/make/helper_functions.inc
@@ -117,8 +117,7 @@ # 2 - File pattern, e.g: *.h recursive_find = $(wildcard $(1)$(2)) $(foreach dir,$(wildcard $(1)*),$(call recursive_find,$(dir)/,$(2))) -# Generates code capable of performing inference without an interpreter. It run -# the codegen preprocessor and the code generator. +# Generates code capable of performing inference without an interpreter. # # Arguments are: # 1 - Name of target @@ -127,31 +126,17 @@ # Calling eval on the output will create the targets that you need. define codegen_model # Filter out targets that currently don't support codegen: -# Bluepill: Is compiled with nostdlib, but preprocessor uses standard library. -# Corstone: This uses a FVP for simulation, which can't run the preprocessor. -# RISC-V: TODO(b/300484340): qemu-riscv32 currently does not support semi- -# hosting, which prevents the preprocessor from opening a file on the -# host filesystem. -# Hexagon: TODO(b/300322637): The hexagon 3.5.1 SDK doesn't provide a working -# C++11 stdlib, so preprocessor fails to link. -ifneq ($(TARGET), $(filter $(TARGET), \ - bluepill cortex_m_corstone_300 riscv32_generic hexagon)) +# Hexagon: Docker container doesn't have Bazel support. +ifneq ($(TARGET), $(filter $(TARGET), hexagon)) $(1)_MODEL := $(3) -$(1)_PREPROCESSOR_OUTPUT := $(GENERATED_SRCS_DIR)$(2).ppd $(1)_GENERATED_SRCS := $(GENERATED_SRCS_DIR)$(2).cc $(1)_GENERATED_HDRS := $(GENERATED_SRCS_DIR)$(2).h -$$($(1)_PREPROCESSOR_OUTPUT): $(CODEGEN_PREPROCESSOR_PATH) $$($(1)_MODEL) - @mkdir -p $$(dir $$@) - $$(RUN_COMMAND) $(CODEGEN_PREPROCESSOR_PATH) \ - $(abspath $$($(1)_MODEL)) $(abspath $$($(1)_PREPROCESSOR_OUTPUT)) - -$$($(1)_GENERATED_SRCS) $$($(1)_GENERATED_HDRS): $$($(1)_MODEL) $$($(1)_PREPROCESSOR_OUTPUT) +$$($(1)_GENERATED_SRCS) $$($(1)_GENERATED_HDRS): $$($(1)_MODEL) cd $(BAZEL_ROOT) && bazel run //codegen:code_generator -- \ --model $(abspath $$($(1)_MODEL)) \ - --preprocessed_data $(abspath $$($(1)_PREPROCESSOR_OUTPUT)) \ --output_dir $(abspath $(GENERATED_SRCS_DIR)) --output_name $(2) $(1): $$($(1)_GENERATED_SRCS) $$($(1)_GENERATED_HDRS) @@ -174,15 +159,8 @@ # Calling eval on the output will create the targets that you need. define codegen_model_binary # Filter out targets that currently don't support codegen: -# Bluepill: Is compiled with nostdlib, but preprocessor uses standard library. -# Corstone: This uses a FVP for simulation, which can't run the preprocessor. -# RISC-V: TODO(b/300484340): qemu-riscv32 currently does not support semi- -# hosting, which prevents the preprocessor from opening a file on the -# host filesystem. -# Hexagon: TODO(b/300322637): The hexagon 3.5.1 SDK doesn't provide a working -# C++11 stdlib, so preprocessor fails to link. -ifneq ($(TARGET), $(filter $(TARGET), \ - bluepill cortex_m_corstone_300 riscv32_generic hexagon)) +# Hexagon: Docker container doesn't have Bazel support. +ifneq ($(TARGET), $(filter $(TARGET), hexagon)) $(1)_CODEGEN_SRCS := $(4) $$(CODEGEN_RUNTIME_CC_SRCS) $(1)_CODEGEN_HDRS := $(5) $$(CODEGEN_RUNTIME_CC_HDRS)