Skip to content

Commit d7a2068

Browse files
author
Tim Burks
committed
Fixed problems building frameworks on Linux.
Discovered and verified on Nunja, the Nu-based web server that now can be built for both Linux and Darwin. Nunja is built as a framework on both platforms.
1 parent b46ed84 commit d7a2068

File tree

5 files changed

+98
-90
lines changed

5 files changed

+98
-90
lines changed

Nukefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ END)
4646

4747
;; includes
4848
(if (eq (uname) "Darwin")
49-
(then (set @includes " -I./include "))
50-
(else (set @includes " -I./include -I/usr/local/include")))
49+
(then (set @includes " -I ./include -I ./include/Nu "))
50+
(else (set @includes " -I ./include -I ./include/Nu -I /usr/local/include")))
5151

5252
(if (NSFileManager directoryExistsNamed:"#{@prefix}/include") (@includes appendString:" -I #{@prefix}/include"))
5353

@@ -125,7 +125,7 @@ END)
125125

126126
(if (eq (uname) "Darwin")
127127
(file "#{@framework_headers_dir}/Nu.h" => "objc/Nu.h" @framework_headers_dir is
128-
(SH "cp objc/Nu.h #{@framework_headers_dir}")))
128+
(SH "cp include/Nu/Nu.h #{@framework_headers_dir}")))
129129

130130
(task "clobber" => "clean" is
131131
(if (eq (uname) "Darwin")
@@ -185,7 +185,10 @@ END)
185185
(SH "ditto #{@framework}.framework #{@destdir}/Library/Frameworks/#{@framework}.framework"))
186186
(if (eq (uname) "Linux")
187187
;; install the dynamic library
188-
(SH "sudo cp #{@library_executable_name} #{@installprefix}/lib"))
188+
(SH "sudo cp #{@library_executable_name} #{@installprefix}/lib")
189+
;; copy the headers
190+
(SH "sudo rm -rf /usr/local/include/Nu")
191+
(SH "sudo cp -rp include/Nu /usr/local/include"))
189192
(SH "sudo mkdir -p #{@installprefix}/share")
190193
(SH "sudo rm -rf #{@installprefix}/share/nu")
191194
(SH "sudo cp -rp share/nu #{@installprefix}/share/nu")

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else # Linux
2929
LEOPARD_CFLAGS = ""
3030
end
3131

32-
@includes = FFI_INCLUDE
32+
@includes = FFI_INCLUDE + " -I ./include/Nu "
3333

3434
if SYSTEM == "Darwin"
3535
@includes += " -I #{PREFIX}/include" if File.exist? "#{PREFIX}/include"

include/Nu/Nu.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/Nu/Nu.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*!
2+
@header Nu.h
3+
The public interface for the Nu programming language.
4+
Objective-C programs can call Nu scripts by simply including this file,
5+
which is built into the Nu framework.
6+
7+
@copyright Copyright (c) 2007 Neon Design Technology, Inc.
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+
*/
21+
#import <Foundation/Foundation.h>
22+
23+
@protocol NuParsing
24+
/*! Parse a string into a list of objects that can be evaluated. */
25+
- (id) parse:(NSString *)string;
26+
/*! Evaluate a parsed code structure in the parser's context. */
27+
- (id) eval:(id) code;
28+
/*! Parse and evaluate a string containing Nu source code. */
29+
- (id) parseEval:(NSString *) string;
30+
/*! Get the value of a name or expression in the parser's context. */
31+
- (id) valueForKey:(NSString *)string;
32+
/*! Set the value of a name in the parser's context. Use this to insert object references into Nu contexts. */
33+
- (void) setValue:(id)value forKey:(NSString *)string;
34+
/*! Call this when you're finished using a parser. */
35+
- (void) close;
36+
@end
37+
38+
/*!
39+
@class Nu
40+
@abstract An Objective-C class that provides access to a Nu parser.
41+
@discussion This class provides a simple interface that allows Objective-C code to run code written in Nu.
42+
It is intended for use in Objective-C programs that include Nu as a framework.
43+
*/
44+
@interface Nu : NSObject
45+
{
46+
}
47+
48+
/*!
49+
Get a Nu parser. The parser will implement the NuParsing protocol, shown below.
50+
51+
<div style="margin-left:2em">
52+
<code>
53+
@protocol NuParsing<br/>
54+
// parse a string containing Nu expressions into a code object.<br/>
55+
&#45; (id) parse:(NSString *)string;<br/>
56+
// evaluate a code object in the parser's evaluation context.<br/>
57+
&#45; (id) eval: (id) code;<br/>
58+
// Get the value of a name or expression in the parser's context.<br/>
59+
&#45; (id) valueForKey:(NSString *)string;<br/>
60+
// Set the value of a name in the parser's context. Use this to insert object references into Nu contexts.<br/>
61+
&#45; (void) setValue:(id)value forKey:(NSString *)string;<br/>
62+
// Call this when you're finished using a parser.<br/>
63+
&#45; (void) close;<br/>
64+
@end
65+
</code>
66+
</div>
67+
*/
68+
+ (id<NuParsing>) parser;
69+
/*!
70+
Load a Nu source file from a bundle with the specified identifier.
71+
Used by bundle (aka framework) initializers.
72+
*/
73+
+ (BOOL) loadNuFile:(NSString *) fileName fromBundleWithIdentifier:(NSString *) bundleIdentifier withContext:(NSMutableDictionary *) context;
74+
@end
75+
76+
// Helpers for programmatic construction of Nu code.
77+
// Experimental. They may change or disappear in future releases.
78+
id _nunull();
79+
id _nustring(const char *string);
80+
id _nusymbol(const char *string);
81+
id _nunumberd(double d);
82+
id _nucell(id car, id cdr);
83+
id _nuregex(const char *pattern, int options);

objc/Nu.h

Lines changed: 0 additions & 83 deletions
This file was deleted.

tools/nuke

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,14 @@
458458
(if (eq (uname) "Darwin")
459459
(then (set archflags "-arch #{architecture}"))
460460
(else (set archflags "")))
461+
(if (eq (uname) "Darwin")
462+
(then (set installnameflag "-install_name #{framework_executable}"))
463+
(else (set installnameflag "")))
464+
(if (eq (uname) "Darwin")
465+
(then (set dylibflag "-dynamiclib"))
466+
(else (set dylibflag "-shared")))
461467
(file framework_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
462-
(set command "#{@cc} #{((@c_objects objectForKey:architecture) join)} #{((@m_objects objectForKey:architecture) join)} #{archflags} #{@cflags} #{@ldflags} #{@initflags} -install_name #{@framework_executable_name} -dynamiclib -o '#{(target name)}'")
468+
(set command "#{@cc} #{((@c_objects objectForKey:architecture) join)} #{((@m_objects objectForKey:architecture) join)} #{archflags} #{@cflags} #{@ldflags} #{@initflags} #{installnameflag} #{dylibflag} -o '#{(target name)}'")
463469
(SH command))))
464470

465471
;; framework fat executable

0 commit comments

Comments
 (0)