blob: 1fea1355725663a838a6d131ad4c85d315debb2c [file] [log] [blame]
Sasha Smundakd3b0ede2016-07-20 09:11:34 +00001// 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>
Googlerce714f82017-10-26 18:23:29 +020020#include "src/tools/singlejar/token_stream.h"
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000021
22/* Command line options. */
23class Options {
24 public:
25 Options()
26 : exclude_build_data(false),
27 force_compression(false),
28 normalize_timestamps(false),
29 no_duplicates(false),
Sasha Smundak57472632016-08-05 20:07:40 +000030 no_duplicate_classes(false),
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000031 preserve_compression(false),
32 verbose(false),
kmbf6b8d5e2017-10-12 01:21:26 +020033 warn_duplicate_resources(false),
34 check_desugar_deps(false) {}
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000035
Googlerce714f82017-10-26 18:23:29 +020036 virtual ~Options() {}
37
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000038 // Parses command line arguments into the fields of this instance.
Googlerce714f82017-10-26 18:23:29 +020039 void ParseCommandLine(int argc, const char *const argv[]);
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000040
41 std::string output_jar;
42 std::string main_class;
43 std::string java_launcher;
44 std::vector<std::string> manifest_lines;
Googlerce714f82017-10-26 18:23:29 +020045 std::vector<std::pair<std::string, std::string> > input_jars;
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000046 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 Smundak0241b592016-09-26 17:00:25 +000051 std::vector<std::string> nocompress_suffixes;
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000052 bool exclude_build_data;
53 bool force_compression;
54 bool normalize_timestamps;
55 bool no_duplicates;
Sasha Smundak57472632016-08-05 20:07:40 +000056 bool no_duplicate_classes;
Sasha Smundakd3b0ede2016-07-20 09:11:34 +000057 bool preserve_compression;
58 bool verbose;
59 bool warn_duplicate_resources;
kmbf6b8d5e2017-10-12 01:21:26 +020060 bool check_desugar_deps;
Googlerce714f82017-10-26 18:23:29 +020061
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 Smundakd3b0ede2016-07-20 09:11:34 +000077};
78
79#endif // THIRD_PARTY_BAZEL_SRC_TOOLS_SINGLEJAR_OPTIONS_H_