1/// ************************************************************* 2/// 3/// Licensed to the Apache Software Foundation (ASF) under one 4/// or more contributor license agreements. See the NOTICE file 5/// distributed with this work for additional information 6/// regarding copyright ownership. The ASF licenses this file 7/// to you under the Apache License, Version 2.0 (the 8/// "License"); you may not use this file except in compliance 9/// with the License. You may obtain a copy of the License at 10/// 11/// http://www.apache.org/licenses/LICENSE-2.0 12/// 13/// Unless required by applicable law or agreed to in writing, 14/// software distributed under the License is distributed on an 15/// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16/// KIND, either express or implied. See the License for the 17/// specific language governing permissions and limitations 18/// under the License. 19/// 20/// ************************************************************* 21#include <types.h> 22 23namespace gb 24{ 25 using namespace types; 26 27 class LinkTarget; 28 class Library; 29 class StaticLibrary; 30 class SdiTarget; 31 class Package; 32 33 /// CObjects are never used standalone. They only exist as part of a 34 /// LinkTarget. 35 class CObject : public HasSource, public HasDependencies, public Target 36 { 37 public: 38 Path get_source(); 39 private: 40 /// CObjects do not need to be explicitly constructed. 41 /// They are named after the path of their source file (without 42 /// file extension) from the root of their source repository. 43 CObject(String name); 44 friend class LinkTarget; 45 46 /// Platformdependent command to compile a plain C object. 47 static const Command command( 48 Path objectfile, 49 String name, 50 Path sourcefile, 51 List<String> defs, 52 List<String> cxxflags, 53 List<Path> include); 54 /// Platformdependent command to generate plain C object dependencies. 55 static const Command command_dep( 56 Path depfile, 57 String name, 58 Path sourcefile, 59 List<String> defs, 60 List<String> cxxflags, 61 List<Path> include); 62 }; 63 64 /// CxxObjects are never used standalone. They only exist as part of a 65 /// LinkTarget. 66 class CxxObject : public HasSource, public HasDependencies, public Target 67 { 68 public: 69 Path get_source(); 70 private: 71 /// CxxObjects do not need to be explicitly constructed. 72 /// They are named after the path of their source file (without 73 /// file extension) from the root of their source repository. 74 CxxObject(String name); 75 friend class LinkTarget; 76 77 /// Platformdependent command to compile a C++ object. 78 static const Command command( 79 Path objectfile, 80 String name, 81 Path sourcefile, 82 List<String> defs, 83 List<String> cxxflags, 84 List<Path> include); 85 /// Platformdependent command to generate C++ object dependencies. 86 static const Command command_dep( 87 Path objectfile, 88 String name, 89 Path sourcefile, 90 List<String> defs, 91 List<String> cxxflags, 92 List<Path> include); 93 }; 94 95 class LinkTarget : public IsCleanable, public HasDependencies, public IsLinking, public DeliversHeaders, public HasCompileSettings, public Target 96 { 97 public: 98 LinkTarget(String name); 99 100 private: 101 void get_external_headers_check(); 102 void add_internal_headers(const List<Target>& internal_headers); 103 104 /// @warning Evil Hack: SELF is set to the name of the LinkTarget 105 /// in the constructor. If SELF is not set to the LinkTarget name in 106 /// the execution of the header rule, the LinkTarget is used (linked 107 /// against) but was never defined. This might work out, if the 108 /// LinkTarget has been provided by other means (for example: 109 /// build.pl/dmake), but it should never happen in a project where 110 /// all LinkTarget s are controlled by gbuild. 111 LinkTarget& SELF; 112 List<CObject> COBJECTS; 113 List<CxxObject> CXXOBJECTS; 114 List<Library> LINKED_LIBS; 115 List<Path> AUXTARGETS; 116 List<Path> INCLUDE; 117 List<Path> INCLUDE_STL; 118 List<StaticLibrary> LINKED_STATIC_LIBS; 119 List<String> CFLAGS; 120 List<String> CXXFLAGS; 121 List<String> DEFS; 122 List<String> LDFLAGS; 123 List<String> TARGETTYPE_FLAGS; 124 Path DLLTARGET; 125 126 /// Platformdependent command for linking. 127 static const Command command ( 128 Path linktargetfile, 129 String linktargetname, 130 List<String> linkflags, 131 List<Library> linked_libs, 132 List<StaticLibrary> linked_static_libs, 133 List<CObject> cobjects, 134 List<CxxObject> cxxobjects); 135 /// Command to collect all dependencies of this LinkTarget. 136 static const Command command_dep( 137 Path depfile, 138 String linktargetname, 139 List<CObject> cobjects, 140 List<CxxObject> cxxobjects); 141 static const List<String> DEFAULTDEFS; 142 static const List<String> CXXFLAGS; 143 static const List<String> LDFLAGS; 144 static const List<Path> INCLUDE; 145 static const List<Path> INCLUDE_STL; 146 }; 147} 148/* vim: set filetype=cpp : */ 149