-
Notifications
You must be signed in to change notification settings - Fork 1
/
NFOXComponentStyle.m
146 lines (121 loc) · 3.91 KB
/
NFOXComponentStyle.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
Copyright (C) 2000 Free Software Foundation, Inc.
Written by: Karl Kraft <karl@nfox.com>
Date: Apr 00
This file is part of nfmake - a utility for building GNUstep programs
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "NFOXComponentStyle.h"
#import <unistd.h>
#import "NSFileManager_CompareFiles.h"
@implementation NFOXComponentStyle
+(BOOL)buildsType:(NSString *)aType
{
if ([aType isEqualToString:@"NFOXComponent"])
{
return YES;
}
return NO;
}
- (NSString *)componentName
{
NSString *extension = [self buildExtension];
if (extension)
{
return [NSString stringWithFormat: @"%@.%@",
[self projectName], extension];
}
else
{
return [NSString stringWithFormat: @"%@.build",
[self projectName]];
}
}
// where the component is assembled
-(NSString *)componentPath
{
return [[self buildComponentDirectory] stringByAppendingPathComponent:
[self componentName]];
}
-(void)linkFinalProduct
{
NSTask *aTask = [[[NSTask alloc] init] autorelease];
NSMutableArray *arguments= [NSMutableArray array];
NSString *infoPath;
if ([[NSFileManager defaultManager] file:[self executablePath] isOlderThanFiles:[self linkables]]==NO) {
// NSLog(@"up to date\n");
return;
}
NSLog(@"Linking %@\n", [self executablePath]);
//[arguments addObject:@"-v"];
[arguments addObjectsFromArray:[self cFlagArray]];
[arguments addObject:@"-shared"];
[arguments addObject:@"-o"];
[arguments addObject:[self executablePath]];
[arguments addObjectsFromArray:[self linkables]];
[arguments addObjectsFromArray:[self libraryDirectoryFlags]];
// [arguments addObjectsFromArray:[self frameworkLinkFlags]];
[aTask setLaunchPath:@"gcc"];
[aTask setArguments:arguments];
//NSLog(@"%@",arguments);
[aTask launch];
//sleep(30);
[aTask waitUntilExit];
if ([aTask terminationStatus]!=0) {
fprintf(stderr,"Abort\n");
exit([aTask terminationStatus]);
} else {
}
infoPath = [[self componentPath] stringByAppendingPathComponent:@"Info.plist"];
{
NSMutableDictionary *theDict=[NSMutableDictionary dictionary];
[theDict setObject:[self projectName] forKey:@"NSExecutable"];
[theDict setObject:[self principalClassName] forKey:@"NSPrincipalClass"];
[theDict writeToFile:infoPath atomically:YES];
}
}
-(void)installBundle
{
NSFileManager *theMan=[NSFileManager defaultManager];
NSString *installDirectory=[self installDirectory];
if (!installDirectory)
{
//NSLog(@"no INSTALLDIR set using /usr/GNUstep/Local/Components");
installDirectory = @"/usr/GNUstep/Local/Components";
}
// NSLog(@"Installing to %@\n", installDirectory);
[theMan installFromPath: [self componentPath]
toDir: installDirectory
operationDelegate: [self copyDelegate]];
}
-(void)makeTarget: (NSString *)targetName;
{
if ([targetName isEqualToString: @"default"])
{
[self buildSubprojects: targetName];
[self buildClasses];
[self installHeaders];
[self installResources];
[self linkFinalProduct];
}
else if ([targetName isEqualToString: @"install"])
{
[self makeTarget: @"default"];
[self installBundle];
}
else
{
[super makeTarget: targetName];
}
}
@end