| 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 <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 "{{cflags}}", // SUBSTITUTION_CFLAGS | 31 "{{cflags}}", // SUBSTITUTION_CFLAGS |
| 32 "{{cflags_c}}", // SUBSTITUTION_CFLAGS_C | 32 "{{cflags_c}}", // SUBSTITUTION_CFLAGS_C |
| 33 "{{cflags_cc}}", // SUBSTITUTION_CFLAGS_CC | 33 "{{cflags_cc}}", // SUBSTITUTION_CFLAGS_CC |
| 34 "{{cflags_objc}}", // SUBSTITUTION_CFLAGS_OBJC | 34 "{{cflags_objc}}", // SUBSTITUTION_CFLAGS_OBJC |
| 35 "{{cflags_objcc}}", // SUBSTITUTION_CFLAGS_OBJCC | 35 "{{cflags_objcc}}", // SUBSTITUTION_CFLAGS_OBJCC |
| 36 "{{defines}}", // SUBSTITUTION_DEFINES | 36 "{{defines}}", // SUBSTITUTION_DEFINES |
| 37 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS | 37 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS |
| 38 | 38 |
| 39 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS | 39 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS |
| 40 "{{inputs_newline}}", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
| 40 "{{ldflags}}", // SUBSTITUTION_LDFLAGS | 41 "{{ldflags}}", // SUBSTITUTION_LDFLAGS |
| 41 "{{libs}}", // SUBSTITUTION_LIBS | 42 "{{libs}}", // SUBSTITUTION_LIBS |
| 42 "{{output_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION | 43 "{{output_extension}}", // SUBSTITUTION_OUTPUT_EXTENSION |
| 43 "{{solibs}}", // SUBSTITUTION_SOLIBS | 44 "{{solibs}}", // SUBSTITUTION_SOLIBS |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { | 47 const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES] = { |
| 47 NULL, // SUBSTITUTION_LITERAL | 48 NULL, // SUBSTITUTION_LITERAL |
| 48 | 49 |
| 49 "in", // SUBSTITUTION_SOURCE | 50 "in", // SUBSTITUTION_SOURCE |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 "cflags_cc", // SUBSTITUTION_CFLAGS_CC | 69 "cflags_cc", // SUBSTITUTION_CFLAGS_CC |
| 69 "cflags_objc", // SUBSTITUTION_CFLAGS_OBJC | 70 "cflags_objc", // SUBSTITUTION_CFLAGS_OBJC |
| 70 "cflags_objcc", // SUBSTITUTION_CFLAGS_OBJCC | 71 "cflags_objcc", // SUBSTITUTION_CFLAGS_OBJCC |
| 71 "defines", // SUBSTITUTION_DEFINES | 72 "defines", // SUBSTITUTION_DEFINES |
| 72 "include_dirs", // SUBSTITUTION_INCLUDE_DIRS | 73 "include_dirs", // SUBSTITUTION_INCLUDE_DIRS |
| 73 | 74 |
| 74 // LINKER_INPUTS expands to the same Ninja var as SUBSTITUTION_SOURCE. These | 75 // LINKER_INPUTS expands to the same Ninja var as SUBSTITUTION_SOURCE. These |
| 75 // are used in different contexts and are named differently to keep things | 76 // are used in different contexts and are named differently to keep things |
| 76 // clear, but they both expand to the "set of input files" for a build rule. | 77 // clear, but they both expand to the "set of input files" for a build rule. |
| 77 "in", // SUBSTITUTION_LINKER_INPUTS | 78 "in", // SUBSTITUTION_LINKER_INPUTS |
| 79 "in_newline", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
| 78 "ldflags", // SUBSTITUTION_LDFLAGS | 80 "ldflags", // SUBSTITUTION_LDFLAGS |
| 79 "libs", // SUBSTITUTION_LIBS | 81 "libs", // SUBSTITUTION_LIBS |
| 80 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION | 82 "output_extension", // SUBSTITUTION_OUTPUT_EXTENSION |
| 81 "solibs", // SUBSTITUTION_SOLIBS | 83 "solibs", // SUBSTITUTION_SOLIBS |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 SubstitutionBits::SubstitutionBits() : used() { | 86 SubstitutionBits::SubstitutionBits() : used() { |
| 85 } | 87 } |
| 86 | 88 |
| 87 void SubstitutionBits::MergeFrom(const SubstitutionBits& other) { | 89 void SubstitutionBits::MergeFrom(const SubstitutionBits& other) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 144 |
| 143 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) { | 145 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) { |
| 144 // All tool types except "output" (which would be infinitely recursive). | 146 // All tool types except "output" (which would be infinitely recursive). |
| 145 return (IsValidToolSubstutition(type) && type != SUBSTITUTION_OUTPUT) || | 147 return (IsValidToolSubstutition(type) && type != SUBSTITUTION_OUTPUT) || |
| 146 IsValidSourceSubstitution(type); | 148 IsValidSourceSubstitution(type); |
| 147 } | 149 } |
| 148 | 150 |
| 149 bool IsValidLinkerSubstitution(SubstitutionType type) { | 151 bool IsValidLinkerSubstitution(SubstitutionType type) { |
| 150 return IsValidToolSubstutition(type) || | 152 return IsValidToolSubstutition(type) || |
| 151 type == SUBSTITUTION_LINKER_INPUTS || | 153 type == SUBSTITUTION_LINKER_INPUTS || |
| 154 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE || |
| 152 type == SUBSTITUTION_LDFLAGS || | 155 type == SUBSTITUTION_LDFLAGS || |
| 153 type == SUBSTITUTION_LIBS || | 156 type == SUBSTITUTION_LIBS || |
| 154 type == SUBSTITUTION_OUTPUT_EXTENSION || | 157 type == SUBSTITUTION_OUTPUT_EXTENSION || |
| 155 type == SUBSTITUTION_SOLIBS; | 158 type == SUBSTITUTION_SOLIBS; |
| 156 } | 159 } |
| 157 | 160 |
| 158 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { | 161 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { |
| 159 // All valid compiler outputs plus the output extension. | 162 // All valid compiler outputs plus the output extension. |
| 160 return IsValidCompilerOutputsSubstitution(type) || | 163 return IsValidCompilerOutputsSubstitution(type) || |
| 161 type == SUBSTITUTION_OUTPUT_EXTENSION; | 164 type == SUBSTITUTION_OUTPUT_EXTENSION; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 174 if (!IsValidSourceSubstitution(types[i])) { | 177 if (!IsValidSourceSubstitution(types[i])) { |
| 175 *err = Err(origin, "Invalid substitution type.", | 178 *err = Err(origin, "Invalid substitution type.", |
| 176 "The substitution " + std::string(kSubstitutionNames[i]) + | 179 "The substitution " + std::string(kSubstitutionNames[i]) + |
| 177 " isn't valid for something\n" | 180 " isn't valid for something\n" |
| 178 "operating on a source file such as this."); | 181 "operating on a source file such as this."); |
| 179 return false; | 182 return false; |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 return true; | 185 return true; |
| 183 } | 186 } |
| OLD | NEW |