| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/substitution_type.h" | 5 #include "tools/gn/substitution_type.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "tools/gn/err.h" | 10 #include "tools/gn/err.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS | 40 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS |
| 41 | 41 |
| 42 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS | 42 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS |
| 43 "{{inputs_newline}}", // SUBSTITUTION_LINKER_INPUTS_NEWLINE | 43 "{{inputs_newline}}", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
| 44 "{{ldflags}}", // SUBSTITUTION_LDFLAGS | 44 "{{ldflags}}", // SUBSTITUTION_LDFLAGS |
| 45 "{{libs}}", // SUBSTITUTION_LIBS | 45 "{{libs}}", // SUBSTITUTION_LIBS |
| 46 "{{output_dir}}", // SUBSTITUTION_OUTPUT_DIR | 46 "{{output_dir}}", // SUBSTITUTION_OUTPUT_DIR |
| 47 "{{output_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION | 47 "{{output_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION |
| 48 "{{solibs}}", // SUBSTITUTION_SOLIBS | 48 "{{solibs}}", // SUBSTITUTION_SOLIBS |
| 49 | 49 |
| 50 "{{arflags}}", // SUBSTITUTION_ARFLAGS |
| 51 |
| 50 "{{bundle_root_dir}}", // SUBSTITUTION_BUNDLE_ROOT_DIR | 52 "{{bundle_root_dir}}", // SUBSTITUTION_BUNDLE_ROOT_DIR |
| 51 "{{bundle_resources_dir}}", // SUBSTITUTION_BUNDLE_RESOURCES_DIR | 53 "{{bundle_resources_dir}}", // SUBSTITUTION_BUNDLE_RESOURCES_DIR |
| 52 "{{bundle_executable_dir}}", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR | 54 "{{bundle_executable_dir}}", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR |
| 53 "{{bundle_plugins_dir}}", // SUBSTITUTION_BUNDLE_PLUGINS_DIR | 55 "{{bundle_plugins_dir}}", // SUBSTITUTION_BUNDLE_PLUGINS_DIR |
| 54 | 56 |
| 55 "{{response_file_name}}", // SUBSTITUTION_RSP_FILE_NAME | 57 "{{response_file_name}}", // SUBSTITUTION_RSP_FILE_NAME |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { | 60 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { |
| 59 nullptr, // SUBSTITUTION_LITERAL | 61 nullptr, // SUBSTITUTION_LITERAL |
| (...skipping 29 matching lines...) Expand all Loading... |
| 89 // are used in different contexts and are named differently to keep things | 91 // are used in different contexts and are named differently to keep things |
| 90 // clear, but they both expand to the "set of input files" for a build rule. | 92 // clear, but they both expand to the "set of input files" for a build rule. |
| 91 "in", // SUBSTITUTION_LINKER_INPUTS | 93 "in", // SUBSTITUTION_LINKER_INPUTS |
| 92 "in_newline", // SUBSTITUTION_LINKER_INPUTS_NEWLINE | 94 "in_newline", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
| 93 "ldflags", // SUBSTITUTION_LDFLAGS | 95 "ldflags", // SUBSTITUTION_LDFLAGS |
| 94 "libs", // SUBSTITUTION_LIBS | 96 "libs", // SUBSTITUTION_LIBS |
| 95 "output_dir", // SUBSTITUTION_OUTPUT_DIR | 97 "output_dir", // SUBSTITUTION_OUTPUT_DIR |
| 96 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION | 98 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION |
| 97 "solibs", // SUBSTITUTION_SOLIBS | 99 "solibs", // SUBSTITUTION_SOLIBS |
| 98 | 100 |
| 101 "arflags", // SUBSTITUTION_ARFLAGS |
| 102 |
| 99 "bundle_root_dir", // SUBSTITUTION_BUNDLE_ROOT_DIR | 103 "bundle_root_dir", // SUBSTITUTION_BUNDLE_ROOT_DIR |
| 100 "bundle_resources_dir", // SUBSTITUTION_BUNDLE_RESOURCES_DIR | 104 "bundle_resources_dir", // SUBSTITUTION_BUNDLE_RESOURCES_DIR |
| 101 "bundle_executable_dir", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR | 105 "bundle_executable_dir", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR |
| 102 "bundle_plugins_dir", // SUBSTITUTION_BUNDLE_PLUGINS_DIR | 106 "bundle_plugins_dir", // SUBSTITUTION_BUNDLE_PLUGINS_DIR |
| 103 | 107 |
| 104 "rspfile", // SUBSTITUTION_RSP_FILE_NAME | 108 "rspfile", // SUBSTITUTION_RSP_FILE_NAME |
| 105 }; | 109 }; |
| 106 | 110 |
| 107 SubstitutionBits::SubstitutionBits() : used() { | 111 SubstitutionBits::SubstitutionBits() : used() { |
| 108 } | 112 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 type == SUBSTITUTION_SOLIBS; | 204 type == SUBSTITUTION_SOLIBS; |
| 201 } | 205 } |
| 202 | 206 |
| 203 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { | 207 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { |
| 204 // All valid compiler outputs plus the output extension. | 208 // All valid compiler outputs plus the output extension. |
| 205 return IsValidCompilerOutputsSubstitution(type) || | 209 return IsValidCompilerOutputsSubstitution(type) || |
| 206 type == SUBSTITUTION_OUTPUT_DIR || | 210 type == SUBSTITUTION_OUTPUT_DIR || |
| 207 type == SUBSTITUTION_OUTPUT_EXTENSION; | 211 type == SUBSTITUTION_OUTPUT_EXTENSION; |
| 208 } | 212 } |
| 209 | 213 |
| 214 bool IsValidALinkSubstitution(SubstitutionType type) { |
| 215 return IsValidToolSubstitution(type) || |
| 216 type == SUBSTITUTION_LINKER_INPUTS || |
| 217 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE || |
| 218 type == SUBSTITUTION_ARFLAGS || |
| 219 type == SUBSTITUTION_OUTPUT_DIR || |
| 220 type == SUBSTITUTION_OUTPUT_EXTENSION; |
| 221 } |
| 222 |
| 210 bool IsValidCopySubstitution(SubstitutionType type) { | 223 bool IsValidCopySubstitution(SubstitutionType type) { |
| 211 return IsValidToolSubstitution(type) || | 224 return IsValidToolSubstitution(type) || |
| 212 type == SUBSTITUTION_SOURCE; | 225 type == SUBSTITUTION_SOURCE; |
| 213 } | 226 } |
| 214 | 227 |
| 215 bool IsValidCompileXCassetsSubstitution(SubstitutionType type) { | 228 bool IsValidCompileXCassetsSubstitution(SubstitutionType type) { |
| 216 return IsValidToolSubstitution(type) || | 229 return IsValidToolSubstitution(type) || |
| 217 type == SUBSTITUTION_LINKER_INPUTS; | 230 type == SUBSTITUTION_LINKER_INPUTS; |
| 218 } | 231 } |
| 219 | 232 |
| 220 bool EnsureValidSourcesSubstitutions( | 233 bool EnsureValidSourcesSubstitutions( |
| 221 const std::vector<SubstitutionType>& types, | 234 const std::vector<SubstitutionType>& types, |
| 222 const ParseNode* origin, | 235 const ParseNode* origin, |
| 223 Err* err) { | 236 Err* err) { |
| 224 for (size_t i = 0; i < types.size(); i++) { | 237 for (size_t i = 0; i < types.size(); i++) { |
| 225 if (!IsValidSourceSubstitution(types[i])) { | 238 if (!IsValidSourceSubstitution(types[i])) { |
| 226 *err = Err(origin, "Invalid substitution type.", | 239 *err = Err(origin, "Invalid substitution type.", |
| 227 "The substitution " + std::string(kSubstitutionNames[types[i]]) + | 240 "The substitution " + std::string(kSubstitutionNames[types[i]]) + |
| 228 " isn't valid for something\n" | 241 " isn't valid for something\n" |
| 229 "operating on a source file such as this."); | 242 "operating on a source file such as this."); |
| 230 return false; | 243 return false; |
| 231 } | 244 } |
| 232 } | 245 } |
| 233 return true; | 246 return true; |
| 234 } | 247 } |
| OLD | NEW |