Home | History | Annotate | Download | only in gn
      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/ninja_group_target_writer.h"
      6 
      7 #include "base/strings/string_util.h"
      8 #include "tools/gn/string_utils.h"
      9 
     10 NinjaGroupTargetWriter::NinjaGroupTargetWriter(const Target* target,
     11                                                const Toolchain* toolchain,
     12                                                std::ostream& out)
     13     : NinjaTargetWriter(target, toolchain, out) {
     14 }
     15 
     16 NinjaGroupTargetWriter::~NinjaGroupTargetWriter() {
     17 }
     18 
     19 void NinjaGroupTargetWriter::Run() {
     20   // A group rule just generates a stamp file with dependencies on each of
     21   // the deps in the group.
     22   out_ << std::endl << "build ";
     23   path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_));
     24   out_ << ": "
     25        << helper_.GetRulePrefix(target_->settings())
     26        << "stamp";
     27 
     28   const LabelTargetVector& deps = target_->deps();
     29   for (size_t i = 0; i < deps.size(); i++) {
     30     out_ << " ";
     31     path_output_.WriteFile(out_, helper_.GetTargetOutputFile(deps[i].ptr));
     32   }
     33 
     34   const LabelTargetVector& datadeps = target_->datadeps();
     35   for (size_t i = 0; i < datadeps.size(); i++) {
     36     out_ << " ";
     37     path_output_.WriteFile(out_, helper_.GetTargetOutputFile(datadeps[i].ptr));
     38   }
     39   out_ << std::endl;
     40 }
     41