gyp_target_writer.h revision d57369da7c6519fef57db42085f7b42d4c8845c1
14e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 24e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 34e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// found in the LICENSE file. 44e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 54e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#ifndef TOOLS_GN_GYP_TARGET_WRITER_H_ 64e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define TOOLS_GN_GYP_TARGET_WRITER_H_ 74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 84e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <iosfwd> 94e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <vector> 104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "base/basictypes.h" 124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "tools/gn/gyp_helper.h" 13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "tools/gn/path_output.h" 144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class BuilderRecord; 164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class Err; 174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class Settings; 184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class SourceFile; 194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class Target; 20d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles)class Toolchain; 214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class GypTargetWriter { 234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) public: 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) struct TargetGroup { 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TargetGroup() 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : debug(NULL), 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) release(NULL), 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) host_debug(NULL), 29d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) host_release(NULL), 30d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) debug64(NULL), 31d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) release64(NULL) { 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const BuilderRecord* debug; 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const BuilderRecord* release; 35d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) 36d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) // When the main compile is targeting a different architecture, these will 37d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) // contain the builds with the host system's toolchain. Only supported on 38d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) // Linux. 39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const BuilderRecord* host_debug; 40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const BuilderRecord* host_release; 41d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) 42d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) // On Windows, we do both 32-bit and 64-bit builds. Null on non-Windows. 43d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const BuilderRecord* debug64; 44d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const BuilderRecord* release64; 454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) }; 464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) GypTargetWriter(const Target* target, 48d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const Toolchain* toolchain, 49f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const SourceDir& gyp_dir, 50f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::ostream& out); 514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) virtual ~GypTargetWriter(); 524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) static void WriteFile(const SourceFile& gyp_file, 548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const std::vector<TargetGroup>& targets, 55d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const Toolchain* debug_toolchain, 564e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) Err* err); 574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) virtual void Run() = 0; 594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) protected: 61f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Writes the given number of spaces to the output stream and returns it. 62f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::ostream& Indent(int spaces); 63f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) static std::ostream& Indent(std::ostream& out, int spaces); 64f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 65f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) static const int kExtraIndent = 2; 66f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const Settings* settings_; // Non-owning. 684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const Target* target_; // Non-owning. 69d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const Toolchain* toolchain_; // Toolchain corresponding to target_. 70f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) SourceDir gyp_dir_; // Dir of GYP file. 714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) std::ostream& out_; 724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GypHelper helper_; 74f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) PathOutput path_output_; 754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) private: 774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(GypTargetWriter); 784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)}; 794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 804e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif // TOOLS_GN_GYP_TARGET_WRITER_H_ 81