1 /* 2 * Copyright 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 namespace { 19 constexpr char kDefaultBundleDataFile[] = "bundle_bfbs.bin"; 20 constexpr char kDefaultGeneratedOutputPath[] = "."; 21 constexpr char kDefaultNamespace[] = ""; 22 constexpr char kDefaultNamespaceDelim[] = "::"; 23 constexpr char kDefaultTitle[] = "Bundled schema tables"; 24 } // namespace 25 26 struct Opts { 27 bool verbose{false}; 28 bool read{false}; 29 bool write{false}; 30 const char* filename{kDefaultBundleDataFile}; 31 const char* gen{kDefaultGeneratedOutputPath}; 32 const char* main_root_name{nullptr}; 33 const char* ns_name{kDefaultNamespace}; 34 const char* title{kDefaultTitle}; 35 struct { 36 int c{0}; 37 char** v{nullptr}; 38 } arg; 39 }; 40 extern Opts opts; 41 42 namespace { 43 namespace helper { // Part of flatbuffers API 44 constexpr bool AsBinaryFile = true; 45 constexpr bool AsTextFile = false; 46 } // namespace helper 47 48 } // namespace 49 50 /** 51 * Read and parse a previously generated bundle data file 52 * 53 **/ 54 int ReadBundledSchema(); 55 56 /** 57 * Generate a bundle data file from the binary flatbuffer schema 58 * files provided as input 59 * 60 **/ 61 int WriteBundledSchema(); 62 63 /** 64 * Print tool usage options 65 */ 66 int Usage(int argc, char** argv); 67 68 /** 69 * Parse tool usage options 70 */ 71 void ParseArgs(int argc, char** argv); 72