| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION | 46 "{{output_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION |
| 47 "{{solibs}}", // SUBSTITUTION_SOLIBS | 47 "{{solibs}}", // SUBSTITUTION_SOLIBS |
| 48 | 48 |
| 49 "{{bundle_root_dir}}", // SUBSTITUTION_BUNDLE_ROOT_DIR | 49 "{{bundle_root_dir}}", // SUBSTITUTION_BUNDLE_ROOT_DIR |
| 50 "{{bundle_resources_dir}}", // SUBSTITUTION_BUNDLE_RESOURCES_DIR | 50 "{{bundle_resources_dir}}", // SUBSTITUTION_BUNDLE_RESOURCES_DIR |
| 51 "{{bundle_executable_dir}}", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR | 51 "{{bundle_executable_dir}}", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR |
| 52 "{{bundle_plugins_dir}}", // SUBSTITUTION_BUNDLE_PLUGINS_DIR | 52 "{{bundle_plugins_dir}}", // SUBSTITUTION_BUNDLE_PLUGINS_DIR |
| 53 "{{binary_compress}}", // SUBSTITUTION_BUNDLE_BINARY_COMPRESS |
| 53 | 54 |
| 54 "{{response_file_name}}", // SUBSTITUTION_RSP_FILE_NAME | 55 "{{response_file_name}}", // SUBSTITUTION_RSP_FILE_NAME |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { | 58 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { |
| 58 nullptr, // SUBSTITUTION_LITERAL | 59 nullptr, // SUBSTITUTION_LITERAL |
| 59 | 60 |
| 60 "in", // SUBSTITUTION_SOURCE | 61 "in", // SUBSTITUTION_SOURCE |
| 61 "out", // SUBSTITUTION_OUTPUT | 62 "out", // SUBSTITUTION_OUTPUT |
| 62 | 63 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 "in_newline", // SUBSTITUTION_LINKER_INPUTS_NEWLINE | 92 "in_newline", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
| 92 "ldflags", // SUBSTITUTION_LDFLAGS | 93 "ldflags", // SUBSTITUTION_LDFLAGS |
| 93 "libs", // SUBSTITUTION_LIBS | 94 "libs", // SUBSTITUTION_LIBS |
| 94 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION | 95 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION |
| 95 "solibs", // SUBSTITUTION_SOLIBS | 96 "solibs", // SUBSTITUTION_SOLIBS |
| 96 | 97 |
| 97 "bundle_root_dir", // SUBSTITUTION_BUNDLE_ROOT_DIR | 98 "bundle_root_dir", // SUBSTITUTION_BUNDLE_ROOT_DIR |
| 98 "bundle_resources_dir", // SUBSTITUTION_BUNDLE_RESOURCES_DIR | 99 "bundle_resources_dir", // SUBSTITUTION_BUNDLE_RESOURCES_DIR |
| 99 "bundle_executable_dir", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR | 100 "bundle_executable_dir", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR |
| 100 "bundle_plugins_dir", // SUBSTITUTION_BUNDLE_PLUGINS_DIR | 101 "bundle_plugins_dir", // SUBSTITUTION_BUNDLE_PLUGINS_DIR |
| 102 "binary_compress", // SUBSTITUTION_BUNDLE_BINARY_COMPRESS |
| 101 | 103 |
| 102 "rspfile", // SUBSTITUTION_RSP_FILE_NAME | 104 "rspfile", // SUBSTITUTION_RSP_FILE_NAME |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 SubstitutionBits::SubstitutionBits() : used() { | 107 SubstitutionBits::SubstitutionBits() : used() { |
| 106 } | 108 } |
| 107 | 109 |
| 108 void SubstitutionBits::MergeFrom(const SubstitutionBits& other) { | 110 void SubstitutionBits::MergeFrom(const SubstitutionBits& other) { |
| 109 for (size_t i = 0; i < SUBSTITUTION_NUM_TYPES; i++) | 111 for (size_t i = 0; i < SUBSTITUTION_NUM_TYPES; i++) |
| 110 used[i] |= other.used[i]; | 112 used[i] |= other.used[i]; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // All valid compiler outputs plus the output extension. | 203 // All valid compiler outputs plus the output extension. |
| 202 return IsValidCompilerOutputsSubstitution(type) || | 204 return IsValidCompilerOutputsSubstitution(type) || |
| 203 type == SUBSTITUTION_OUTPUT_EXTENSION; | 205 type == SUBSTITUTION_OUTPUT_EXTENSION; |
| 204 } | 206 } |
| 205 | 207 |
| 206 bool IsValidCopySubstitution(SubstitutionType type) { | 208 bool IsValidCopySubstitution(SubstitutionType type) { |
| 207 return IsValidToolSubstitution(type) || | 209 return IsValidToolSubstitution(type) || |
| 208 type == SUBSTITUTION_SOURCE; | 210 type == SUBSTITUTION_SOURCE; |
| 209 } | 211 } |
| 210 | 212 |
| 213 bool IsValidCopyBundleDataSubstitution(SubstitutionType type) { |
| 214 return IsValidCopySubstitution(type) || |
| 215 type == SUBSTITUTION_BUNDLE_BINARY_COMPRESS; |
| 216 } |
| 217 |
| 211 bool IsValidCompileXCassetsSubstitution(SubstitutionType type) { | 218 bool IsValidCompileXCassetsSubstitution(SubstitutionType type) { |
| 212 return IsValidToolSubstitution(type) || | 219 return IsValidToolSubstitution(type) || |
| 213 type == SUBSTITUTION_LINKER_INPUTS; | 220 type == SUBSTITUTION_LINKER_INPUTS; |
| 214 } | 221 } |
| 215 | 222 |
| 216 bool EnsureValidSourcesSubstitutions( | 223 bool EnsureValidSourcesSubstitutions( |
| 217 const std::vector<SubstitutionType>& types, | 224 const std::vector<SubstitutionType>& types, |
| 218 const ParseNode* origin, | 225 const ParseNode* origin, |
| 219 Err* err) { | 226 Err* err) { |
| 220 for (size_t i = 0; i < types.size(); i++) { | 227 for (size_t i = 0; i < types.size(); i++) { |
| 221 if (!IsValidSourceSubstitution(types[i])) { | 228 if (!IsValidSourceSubstitution(types[i])) { |
| 222 *err = Err(origin, "Invalid substitution type.", | 229 *err = Err(origin, "Invalid substitution type.", |
| 223 "The substitution " + std::string(kSubstitutionNames[types[i]]) + | 230 "The substitution " + std::string(kSubstitutionNames[types[i]]) + |
| 224 " isn't valid for something\n" | 231 " isn't valid for something\n" |
| 225 "operating on a source file such as this."); | 232 "operating on a source file such as this."); |
| 226 return false; | 233 return false; |
| 227 } | 234 } |
| 228 } | 235 } |
| 229 return true; | 236 return true; |
| 230 } | 237 } |
| OLD | NEW |