| 1 |
/* |
| 2 |
Copyright (C) 2018, 2019, 2020, 2021 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
Written by: Gregory John Casamento <[email protected]> |
| 5 |
Date: 2022 |
| 6 |
|
| 7 |
This file is part of the GNUstep XCode Library |
| 8 |
|
| 9 |
This library is free software; you can redistribute it and/or |
| 10 |
modify it under the terms of the GNU Lesser General Public |
| 11 |
License as published by the Free Software Foundation; either |
| 12 |
version 2 of the License, or (at your option) any later version. |
| 13 |
|
| 14 |
This library is distributed in the hope that it will be useful, |
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
Lesser General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU Lesser General Public |
| 20 |
License along with this library; if not, write to the Free |
| 21 |
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 |
Boston, MA 02110 USA. |
| 23 |
*/ |
| 24 |
|
| 25 |
#import <stdlib.h> |
| 26 |
#import "PBXCommon.h" |
| 27 |
#import "PBXTarget.h" |
| 28 |
#import "NSString+PBXAdditions.h" |
| 29 |
#import "PBXProject.h" |
| 30 |
#import "GSXCBuildDatabase.h" |
| 31 |
|
| 32 |
@implementation PBXTarget |
| 33 |
|
| 34 |
- (void) dealloc |
| 35 |
{ |
| 36 |
RELEASE(_dependencies); |
| 37 |
RELEASE(_buildConfigurationList); |
| 38 |
RELEASE(_productName); |
| 39 |
RELEASE(_buildPhases); |
| 40 |
RELEASE(_name); |
| 41 |
RELEASE(_project); |
| 42 |
RELEASE(_productType); |
| 43 |
RELEASE(_fileSystemSynchronizedGroups); |
| 44 |
RELEASE(_packageProductDepedencies); |
| 45 |
|
| 46 |
[super dealloc]; |
| 47 |
} |
| 48 |
|
| 49 |
// Methods.... |
| 50 |
- (NSMutableArray *) fileSystemSynchronizedGroups |
| 51 |
{ |
| 52 |
return _fileSystemSynchronizedGroups; |
| 53 |
} |
| 54 |
|
| 55 |
- (void) setFileSystemSynchronizedGroups: (NSMutableArray *)object |
| 56 |
{ |
| 57 |
ASSIGN(_fileSystemSynchronizedGroups, object); |
| 58 |
} |
| 59 |
|
| 60 |
- (NSMutableArray *) packageProductDependencies |
| 61 |
{ |
| 62 |
return _packageProductDepedencies; |
| 63 |
} |
| 64 |
|
| 65 |
- (void) setPackageProductDependencies: (NSMutableArray *)object |
| 66 |
{ |
| 67 |
ASSIGN(_packageProductDepedencies, object); |
| 68 |
} |
| 69 |
|
| 70 |
- (PBXProject *) project |
| 71 |
{ |
| 72 |
return _project; |
| 73 |
} |
| 74 |
|
| 75 |
- (void) setProject: (PBXProject *)project |
| 76 |
{ |
| 77 |
ASSIGN(_project, project); |
| 78 |
} |
| 79 |
|
| 80 |
- (NSMutableArray *) dependencies // getter |
| 81 |
{ |
| 82 |
return _dependencies; |
| 83 |
} |
| 84 |
|
| 85 |
- (void) setDependencies: (NSMutableArray *)object; // setter |
| 86 |
{ |
| 87 |
ASSIGN(_dependencies,object); |
| 88 |
} |
| 89 |
|
| 90 |
- (XCConfigurationList *) buildConfigurationList // getter |
| 91 |
{ |
| 92 |
return _buildConfigurationList; |
| 93 |
} |
| 94 |
|
| 95 |
- (void) setBuildConfigurationList: (XCConfigurationList *)object; // setter |
| 96 |
{ |
| 97 |
ASSIGN(_buildConfigurationList,object); |
| 98 |
} |
| 99 |
|
| 100 |
- (NSString *) productName // getter |
| 101 |
{ |
| 102 |
return _productName; |
| 103 |
} |
| 104 |
|
| 105 |
- (void) setProductName: (NSString *)object; // setter |
| 106 |
{ |
| 107 |
NSString *newName = [object stringByEliminatingSpecialCharacters]; |
| 108 |
ASSIGN(_productName,newName); |
| 109 |
} |
| 110 |
|
| 111 |
- (NSString *) name // getter |
| 112 |
{ |
| 113 |
return _name; |
| 114 |
} |
| 115 |
|
| 116 |
- (void) setName: (NSString *)object; // setter |
| 117 |
{ |
| 118 |
NSString *newName = [object stringByEliminatingSpecialCharacters]; |
| 119 |
ASSIGN(_name, newName); |
| 120 |
} |
| 121 |
|
| 122 |
- (NSMutableArray *) buildPhases // getter |
| 123 |
{ |
| 124 |
return _buildPhases; |
| 125 |
} |
| 126 |
|
| 127 |
- (void) setBuildPhases: (NSMutableArray *)object; // setter |
| 128 |
{ |
| 129 |
ASSIGN(_buildPhases,object); |
| 130 |
} |
| 131 |
|
| 132 |
- (void) setDatabase: (GSXCBuildDatabase *)db |
| 133 |
{ |
| 134 |
ASSIGN(_database, db); |
| 135 |
} |
| 136 |
|
| 137 |
- (GSXCBuildDatabase *) database |
| 138 |
{ |
| 139 |
return _database; |
| 140 |
} |
| 141 |
|
| 142 |
- (NSString *) productType // getter |
| 143 |
{ |
| 144 |
return _productType; |
| 145 |
} |
| 146 |
|
| 147 |
- (void) setProductType: (NSString *)object; // setter |
| 148 |
{ |
| 149 |
ASSIGN(_productType,object); |
| 150 |
} |
| 151 |
|
| 152 |
- (NSArray *) synchronizedSources |
| 153 |
{ |
| 154 |
NSMutableArray *result = [NSMutableArray array]; |
| 155 |
NSEnumerator *gen = [_fileSystemSynchronizedGroups objectEnumerator]; |
| 156 |
PBXFileSystemSynchronizedRootGroup *group = nil; |
| 157 |
|
| 158 |
while ((group = [gen nextObject]) != nil) |
| 159 |
{ |
| 160 |
NSArray *children = [group children]; |
| 161 |
NSEnumerator *cen = [children objectEnumerator]; |
| 162 |
PBXBuildFile *buildFile = nil; |
| 163 |
|
| 164 |
while ((buildFile = [cen nextObject]) != nil) |
| 165 |
{ |
| 166 |
PBXFileReference *fr = [buildFile fileRef]; |
| 167 |
NSString *name = [fr path]; |
| 168 |
|
| 169 |
// NSLog(@"path = %@", name); |
| 170 |
if ([[name pathExtension] isEqualToString: @"m"] |
| 171 |
|| [[name pathExtension] isEqualToString: @"mm"] |
| 172 |
|| [[name pathExtension] isEqualToString: @"M"] |
| 173 |
|| [[name pathExtension] isEqualToString: @"c"] |
| 174 |
|| [[name pathExtension] isEqualToString: @"cc"] |
| 175 |
|| [[name pathExtension] isEqualToString: @"C"] |
| 176 |
|| [[name pathExtension] isEqualToString: @"swift"]) |
| 177 |
{ |
| 178 |
[result addObject: buildFile]; |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
return result; |
| 184 |
} |
| 185 |
|
| 186 |
- (NSArray *) synchronizedHeaders |
| 187 |
{ |
| 188 |
NSMutableArray *result = [NSMutableArray array]; |
| 189 |
NSEnumerator *gen = [_fileSystemSynchronizedGroups objectEnumerator]; |
| 190 |
PBXFileSystemSynchronizedRootGroup *group = nil; |
| 191 |
|
| 192 |
while ((group = [gen nextObject]) != nil) |
| 193 |
{ |
| 194 |
NSArray *children = [group children]; |
| 195 |
NSEnumerator *cen = [children objectEnumerator]; |
| 196 |
PBXBuildFile *buildFile = nil; |
| 197 |
|
| 198 |
while ((buildFile = [cen nextObject]) != nil) |
| 199 |
{ |
| 200 |
PBXFileReference *fr = [buildFile fileRef]; |
| 201 |
NSString *name = [fr path]; |
| 202 |
|
| 203 |
if ([[name pathExtension] isEqualToString: @"h"]) |
| 204 |
{ |
| 205 |
[result addObject: buildFile]; |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
return result; |
| 211 |
} |
| 212 |
|
| 213 |
- (NSArray *) synchronizedResources |
| 214 |
{ |
| 215 |
NSMutableArray *result = [NSMutableArray array]; |
| 216 |
NSEnumerator *gen = [_fileSystemSynchronizedGroups objectEnumerator]; |
| 217 |
PBXFileSystemSynchronizedRootGroup *group = nil; |
| 218 |
|
| 219 |
while ((group = [gen nextObject]) != nil) |
| 220 |
{ |
| 221 |
NSArray *children = [group children]; |
| 222 |
NSEnumerator *cen = [children objectEnumerator]; |
| 223 |
PBXBuildFile *buildFile = nil; |
| 224 |
|
| 225 |
while ((buildFile = [cen nextObject]) != nil) |
| 226 |
{ |
| 227 |
PBXFileReference *fr = [buildFile fileRef]; |
| 228 |
NSString *name = [fr path]; |
| 229 |
|
| 230 |
if ([[name pathExtension] isEqualToString: @"xcassets"] |
| 231 |
|| [[name pathExtension] isEqualToString: @"xib"]) |
| 232 |
{ |
| 233 |
[result addObject: buildFile]; |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
return result; |
| 239 |
} |
| 240 |
|
| 241 |
- (BOOL) build |
| 242 |
{ |
| 243 |
GSXCBuildDatabase *db = [GSXCBuildDatabase buildDatabaseWithTarget: self]; |
| 244 |
|
| 245 |
[self setDatabase: db]; |
| 246 |
|
| 247 |
return YES; |
| 248 |
} |
| 249 |
|
| 250 |
- (BOOL) clean |
| 251 |
{ |
| 252 |
xcputs([[NSString stringWithFormat: @"Cleaning %@",self] cString]); |
| 253 |
return YES; |
| 254 |
} |
| 255 |
|
| 256 |
- (BOOL) install |
| 257 |
{ |
| 258 |
xcputs([[NSString stringWithFormat: @"Installing %@",self] cString]); |
| 259 |
return YES; |
| 260 |
} |
| 261 |
|
| 262 |
- (BOOL) generate |
| 263 |
{ |
| 264 |
return YES; |
| 265 |
} |
| 266 |
|
| 267 |
- (BOOL) link |
| 268 |
{ |
| 269 |
return YES; |
| 270 |
} |
| 271 |
|
| 272 |
@end |