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/setup.h" | 5 #include "tools/gn/setup.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 If unspecified, the ability to call exec_script is unrestricted. | 88 If unspecified, the ability to call exec_script is unrestricted. |
89 | 89 |
90 Example: | 90 Example: |
91 exec_script_whitelist = [ | 91 exec_script_whitelist = [ |
92 "//base/BUILD.gn", | 92 "//base/BUILD.gn", |
93 "//build/my_config.gni", | 93 "//build/my_config.gni", |
94 ] | 94 ] |
95 | 95 |
96 root [optional] | 96 root [optional] |
97 Label of the root build target. The GN build will start by loading the | 97 Label of the root build target. The GN build will start by loading the |
98 build file containing this target name. This defaults to "//:" which will | 98 build file containing this target name. This defaults to label which will |
brettw
2017/04/19 19:49:25
This new text isn't gramatical. I think the old te
Petr Hosek
2017/04/19 20:20:26
Done.
Dirk Pranke
2017/04/19 23:01:27
FWIW, I still find it confusing.
| |
99 cause the file //BUILD.gn to be loaded. | 99 cause the file //BUILD.gn to be loaded. |
100 | 100 |
101 secondary_source [optional] | 101 secondary_source [optional] |
102 Label of an alternate directory tree to find input files. When searching | 102 Label of an alternate directory tree to find input files. When searching |
103 for a BUILD.gn file (or the build config file discussed above), the file | 103 for a BUILD.gn file (or the build config file discussed above), the file |
104 will first be looked for in the source root. If it's not found, the | 104 will first be looked for in the source root. If it's not found, the |
105 secondary source root will be checked (which would contain a parallel | 105 secondary source root will be checked (which would contain a parallel |
106 directory hierarchy). | 106 directory hierarchy). |
107 | 107 |
108 This behavior is intended to be used when BUILD.gn files can't be checked | 108 This behavior is intended to be used when BUILD.gn files can't be checked |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 err.PrintToStdout(); | 691 err.PrintToStdout(); |
692 return false; | 692 return false; |
693 } | 693 } |
694 | 694 |
695 return true; | 695 return true; |
696 } | 696 } |
697 | 697 |
698 bool Setup::FillOtherConfig(const base::CommandLine& cmdline) { | 698 bool Setup::FillOtherConfig(const base::CommandLine& cmdline) { |
699 Err err; | 699 Err err; |
700 SourceDir current_dir("//"); | 700 SourceDir current_dir("//"); |
701 Label root_target_label(current_dir, ""); | |
701 | 702 |
702 // Secondary source path, read from the config file if present. | 703 // Secondary source path, read from the config file if present. |
703 // Read from the config file if present. | 704 // Read from the config file if present. |
704 const Value* secondary_value = | 705 const Value* secondary_value = |
705 dotfile_scope_.GetValue("secondary_source", true); | 706 dotfile_scope_.GetValue("secondary_source", true); |
706 if (secondary_value) { | 707 if (secondary_value) { |
707 if (!secondary_value->VerifyTypeIs(Value::STRING, &err)) { | 708 if (!secondary_value->VerifyTypeIs(Value::STRING, &err)) { |
708 err.PrintToStdout(); | 709 err.PrintToStdout(); |
709 return false; | 710 return false; |
710 } | 711 } |
711 build_settings_.SetSecondarySourcePath( | 712 build_settings_.SetSecondarySourcePath( |
712 SourceDir(secondary_value->string_value())); | 713 SourceDir(secondary_value->string_value())); |
713 } | 714 } |
714 | 715 |
715 // Root build file. | 716 // Root build file. |
716 const Value* root_value = dotfile_scope_.GetValue("root", true); | 717 const Value* root_value = dotfile_scope_.GetValue("root", true); |
717 if (root_value) { | 718 if (root_value) { |
718 if (!root_value->VerifyTypeIs(Value::STRING, &err)) { | 719 if (!root_value->VerifyTypeIs(Value::STRING, &err)) { |
719 err.PrintToStdout(); | 720 err.PrintToStdout(); |
720 return false; | 721 return false; |
721 } | 722 } |
722 | 723 |
723 Label root_target_label = | 724 root_target_label = Label::Resolve(current_dir, Label(), *root_value, &err); |
724 Label::Resolve(current_dir, Label(), *root_value, &err); | |
725 if (err.has_error()) { | 725 if (err.has_error()) { |
726 err.PrintToStdout(); | 726 err.PrintToStdout(); |
727 return false; | 727 return false; |
728 } | 728 } |
729 | 729 |
730 root_build_file_ = Loader::BuildFileForLabel(root_target_label); | 730 root_build_file_ = Loader::BuildFileForLabel(root_target_label); |
731 } | 731 } |
732 build_settings_.SetRootTargetLabel(root_target_label); | |
732 | 733 |
733 // Build config file. | 734 // Build config file. |
734 const Value* build_config_value = | 735 const Value* build_config_value = |
735 dotfile_scope_.GetValue("buildconfig", true); | 736 dotfile_scope_.GetValue("buildconfig", true); |
736 if (!build_config_value) { | 737 if (!build_config_value) { |
737 Err(Location(), "No build config file.", | 738 Err(Location(), "No build config file.", |
738 "Your .gn file (\"" + FilePathToUTF8(dotfile_name_) + "\")\n" | 739 "Your .gn file (\"" + FilePathToUTF8(dotfile_name_) + "\")\n" |
739 "didn't specify a \"buildconfig\" value.").PrintToStdout(); | 740 "didn't specify a \"buildconfig\" value.").PrintToStdout(); |
740 return false; | 741 return false; |
741 } else if (!build_config_value->VerifyTypeIs(Value::STRING, &err)) { | 742 } else if (!build_config_value->VerifyTypeIs(Value::STRING, &err)) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) { | 801 if (!arg_file_template_value->VerifyTypeIs(Value::STRING, &err)) { |
801 err.PrintToStdout(); | 802 err.PrintToStdout(); |
802 return false; | 803 return false; |
803 } | 804 } |
804 SourceFile path(arg_file_template_value->string_value()); | 805 SourceFile path(arg_file_template_value->string_value()); |
805 build_settings_.set_arg_file_template_path(path); | 806 build_settings_.set_arg_file_template_path(path); |
806 } | 807 } |
807 | 808 |
808 return true; | 809 return true; |
809 } | 810 } |
OLD | NEW |