| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/build_settings.h" | 7 #include "tools/gn/build_settings.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 " current directory to be relative to the build directory (which will\n" | 137 " current directory to be relative to the build directory (which will\n" |
| 138 " be the current directory when executing scripts).\n" | 138 " be the current directory when executing scripts).\n" |
| 139 "\n" | 139 "\n" |
| 140 " If you want to convert a file path to be source-absolute (that is,\n" | 140 " If you want to convert a file path to be source-absolute (that is,\n" |
| 141 " beginning with a double slash like \"//foo/bar\"), you should use\n" | 141 " beginning with a double slash like \"//foo/bar\"), you should use\n" |
| 142 " the get_path_info() function. This function won't work because it will\n" | 142 " the get_path_info() function. This function won't work because it will\n" |
| 143 " always make relative paths, and it needs to support making paths\n" | 143 " always make relative paths, and it needs to support making paths\n" |
| 144 " relative to the source root, so can't also generate source-absolute\n" | 144 " relative to the source root, so can't also generate source-absolute\n" |
| 145 " paths without more special-cases.\n" | 145 " paths without more special-cases.\n" |
| 146 "\n" | 146 "\n" |
| 147 "Arguments:\n" | 147 "Arguments\n" |
| 148 "\n" | 148 "\n" |
| 149 " input\n" | 149 " input\n" |
| 150 " A string or list of strings representing file or directory names\n" | 150 " A string or list of strings representing file or directory names\n" |
| 151 " These can be relative paths (\"foo/bar.txt\"), system absolute\n" | 151 " These can be relative paths (\"foo/bar.txt\"), system absolute\n" |
| 152 " paths (\"/foo/bar.txt\"), or source absolute paths\n" | 152 " paths (\"/foo/bar.txt\"), or source absolute paths\n" |
| 153 " (\"//foo/bar.txt\").\n" | 153 " (\"//foo/bar.txt\").\n" |
| 154 "\n" | 154 "\n" |
| 155 " new_base\n" | 155 " new_base\n" |
| 156 " The directory to convert the paths to be relative to. This can be\n" | 156 " The directory to convert the paths to be relative to. This can be\n" |
| 157 " an absolute path or a relative path (which will be treated\n" | 157 " an absolute path or a relative path (which will be treated\n" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 168 " relative to the current build file. Use \".\" (the default) to\n" | 168 " relative to the current build file. Use \".\" (the default) to\n" |
| 169 " convert paths from the current BUILD-file's directory.\n" | 169 " convert paths from the current BUILD-file's directory.\n" |
| 170 "\n" | 170 "\n" |
| 171 "Return value\n" | 171 "Return value\n" |
| 172 "\n" | 172 "\n" |
| 173 " The return value will be the same type as the input value (either a\n" | 173 " The return value will be the same type as the input value (either a\n" |
| 174 " string or a list of strings). All relative and source-absolute file\n" | 174 " string or a list of strings). All relative and source-absolute file\n" |
| 175 " names will be converted to be relative to the requested output\n" | 175 " names will be converted to be relative to the requested output\n" |
| 176 " System-absolute paths will be unchanged.\n" | 176 " System-absolute paths will be unchanged.\n" |
| 177 "\n" | 177 "\n" |
| 178 " Whether an output path will end in a slash will match whether the\n" |
| 179 " corresponding input path ends in a slash. It will return \".\" or\n" |
| 180 " \"./\" (depending on whether the input ends in a slash) to avoid\n" |
| 181 " returning empty strings. This means if you want a root path\n" |
| 182 " (\"//\" or \"/\") not ending in a slash, you can add a dot (\"//.\").\n" |
| 183 "\n" |
| 178 "Example\n" | 184 "Example\n" |
| 179 "\n" | 185 "\n" |
| 180 " # Convert a file in the current directory to be relative to the build\n" | 186 " # Convert a file in the current directory to be relative to the build\n" |
| 181 " # directory (the current dir when executing compilers and scripts).\n" | 187 " # directory (the current dir when executing compilers and scripts).\n" |
| 182 " foo = rebase_path(\"myfile.txt\", root_build_dir)\n" | 188 " foo = rebase_path(\"myfile.txt\", root_build_dir)\n" |
| 183 " # might produce \"../../project/myfile.txt\".\n" | 189 " # might produce \"../../project/myfile.txt\".\n" |
| 184 "\n" | 190 "\n" |
| 185 " # Convert a file to be system absolute:\n" | 191 " # Convert a file to be system absolute:\n" |
| 186 " foo = rebase_path(\"myfile.txt\")\n" | 192 " foo = rebase_path(\"myfile.txt\")\n" |
| 187 " # Might produce \"D:\\source\\project\\myfile.txt\" on Windows or\n" | 193 " # Might produce \"D:\\source\\project\\myfile.txt\" on Windows or\n" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 280 } |
| 275 return result; | 281 return result; |
| 276 } | 282 } |
| 277 | 283 |
| 278 *err = Err(function->function(), | 284 *err = Err(function->function(), |
| 279 "rebase_path requires a list or a string."); | 285 "rebase_path requires a list or a string."); |
| 280 return result; | 286 return result; |
| 281 } | 287 } |
| 282 | 288 |
| 283 } // namespace functions | 289 } // namespace functions |
| OLD | NEW |