Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 1 | // Copyright 2016 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef THIRD_PARTY_BAZEL_SRC_TOOLS_SINGLEJAR_OPTIONS_H_ |
| 16 | #define THIRD_PARTY_BAZEL_SRC_TOOLS_SINGLEJAR_OPTIONS_H_ |
| 17 | |
| 18 | #include <string> |
| 19 | #include <vector> |
Googler | ce714f8 | 2017-10-26 18:23:29 +0200 | [diff] [blame] | 20 | #include "src/tools/singlejar/token_stream.h" |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 21 | |
| 22 | /* Command line options. */ |
| 23 | class Options { |
| 24 | public: |
| 25 | Options() |
| 26 | : exclude_build_data(false), |
| 27 | force_compression(false), |
| 28 | normalize_timestamps(false), |
| 29 | no_duplicates(false), |
Sasha Smundak | 5747263 | 2016-08-05 20:07:40 +0000 | [diff] [blame] | 30 | no_duplicate_classes(false), |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 31 | preserve_compression(false), |
| 32 | verbose(false), |
kmb | f6b8d5e | 2017-10-12 01:21:26 +0200 | [diff] [blame] | 33 | warn_duplicate_resources(false), |
| 34 | check_desugar_deps(false) {} |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 35 | |
Googler | ce714f8 | 2017-10-26 18:23:29 +0200 | [diff] [blame] | 36 | virtual ~Options() {} |
| 37 | |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 38 | // Parses command line arguments into the fields of this instance. |
Googler | ce714f8 | 2017-10-26 18:23:29 +0200 | [diff] [blame] | 39 | void ParseCommandLine(int argc, const char *const argv[]); |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 40 | |
| 41 | std::string output_jar; |
| 42 | std::string main_class; |
| 43 | std::string java_launcher; |
| 44 | std::vector<std::string> manifest_lines; |
Googler | ce714f8 | 2017-10-26 18:23:29 +0200 | [diff] [blame] | 45 | std::vector<std::pair<std::string, std::string> > input_jars; |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 46 | std::vector<std::string> resources; |
| 47 | std::vector<std::string> classpath_resources; |
| 48 | std::vector<std::string> build_info_files; |
| 49 | std::vector<std::string> build_info_lines; |
| 50 | std::vector<std::string> include_prefixes; |
Sasha Smundak | 0241b59 | 2016-09-26 17:00:25 +0000 | [diff] [blame] | 51 | std::vector<std::string> nocompress_suffixes; |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 52 | bool exclude_build_data; |
| 53 | bool force_compression; |
| 54 | bool normalize_timestamps; |
| 55 | bool no_duplicates; |
Sasha Smundak | 5747263 | 2016-08-05 20:07:40 +0000 | [diff] [blame] | 56 | bool no_duplicate_classes; |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 57 | bool preserve_compression; |
| 58 | bool verbose; |
| 59 | bool warn_duplicate_resources; |
kmb | f6b8d5e | 2017-10-12 01:21:26 +0200 | [diff] [blame] | 60 | bool check_desugar_deps; |
Googler | ce714f8 | 2017-10-26 18:23:29 +0200 | [diff] [blame] | 61 | |
| 62 | protected: |
| 63 | /* |
| 64 | * Given the token stream, consume one notional flag from the input stream and |
| 65 | * return true if the flag was recognized and fully consumed. This notional |
| 66 | * flag may result in many tokens being consumed, as flags like --inputs ends |
| 67 | * up consuming many future tokens: --inputs a b c d e --some_other_flag |
| 68 | */ |
| 69 | virtual bool ParseToken(ArgTokenStream *tokens); |
| 70 | |
| 71 | /* |
| 72 | * After all of the command line options are consumed, validate that the |
| 73 | * options make sense. This function will exit(1) if invalid combinations of |
| 74 | * flags are passed (e.g.: is missing --output_jar) |
| 75 | */ |
| 76 | virtual void PostValidateOptions(); |
Sasha Smundak | d3b0ede | 2016-07-20 09:11:34 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | #endif // THIRD_PARTY_BAZEL_SRC_TOOLS_SINGLEJAR_OPTIONS_H_ |