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

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

Issue 26561005: GYP generator for GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months 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/ninja_binary_target_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "tools/gn/gyp_target_writer.h"
6
7 #include <iostream>
8
9 #include "base/file_util.h"
10 #include "base/files/file_path.h"
11 #include "tools/gn/build_settings.h"
12 #include "tools/gn/filesystem_utils.h"
13 #include "tools/gn/gyp_binary_target_writer.h"
14 #include "tools/gn/scheduler.h"
15 #include "tools/gn/settings.h"
16 #include "tools/gn/target.h"
17
18 GypTargetWriter::GypTargetWriter(const Target* target, std::ostream& out)
19 : settings_(target->settings()),
20 target_(target),
21 out_(out) {
22 }
23
24 GypTargetWriter::~GypTargetWriter() {
25 }
26
27 // static
28 void GypTargetWriter::WriteFile(const SourceFile& gyp_file,
29 const std::vector<TargetPair>& targets,
30 Err* err) {
31 if (targets.empty())
32 return;
33 const BuildSettings* debug_build_settings =
34 targets[0].debug->settings()->build_settings();
35
36 std::stringstream file;
37 file << "# Generated by GN. Do not edit.\n\n";
38 file << "{\n";
39 file << " 'skip_includes': 1,\n";
40 file << " 'targets': [\n";
41
42 for (size_t i = 0; i < targets.size(); i++) {
43 switch (targets[i].debug->output_type()) {
44 case Target::COPY_FILES:
45 case Target::CUSTOM:
46 case Target::GROUP:
47 break; // TODO(brettw)
48 case Target::EXECUTABLE:
49 case Target::STATIC_LIBRARY:
50 case Target::SHARED_LIBRARY:
51 case Target::SOURCE_SET: {
52 GypBinaryTargetWriter writer(targets[i].debug, targets[i].release,
53 file);
54 writer.Run();
55 break;
56 }
57 default:
58 CHECK(0);
59 }
60 }
61
62 file << " ],\n}\n";
63
64 base::FilePath gyp_file_path = debug_build_settings->GetFullPath(gyp_file);
65 std::string contents = file.str();
66 file_util::WriteFile(gyp_file_path, contents.c_str(),
67 static_cast<int>(contents.size()));
68 }
69
OLDNEW
« no previous file with comments | « tools/gn/gyp_target_writer.h ('k') | tools/gn/ninja_binary_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698