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 "tools/gn/functions.h" | 5 #include "tools/gn/functions.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <iostream> | 8 #include <iostream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (!EnsureSingleStringArg(function, args, err) || | 294 if (!EnsureSingleStringArg(function, args, err) || |
295 !EnsureNotProcessingImport(function, scope, err)) | 295 !EnsureNotProcessingImport(function, scope, err)) |
296 return Value(); | 296 return Value(); |
297 | 297 |
298 Label label(MakeLabelForScope(scope, function, args[0].string_value())); | 298 Label label(MakeLabelForScope(scope, function, args[0].string_value())); |
299 | 299 |
300 if (g_scheduler->verbose_logging()) | 300 if (g_scheduler->verbose_logging()) |
301 g_scheduler->Log("Defining config", label.GetUserVisibleName(true)); | 301 g_scheduler->Log("Defining config", label.GetUserVisibleName(true)); |
302 | 302 |
303 // Create the new config. | 303 // Create the new config. |
304 scoped_ptr<Config> config(new Config(scope->settings(), label)); | 304 std::unique_ptr<Config> config(new Config(scope->settings(), label)); |
305 config->set_defined_from(function); | 305 config->set_defined_from(function); |
306 if (!Visibility::FillItemVisibility(config.get(), scope, err)) | 306 if (!Visibility::FillItemVisibility(config.get(), scope, err)) |
307 return Value(); | 307 return Value(); |
308 | 308 |
309 // Fill the flags and such. | 309 // Fill the flags and such. |
310 const SourceDir& input_dir = scope->GetSourceDir(); | 310 const SourceDir& input_dir = scope->GetSourceDir(); |
311 ConfigValuesGenerator gen(&config->own_values(), scope, input_dir, err); | 311 ConfigValuesGenerator gen(&config->own_values(), scope, input_dir, err); |
312 gen.Run(); | 312 gen.Run(); |
313 if (err->has_error()) | 313 if (err->has_error()) |
314 return Value(); | 314 return Value(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 "\n" | 528 "\n" |
529 " home_dir = getenv(\"HOME\")\n"; | 529 " home_dir = getenv(\"HOME\")\n"; |
530 | 530 |
531 Value RunGetEnv(Scope* scope, | 531 Value RunGetEnv(Scope* scope, |
532 const FunctionCallNode* function, | 532 const FunctionCallNode* function, |
533 const std::vector<Value>& args, | 533 const std::vector<Value>& args, |
534 Err* err) { | 534 Err* err) { |
535 if (!EnsureSingleStringArg(function, args, err)) | 535 if (!EnsureSingleStringArg(function, args, err)) |
536 return Value(); | 536 return Value(); |
537 | 537 |
538 scoped_ptr<base::Environment> env(base::Environment::Create()); | 538 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
539 | 539 |
540 std::string result; | 540 std::string result; |
541 if (!env->GetVar(args[0].string_value().c_str(), &result)) | 541 if (!env->GetVar(args[0].string_value().c_str(), &result)) |
542 return Value(function, ""); // Not found, return empty string. | 542 return Value(function, ""); // Not found, return empty string. |
543 return Value(function, result); | 543 return Value(function, result); |
544 } | 544 } |
545 | 545 |
546 // import ---------------------------------------------------------------------- | 546 // import ---------------------------------------------------------------------- |
547 | 547 |
548 const char kImport[] = "import"; | 548 const char kImport[] = "import"; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 " print(sources)\n" | 663 " print(sources)\n" |
664 " # Will print [ \"a.cc\" ]. b_win one was filtered out.\n"; | 664 " # Will print [ \"a.cc\" ]. b_win one was filtered out.\n"; |
665 | 665 |
666 Value RunSetSourcesAssignmentFilter(Scope* scope, | 666 Value RunSetSourcesAssignmentFilter(Scope* scope, |
667 const FunctionCallNode* function, | 667 const FunctionCallNode* function, |
668 const std::vector<Value>& args, | 668 const std::vector<Value>& args, |
669 Err* err) { | 669 Err* err) { |
670 if (args.size() != 1) { | 670 if (args.size() != 1) { |
671 *err = Err(function, "set_sources_assignment_filter takes one argument."); | 671 *err = Err(function, "set_sources_assignment_filter takes one argument."); |
672 } else { | 672 } else { |
673 scoped_ptr<PatternList> f(new PatternList); | 673 std::unique_ptr<PatternList> f(new PatternList); |
674 f->SetFromValue(args[0], err); | 674 f->SetFromValue(args[0], err); |
675 if (!err->has_error()) | 675 if (!err->has_error()) |
676 scope->set_sources_assignment_filter(std::move(f)); | 676 scope->set_sources_assignment_filter(std::move(f)); |
677 } | 677 } |
678 return Value(); | 678 return Value(); |
679 } | 679 } |
680 | 680 |
681 // print ----------------------------------------------------------------------- | 681 // print ----------------------------------------------------------------------- |
682 | 682 |
683 const char kPrint[] = "print"; | 683 const char kPrint[] = "print"; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 } | 921 } |
922 | 922 |
923 // Otherwise it's a no-block function. | 923 // Otherwise it's a no-block function. |
924 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 924 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
925 return Value(); | 925 return Value(); |
926 return found_function->second.no_block_runner(scope, function, | 926 return found_function->second.no_block_runner(scope, function, |
927 args.list_value(), err); | 927 args.list_value(), err); |
928 } | 928 } |
929 | 929 |
930 } // namespace functions | 930 } // namespace functions |
OLD | NEW |