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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "tools/gn/err.h" | 7 #include "tools/gn/err.h" |
8 #include "tools/gn/filesystem_utils.h" | 8 #include "tools/gn/filesystem_utils.h" |
9 #include "tools/gn/functions.h" | 9 #include "tools/gn/functions.h" |
10 #include "tools/gn/parse_tree.h" | 10 #include "tools/gn/parse_tree.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Trim slash since this function doesn't return trailing slashes. The | 81 // Trim slash since this function doesn't return trailing slashes. The |
82 // times we don't do this are if the result is "/" and "//" since those | 82 // times we don't do this are if the result is "/" and "//" since those |
83 // slashes can't be trimmed. | 83 // slashes can't be trimmed. |
84 if (dir_incl_slash == "/") | 84 if (dir_incl_slash == "/") |
85 return std::string("/."); | 85 return std::string("/."); |
86 if (dir_incl_slash == "//") | 86 if (dir_incl_slash == "//") |
87 return std::string("//."); | 87 return std::string("//."); |
88 return dir_incl_slash.substr(0, dir_incl_slash.size() - 1).as_string(); | 88 return dir_incl_slash.substr(0, dir_incl_slash.size() - 1).as_string(); |
89 } | 89 } |
90 case WHAT_GEN_DIR: { | 90 case WHAT_GEN_DIR: { |
91 return DirectoryWithNoLastSlash( | 91 return DirectoryWithNoLastSlash(GetSubBuildDirAsSourceDir( |
92 GetGenDirForSourceDir(settings, | 92 BuildDirContext(settings), |
93 DirForInput(settings, current_dir, | 93 DirForInput(settings, current_dir, input, err), |
94 input, err))); | 94 BuildDirType::GEN)); |
95 } | 95 } |
96 case WHAT_OUT_DIR: { | 96 case WHAT_OUT_DIR: { |
97 return DirectoryWithNoLastSlash( | 97 return DirectoryWithNoLastSlash(GetSubBuildDirAsSourceDir( |
98 GetOutputDirForSourceDir(settings, | 98 BuildDirContext(settings), |
99 DirForInput(settings, current_dir, | 99 DirForInput(settings, current_dir, input, err), |
100 input, err))); | 100 BuildDirType::OBJ)); |
101 } | 101 } |
102 case WHAT_ABSPATH: { | 102 case WHAT_ABSPATH: { |
103 if (!input_string.empty() && | 103 if (!input_string.empty() && |
104 input_string[input_string.size() - 1] == '/') { | 104 input_string[input_string.size() - 1] == '/') { |
105 return current_dir.ResolveRelativeDir(input, err, | 105 return current_dir.ResolveRelativeDir(input, err, |
106 settings->build_settings()->root_path_utf8()).value(); | 106 settings->build_settings()->root_path_utf8()).value(); |
107 } else { | 107 } else { |
108 return current_dir.ResolveRelativeFile(input, err, | 108 return current_dir.ResolveRelativeFile(input, err, |
109 settings->build_settings()->root_path_utf8()).value(); | 109 settings->build_settings()->root_path_utf8()).value(); |
110 } | 110 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 "\n" | 161 "\n" |
162 " The result will never end in a slash, so if the resulting\n" | 162 " The result will never end in a slash, so if the resulting\n" |
163 " is empty, the system (\"/\") or source (\"//\") roots, a \".\"\n" | 163 " is empty, the system (\"/\") or source (\"//\") roots, a \".\"\n" |
164 " will be appended such that it is always legal to append a slash\n" | 164 " will be appended such that it is always legal to append a slash\n" |
165 " and a filename and get a valid path.\n" | 165 " and a filename and get a valid path.\n" |
166 "\n" | 166 "\n" |
167 " \"out_dir\"\n" | 167 " \"out_dir\"\n" |
168 " The output file directory corresponding to the path of the\n" | 168 " The output file directory corresponding to the path of the\n" |
169 " given file, not including a trailing slash.\n" | 169 " given file, not including a trailing slash.\n" |
170 " \"//foo/bar/baz.txt\" => \"//out/Default/obj/foo/bar\"\n" | 170 " \"//foo/bar/baz.txt\" => \"//out/Default/obj/foo/bar\"\n" |
171 | 171 "\n" |
172 " \"gen_dir\"\n" | 172 " \"gen_dir\"\n" |
173 " The generated file directory corresponding to the path of the\n" | 173 " The generated file directory corresponding to the path of the\n" |
174 " given file, not including a trailing slash.\n" | 174 " given file, not including a trailing slash.\n" |
175 " \"//foo/bar/baz.txt\" => \"//out/Default/gen/foo/bar\"\n" | 175 " \"//foo/bar/baz.txt\" => \"//out/Default/gen/foo/bar\"\n" |
176 "\n" | 176 "\n" |
177 " \"abspath\"\n" | 177 " \"abspath\"\n" |
178 " The full absolute path name to the file or directory. It will be\n" | 178 " The full absolute path name to the file or directory. It will be\n" |
179 " resolved relative to the current directory, and then the source-\n" | 179 " resolved relative to the current directory, and then the source-\n" |
180 " absolute version will be returned. If the input is system-\n" | 180 " absolute version will be returned. If the input is system-\n" |
181 " absolute, the same input will be returned.\n" | 181 " absolute, the same input will be returned.\n" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return Value(); | 244 return Value(); |
245 } | 245 } |
246 return result; | 246 return result; |
247 } | 247 } |
248 | 248 |
249 *err = Err(args[0], "Path must be a string or a list of strings."); | 249 *err = Err(args[0], "Path must be a string or a list of strings."); |
250 return Value(); | 250 return Value(); |
251 } | 251 } |
252 | 252 |
253 } // namespace functions | 253 } // namespace functions |
OLD | NEW |