| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 base::FilePath up_one_dir = with_no_slash.DirName(); | 133 base::FilePath up_one_dir = with_no_slash.DirName(); |
| 134 if (up_one_dir == current_dir) | 134 if (up_one_dir == current_dir) |
| 135 return base::FilePath(); // Got to the top. | 135 return base::FilePath(); // Got to the top. |
| 136 | 136 |
| 137 return FindDotFile(up_one_dir); | 137 return FindDotFile(up_one_dir); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Called on any thread. Post the item to the builder on the main thread. | 140 // Called on any thread. Post the item to the builder on the main thread. |
| 141 void ItemDefinedCallback(base::MessageLoop* main_loop, | 141 void ItemDefinedCallback(base::MessageLoop* main_loop, |
| 142 scoped_refptr<Builder> builder, | 142 scoped_refptr<Builder> builder, |
| 143 scoped_ptr<Item> item) { | 143 std::unique_ptr<Item> item) { |
| 144 DCHECK(item); | 144 DCHECK(item); |
| 145 main_loop->PostTask(FROM_HERE, base::Bind(&Builder::ItemDefined, builder, | 145 main_loop->PostTask(FROM_HERE, base::Bind(&Builder::ItemDefined, builder, |
| 146 base::Passed(&item))); | 146 base::Passed(&item))); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void DecrementWorkCount() { | 149 void DecrementWorkCount() { |
| 150 g_scheduler->DecrementWorkCount(); | 150 g_scheduler->DecrementWorkCount(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 base::FilePath cur_dir_candidate_exe = | 192 base::FilePath cur_dir_candidate_exe = |
| 193 base::FilePath(current_directory).Append(kPythonExeName); | 193 base::FilePath(current_directory).Append(kPythonExeName); |
| 194 if (base::PathExists(cur_dir_candidate_exe)) | 194 if (base::PathExists(cur_dir_candidate_exe)) |
| 195 return cur_dir_candidate_exe; | 195 return cur_dir_candidate_exe; |
| 196 | 196 |
| 197 // Get the path. | 197 // Get the path. |
| 198 const base::char16 kPathEnvVarName[] = L"Path"; | 198 const base::char16 kPathEnvVarName[] = L"Path"; |
| 199 DWORD path_length = ::GetEnvironmentVariable(kPathEnvVarName, nullptr, 0); | 199 DWORD path_length = ::GetEnvironmentVariable(kPathEnvVarName, nullptr, 0); |
| 200 if (path_length == 0) | 200 if (path_length == 0) |
| 201 return base::FilePath(); | 201 return base::FilePath(); |
| 202 scoped_ptr<base::char16[]> full_path(new base::char16[path_length]); | 202 std::unique_ptr<base::char16[]> full_path(new base::char16[path_length]); |
| 203 DWORD actual_path_length = | 203 DWORD actual_path_length = |
| 204 ::GetEnvironmentVariable(kPathEnvVarName, full_path.get(), path_length); | 204 ::GetEnvironmentVariable(kPathEnvVarName, full_path.get(), path_length); |
| 205 CHECK_EQ(path_length, actual_path_length + 1); | 205 CHECK_EQ(path_length, actual_path_length + 1); |
| 206 | 206 |
| 207 // Search for python.exe in the path. | 207 // Search for python.exe in the path. |
| 208 for (const auto& component : base::SplitStringPiece( | 208 for (const auto& component : base::SplitStringPiece( |
| 209 base::StringPiece16(full_path.get(), path_length), L";", | 209 base::StringPiece16(full_path.get(), path_length), L";", |
| 210 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 210 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
| 211 base::FilePath candidate_exe = | 211 base::FilePath candidate_exe = |
| 212 base::FilePath(component).Append(kPythonExeName); | 212 base::FilePath(component).Append(kPythonExeName); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 705 |
| 706 // Fill exec_script_whitelist. | 706 // Fill exec_script_whitelist. |
| 707 const Value* exec_script_whitelist_value = | 707 const Value* exec_script_whitelist_value = |
| 708 dotfile_scope_.GetValue("exec_script_whitelist", true); | 708 dotfile_scope_.GetValue("exec_script_whitelist", true); |
| 709 if (exec_script_whitelist_value) { | 709 if (exec_script_whitelist_value) { |
| 710 // Fill the list of targets to check. | 710 // Fill the list of targets to check. |
| 711 if (!exec_script_whitelist_value->VerifyTypeIs(Value::LIST, &err)) { | 711 if (!exec_script_whitelist_value->VerifyTypeIs(Value::LIST, &err)) { |
| 712 err.PrintToStdout(); | 712 err.PrintToStdout(); |
| 713 return false; | 713 return false; |
| 714 } | 714 } |
| 715 scoped_ptr<std::set<SourceFile>> whitelist(new std::set<SourceFile>); | 715 std::unique_ptr<std::set<SourceFile>> whitelist(new std::set<SourceFile>); |
| 716 for (const auto& item : exec_script_whitelist_value->list_value()) { | 716 for (const auto& item : exec_script_whitelist_value->list_value()) { |
| 717 if (!item.VerifyTypeIs(Value::STRING, &err)) { | 717 if (!item.VerifyTypeIs(Value::STRING, &err)) { |
| 718 err.PrintToStdout(); | 718 err.PrintToStdout(); |
| 719 return false; | 719 return false; |
| 720 } | 720 } |
| 721 whitelist->insert(current_dir.ResolveRelativeFile(item, &err)); | 721 whitelist->insert(current_dir.ResolveRelativeFile(item, &err)); |
| 722 if (err.has_error()) { | 722 if (err.has_error()) { |
| 723 err.PrintToStdout(); | 723 err.PrintToStdout(); |
| 724 return false; | 724 return false; |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 build_settings_.set_exec_script_whitelist(std::move(whitelist)); | 727 build_settings_.set_exec_script_whitelist(std::move(whitelist)); |
| 728 } | 728 } |
| 729 | 729 |
| 730 return true; | 730 return true; |
| 731 } | 731 } |
| OLD | NEW |