Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
y | d6b8329 | 2018-04-11 09:54:56 -0700 | [diff] [blame] | 17 | #ifndef AAPT2_COMPILE_H |
| 18 | #define AAPT2_COMPILE_H |
| 19 | |
| 20 | #include "androidfw/StringPiece.h" |
| 21 | |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame^] | 22 | #include "Command.h" |
y | d6b8329 | 2018-04-11 09:54:56 -0700 | [diff] [blame] | 23 | #include "Diagnostics.h" |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame^] | 24 | #include "ResourceTable.h" |
y | d6b8329 | 2018-04-11 09:54:56 -0700 | [diff] [blame] | 25 | |
| 26 | namespace aapt { |
| 27 | |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame^] | 28 | struct CompileOptions { |
| 29 | std::string output_path; |
| 30 | Maybe<std::string> res_dir; |
| 31 | Maybe<std::string> generate_text_symbols_path; |
| 32 | Maybe<Visibility::Level> visibility; |
| 33 | bool pseudolocalize = false; |
| 34 | bool no_png_crunch = false; |
| 35 | bool legacy_mode = false; |
| 36 | bool verbose = false; |
| 37 | }; |
| 38 | |
| 39 | class CompileCommand : public Command { |
| 40 | public: |
| 41 | explicit CompileCommand(IDiagnostics* diagnostic) : Command("compile", "c"), |
| 42 | diagnostic_(diagnostic) { |
| 43 | SetDescription("Compiles resources to be linked into an apk."); |
| 44 | AddRequiredFlag("-o", "Output path", &options_.output_path); |
| 45 | AddOptionalFlag("--dir", "Directory to scan for resources", &options_.res_dir); |
| 46 | AddOptionalFlag("--output-text-symbols", |
| 47 | "Generates a text file containing the resource symbols in the\n" |
| 48 | "specified file", &options_.generate_text_symbols_path); |
| 49 | AddOptionalSwitch("--pseudo-localize", "Generate resources for pseudo-locales " |
| 50 | "(en-XA and ar-XB)", &options_.pseudolocalize); |
| 51 | AddOptionalSwitch("--no-crunch", "Disables PNG processing", &options_.no_png_crunch); |
| 52 | AddOptionalSwitch("--legacy", "Treat errors that used to be valid in AAPT as warnings", |
| 53 | &options_.legacy_mode); |
| 54 | AddOptionalSwitch("-v", "Enables verbose logging", &options_.verbose); |
| 55 | AddOptionalFlag("--visibility", |
| 56 | "Sets the visibility of the compiled resources to the specified\n" |
| 57 | "level. Accepted levels: public, private, default", &visibility_); |
| 58 | } |
| 59 | |
| 60 | int Action(const std::vector<std::string>& args) override; |
| 61 | |
| 62 | private: |
| 63 | IDiagnostics* diagnostic_; |
| 64 | CompileOptions options_; |
| 65 | Maybe<std::string> visibility_; |
| 66 | }; |
y | d6b8329 | 2018-04-11 09:54:56 -0700 | [diff] [blame] | 67 | |
| 68 | }// namespace aapt |
| 69 | |
| 70 | #endif //AAPT2_COMPILE_H |