Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: tools/gn/gyp_target_writer.cc

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/gyp_target_writer.h ('k') | tools/gn/input_file_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gyp_target_writer.h" 5 #include "tools/gn/gyp_target_writer.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "tools/gn/build_settings.h" 11 #include "tools/gn/build_settings.h"
12 #include "tools/gn/builder_record.h"
12 #include "tools/gn/filesystem_utils.h" 13 #include "tools/gn/filesystem_utils.h"
13 #include "tools/gn/gyp_binary_target_writer.h" 14 #include "tools/gn/gyp_binary_target_writer.h"
14 #include "tools/gn/scheduler.h" 15 #include "tools/gn/scheduler.h"
15 #include "tools/gn/settings.h" 16 #include "tools/gn/settings.h"
16 #include "tools/gn/target.h" 17 #include "tools/gn/target.h"
17 18
18 GypTargetWriter::GypTargetWriter(const Target* target, std::ostream& out) 19 GypTargetWriter::GypTargetWriter(const Target* target, std::ostream& out)
19 : settings_(target->settings()), 20 : settings_(target->settings()),
20 target_(target), 21 target_(target),
21 out_(out) { 22 out_(out) {
22 } 23 }
23 24
24 GypTargetWriter::~GypTargetWriter() { 25 GypTargetWriter::~GypTargetWriter() {
25 } 26 }
26 27
27 // static 28 // static
28 void GypTargetWriter::WriteFile(const SourceFile& gyp_file, 29 void GypTargetWriter::WriteFile(const SourceFile& gyp_file,
29 const std::vector<TargetGroup>& targets, 30 const std::vector<TargetGroup>& targets,
30 Err* err) { 31 Err* err) {
31 if (targets.empty()) 32 if (targets.empty())
32 return; 33 return;
33 const BuildSettings* debug_build_settings = 34 const Settings* debug_settings =
34 targets[0].debug->settings()->build_settings(); 35 targets[0].debug->item()->AsTarget()->settings();
36 const BuildSettings* debug_build_settings = debug_settings->build_settings();
35 37
36 std::stringstream file; 38 std::stringstream file;
37 file << "# Generated by GN. Do not edit.\n\n"; 39 file << "# Generated by GN. Do not edit.\n\n";
38 file << "{\n"; 40 file << "{\n";
39 file << " 'skip_includes': 1,\n"; 41 file << " 'skip_includes': 1,\n";
40 42
41 if (targets[0].debug->settings()->IsMac()) { 43 if (debug_settings->IsMac()) {
42 // Global settings for make/ninja. This must match common.gypi :( 44 // Global settings for make/ninja. This must match common.gypi :(
43 file << " 'make_global_settings': [\n"; 45 file << " 'make_global_settings': [\n";
44 file << " ['CC', 'third_party/llvm-build/Release+Asserts/bin/clang'],\n"; 46 file << " ['CC', 'third_party/llvm-build/Release+Asserts/bin/clang'],\n";
45 file << 47 file <<
46 " ['CXX', 'third_party/llvm-build/Release+Asserts/bin/clang++'],\n"; 48 " ['CXX', 'third_party/llvm-build/Release+Asserts/bin/clang++'],\n";
47 file << " ['CC.host', '$(CC)'],\n"; 49 file << " ['CC.host', '$(CC)'],\n";
48 file << " ['CXX.host', '$(CXX)'],\n"; 50 file << " ['CXX.host', '$(CXX)'],\n";
49 file << " ],\n"; 51 file << " ],\n";
50 } 52 }
51 // TODO(brettw) android. 53 // TODO(brettw) android.
52 54
53 file << " 'targets': [\n"; 55 file << " 'targets': [\n";
54 56
55 for (size_t i = 0; i < targets.size(); i++) { 57 for (size_t i = 0; i < targets.size(); i++) {
56 switch (targets[i].debug->output_type()) { 58 const Target* cur = targets[i].debug->item()->AsTarget();
59 switch (cur->output_type()) {
57 case Target::COPY_FILES: 60 case Target::COPY_FILES:
58 case Target::CUSTOM: 61 case Target::CUSTOM:
59 case Target::GROUP: 62 case Target::GROUP:
60 break; // TODO(brettw) 63 break; // TODO(brettw)
61 case Target::EXECUTABLE: 64 case Target::EXECUTABLE:
62 case Target::STATIC_LIBRARY: 65 case Target::STATIC_LIBRARY:
63 case Target::SHARED_LIBRARY: 66 case Target::SHARED_LIBRARY:
64 case Target::SOURCE_SET: { 67 case Target::SOURCE_SET: {
65 GypBinaryTargetWriter writer(targets[i], file); 68 GypBinaryTargetWriter writer(targets[i], file);
66 writer.Run(); 69 writer.Run();
67 break; 70 break;
68 } 71 }
69 default: 72 default:
70 CHECK(0); 73 CHECK(0);
71 } 74 }
72 } 75 }
73 76
74 file << " ],\n}\n"; 77 file << " ],\n}\n";
75 78
76 base::FilePath gyp_file_path = debug_build_settings->GetFullPath(gyp_file); 79 base::FilePath gyp_file_path = debug_build_settings->GetFullPath(gyp_file);
77 std::string contents = file.str(); 80 std::string contents = file.str();
78 file_util::WriteFile(gyp_file_path, contents.c_str(), 81 file_util::WriteFile(gyp_file_path, contents.c_str(),
79 static_cast<int>(contents.size())); 82 static_cast<int>(contents.size()));
80 } 83 }
81 84
OLDNEW
« no previous file with comments | « tools/gn/gyp_target_writer.h ('k') | tools/gn/input_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698