| 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 "PBXCommon.h" |
| 26 |
#import "XCConfigurationList.h" |
| 27 |
#import "XCBuildConfiguration.h" |
| 28 |
|
| 29 |
@implementation XCConfigurationList |
| 30 |
|
| 31 |
- (instancetype) initWithConfigurations: (NSMutableArray *)configs |
| 32 |
{ |
| 33 |
self = [super init]; |
| 34 |
if (self != nil) |
| 35 |
{ |
| 36 |
[self setBuildConfigurations: configs]; |
| 37 |
} |
| 38 |
return self; |
| 39 |
} |
| 40 |
|
| 41 |
/* |
| 42 |
- (instancetype) init |
| 43 |
{ |
| 44 |
return [self initWithConfigurations: [NSMutableArray array]]; |
| 45 |
} |
| 46 |
*/ |
| 47 |
|
| 48 |
// Methods.... |
| 49 |
- (NSString *) defaultConfigurationIsVisible // getter |
| 50 |
{ |
| 51 |
return defaultConfigurationIsVisible; |
| 52 |
} |
| 53 |
|
| 54 |
- (void) setDefaultConfigurationIsVisible: (NSString *)object; // setter |
| 55 |
{ |
| 56 |
ASSIGN(defaultConfigurationIsVisible,object); |
| 57 |
} |
| 58 |
|
| 59 |
- (NSMutableArray *) buildConfigurations // getter |
| 60 |
{ |
| 61 |
return buildConfigurations; |
| 62 |
} |
| 63 |
|
| 64 |
- (void) setBuildConfigurations: (NSMutableArray *)object; // setter |
| 65 |
{ |
| 66 |
ASSIGN(buildConfigurations,object); |
| 67 |
} |
| 68 |
|
| 69 |
- (NSString *) defaultConfigurationName // getter |
| 70 |
{ |
| 71 |
return defaultConfigurationName; |
| 72 |
} |
| 73 |
|
| 74 |
- (void) setDefaultConfigurationName: (NSString *)object; // setter |
| 75 |
{ |
| 76 |
ASSIGN(defaultConfigurationName,object); |
| 77 |
} |
| 78 |
|
| 79 |
- (XCBuildConfiguration *) defaultConfiguration |
| 80 |
{ |
| 81 |
NSEnumerator *en = [buildConfigurations objectEnumerator]; |
| 82 |
NSString *defaultConfig = (defaultConfigurationName == nil)? |
| 83 |
@"Release":defaultConfigurationName; |
| 84 |
XCBuildConfiguration *config = nil; |
| 85 |
|
| 86 |
NSDebugLog(@"Number of build configurations = %ld\n%@", |
| 87 |
[buildConfigurations count], buildConfigurations); |
| 88 |
|
| 89 |
while((config = [en nextObject]) != nil) |
| 90 |
{ |
| 91 |
if([[config name] |
| 92 |
isEqualToString: |
| 93 |
defaultConfig]) |
| 94 |
{ |
| 95 |
break; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
return config; |
| 100 |
} |
| 101 |
|
| 102 |
- (void) applyDefaultConfiguration |
| 103 |
{ |
| 104 |
[[self defaultConfiguration] apply]; |
| 105 |
} |
| 106 |
|
| 107 |
- (NSString *) description |
| 108 |
{ |
| 109 |
return [NSString stringWithFormat: @"%@ -- %@", [super description], |
| 110 |
buildConfigurations]; |
| 111 |
} |
| 112 |
@end |