| #!/bin/sh |
| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # This file takes an output file as its first parameter, followed by one or more |
| # FIDL schema files in JSON format. It then generates a header containing a C++ |
| # map from schema filename to file contents, which can then be used for test |
| # purposes. |
| |
| set -e |
| |
| FILENAME="${1}" |
| shift |
| rm -f "${FILENAME}" |
| |
| cat > "${FILENAME}" << EOF |
| #include <map> |
| #include <string> |
| // Autogenerated: Do not modify! |
| namespace fidlcat_test { |
| class ExampleMap { |
| public: |
| ExampleMap() { |
| map_ = { |
| EOF |
| |
| for i in "$@"; do |
| if [ ! -f "${i}" ]; then |
| echo "file ${i} not found" |
| exit 1 |
| fi; |
| cat >> "${FILENAME}" <<EOF |
| {"${i}", R"FIDL($(cat "${i}"))FIDL"}, |
| EOF |
| done |
| |
| cat >> "${FILENAME}" << EOF |
| }; |
| } |
| std::map<std::string, std::string> &map() { return map_; } |
| private: |
| std::map<std::string, std::string> map_; |
| }; |
| |
| } // namespace fidlcat_test |
| EOF |