public
Description: The Nu programming language.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nu.git
Search Repo:
New ifDarwin macro simplifies Nukefiles, minor text edits.
timburks (author)
Sun Mar 16 09:56:43 -0700 2008
commit  3aa086ba65e7ee9ba3a0e9687eb408c78732b388
tree    a66fa02c070a2d4275f36b4a82214bf931846bf1
parent  a300ca791bd7fba9c64dbc7179085ce02cded79f
...
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
...
82
83
84
85
 
86
87
88
89
90
91
92
93
94
95
 
 
96
97
 
 
 
 
98
99
100
...
117
118
119
120
 
121
122
123
124
125
126
 
127
128
129
130
131
 
132
133
134
...
140
141
142
143
 
144
145
146
...
149
150
151
152
 
153
154
155
...
179
180
181
182
 
183
184
185
...
187
188
189
190
 
191
192
193
194
195
 
196
197
198
...
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
...
82
83
84
 
85
86
87
88
89
90
 
 
 
 
 
91
92
93
 
94
95
96
97
98
99
100
...
117
118
119
 
120
121
122
123
124
125
 
126
127
128
129
130
 
131
132
133
134
...
140
141
142
 
143
144
145
146
...
149
150
151
 
152
153
154
155
...
179
180
181
 
182
183
184
185
...
187
188
189
 
190
191
192
193
194
 
195
196
197
198
0
@@ -34,38 +34,38 @@ END)
0
 (set @nib_files '("share/nu/resources/English.lproj/MainMenu.nib"))
0
 
0
 ;; libraries
0
-(if (eq (uname) "Darwin")
0
- (then (set @frameworks '("Cocoa"))
0
- (set @libs '("edit" "ffi" ))
0
- (set @lib_dirs (NSMutableArray arrayWithObject:"/usr/lib")))
0
- (else (set @frameworks nil)
0
- (set @libs (list "readline" "ffi" "m" ))
0
- (set @lib_dirs (NSMutableArray arrayWithList:(list "../lib")))))
0
+(ifDarwin
0
+ (then (set @frameworks '("Cocoa"))
0
+ (set @libs '("edit" "ffi" ))
0
+ (set @lib_dirs (NSMutableArray arrayWithObject:"/usr/lib")))
0
+ (else (set @frameworks nil)
0
+ (set @libs (list "readline" "ffi" "m" ))
0
+ (set @lib_dirs (NSMutableArray arrayWithList:(list "../lib")))))
0
 
0
 (if (NSFileManager directoryExistsNamed:"#{@prefix}/lib") (@lib_dirs addObject:"#{@prefix}/lib"))
0
 
0
 ;; includes
0
-(if (eq (uname) "Darwin")
0
- (then (set @includes " -I ./include -I ./include/Nu "))
0
- (else (set @includes " -I ./include -I ./include/Nu -I /usr/local/include")))
0
+(ifDarwin
0
+ (then (set @includes " -I ./include -I ./include/Nu "))
0
+ (else (set @includes " -I ./include -I ./include/Nu -I /usr/local/include")))
0
 
0
 (if (NSFileManager directoryExistsNamed:"#{@prefix}/include") (@includes appendString:" -I #{@prefix}/include"))
0
 
0
-(if (eq (uname) "Darwin")
0
- (then (if (NSFileManager fileExistsNamed:"/usr/lib/libffi.dylib")
0
- (then ;; Use the libffi that ships with OS X.
0
- (@includes appendString:" -I /usr/include"))
0
- (else ;; Use the libffi that is distributed with Nu.
0
- (@includes appendString:" -I ./libffi/include")
0
- (@lib_dirs addObject:"./libffi"))))
0
- (else ;; Use the libffi that ships with Linux
0
- (@includes appendString:" -I /usr/include")))
0
+(ifDarwin
0
+ (then (if (NSFileManager fileExistsNamed:"/usr/lib/libffi.dylib")
0
+ (then ;; Use the libffi that ships with OS X.
0
+ (@includes appendString:" -I /usr/include"))
0
+ (else ;; Use the libffi that is distributed with Nu.
0
+ (@includes appendString:" -I ./libffi/include")
0
+ (@lib_dirs addObject:"./libffi"))))
0
+ (else ;; Use the libffi that ships with Linux
0
+ (@includes appendString:" -I /usr/include")))
0
 
0
 ;; framework description
0
 (set @framework "Nu")
0
 (set @framework_identifier "nu.programming.framework")
0
 (set @framework_icon_file "nu.icns")
0
-(if (eq (uname) "Darwin") (then (set @framework_initializer "NuInit")))
0
+(ifDarwin (then (set @framework_initializer "NuInit")))
0
 (set @framework_creator_code "????")
0
 
0
 ;; for Linux, we build Nu as a dynamic library
0
@@ -82,19 +82,19 @@ END)
0
             (" -isysroot /Developer/SDKs/MacOSX10.4u.sdk"))
0
            (else "")))
0
 
0
-(if (eq (uname) "Darwin")
0
+(ifDarwin
0
     (then (set @cflags "-Wall -g -DDARWIN -DMACOSX #{@sdk} #{@leopard} -std=gnu99")
0
           (set @mflags "-fobjc-exceptions")) ;; Want to try Apple's new GC? Add this: "-fobjc-gc"
0
     (else (set @cflags "-Wall -DLINUX -g -std=gnu99 ")
0
           (set @mflags "-fobjc-exceptions -fconstant-string-class=NSConstantString")))
0
 
0
-(if (eq (uname) "Darwin")
0
- ;; use this to build a universal binary
0
- (then (set @arch '("ppc" "i386")))
0
- ;; or this to just build for your current platform
0
- (else (set @arch '("i386"))))
0
+(ifDarwin
0
+ (then (set @arch '("ppc" "i386")))) ;; build a universal binary
0
 
0
-(if (eq (uname) "Darwin")
0
+;; or set this to just build for your chosen platform
0
+;; (set @arch '("i386"))
0
+
0
+(ifDarwin
0
     (then (set @ldflags
0
                ((list
0
                      (cond ;; statically link in pcre since most people won't have it..
0
@@ -117,18 +117,18 @@ END)
0
 ;; Setup the tasks for compilation and framework-building.
0
 ;; These are defined in the nuke application source file.
0
 (compilation-tasks)
0
-(if (eq (uname) "Darwin")
0
+(ifDarwin
0
     (then (framework-tasks))
0
     (else (dylib-tasks)))
0
 
0
 (task "framework" => "#{@framework_headers_dir}/Nu.h")
0
 
0
-(if (eq (uname) "Darwin")
0
+(ifDarwin
0
     (file "#{@framework_headers_dir}/Nu.h" => "objc/Nu.h" @framework_headers_dir is
0
           (SH "cp include/Nu/Nu.h #{@framework_headers_dir}")))
0
 
0
 (task "clobber" => "clean" is
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
           (SH "rm -rf nush #{@framework_dir} doc"))
0
       ((filelist "^examples/[^/]*$") each:
0
        (do (example-dir)
0
@@ -140,7 +140,7 @@ END)
0
        (do (architecture)
0
            (set nush_thin_binary "build/#{architecture}/nush")
0
            (nush_thin_binaries addObject:nush_thin_binary)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                (then
0
                     (file nush_thin_binary => "framework" "build/#{architecture}/main.o" is
0
                           (SH "#{@cc} #{@cflags} #{@mflags} main/main.m -arch #{architecture} -F. -framework Nu #{@ldflags} -o #{(target name)}")))
0
@@ -149,7 +149,7 @@ END)
0
                           (SH "#{@cc} #{@cflags} #{@mflags} main/main.m #{@library_executable_name} #{@ldflags} -o #{(target name)}"))))))
0
 
0
 (file "nush" => "framework" nush_thin_binaries is
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
           (then (SH "lipo -create #{(nush_thin_binaries join)} -output #{(target name)}"))
0
           (else (SH "cp '#{(nush_thin_binaries objectAtIndex:0)}' '#{(target name)}'"))))
0
 
0
@@ -179,7 +179,7 @@ END)
0
         (do (program)
0
             (SH "sudo cp tools/#{program} #{@installprefix}/bin")))
0
       (SH "sudo cp nush #{@installprefix}/bin")
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
           ;; install the framework
0
           (SH "sudo rm -rf #{@destdir}/Library/Frameworks/#{@framework}.framework")
0
           (SH "ditto #{@framework}.framework #{@destdir}/Library/Frameworks/#{@framework}.framework"))
0
@@ -187,12 +187,12 @@ END)
0
           ;; install the dynamic library
0
           (SH "sudo cp #{@library_executable_name} #{@installprefix}/lib")
0
           ;; copy the headers
0
- (SH "sudo rm -rf /usr/local/include/Nu")
0
+ (SH "sudo rm -rf /usr/local/include/Nu")
0
           (SH "sudo cp -rp include/Nu /usr/local/include"))
0
       (SH "sudo mkdir -p #{@installprefix}/share")
0
       (SH "sudo rm -rf #{@installprefix}/share/nu")
0
       (SH "sudo cp -rp share/nu #{@installprefix}/share/nu")
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
           (SH "sudo ditto examples #{@installprefix}/share/nu/examples")))
0
 
0
 ;; Build a disk image for distributing the framework.
0
...
26
27
28
29
 
30
31
32
...
26
27
28
 
29
30
31
32
0
@@ -26,7 +26,7 @@ Ruby, while adding the syntactic simplicity and flexibility of Lisp.
0
 LEGAL
0
 
0
 Nu is copyrighted open-source software that is released under the Apache
0
-Public License, version 2.0. For details on the license, see the LICENSE file.
0
+License, version 2.0. For details on the license, see the LICENSE file.
0
 In its use to name a programming language, "Nu" is a trademark of Neon Design
0
 Technology, Inc.
0
 
...
477
478
479
480
 
481
482
483
...
477
478
479
 
480
481
482
483
0
@@ -477,7 +477,7 @@ END))
0
 </div>
0
 <div style="float:left">
0
 <h1><a href="/">Programming Nu</a></h1>
0
-<h3>Reduce, Reuse, and Recycle <em>code</em>.</h3>
0
+<h3>Website for the Nu programming language.</h3>
0
 </div>END) (else "")))
0
 
0
 ;;;;;;;;;;;;; Footer Template ;;;;;;;;;;;;;;;;;
...
18
19
20
21
22
23
24
 
25
26
27
...
29
30
31
 
 
 
32
33
34
...
223
224
225
226
227
 
 
 
 
228
229
230
...
240
241
242
243
 
244
245
246
...
256
257
258
259
 
260
261
262
...
328
329
330
331
 
332
333
334
...
336
337
338
339
 
340
341
342
...
450
451
452
453
 
454
455
456
457
458
459
460
 
461
462
463
 
464
465
466
 
467
468
469
...
472
473
474
475
 
476
477
478
...
559
560
561
562
 
563
564
565
...
635
636
637
638
 
639
640
641
...
643
644
645
646
 
647
648
649
 
650
651
652
...
656
657
658
659
 
660
661
662
...
18
19
20
 
 
21
22
23
24
25
26
...
28
29
30
31
32
33
34
35
36
...
225
226
227
 
 
228
229
230
231
232
233
234
...
244
245
246
 
247
248
249
250
...
260
261
262
 
263
264
265
266
...
332
333
334
 
335
336
337
338
...
340
341
342
 
343
344
345
346
...
454
455
456
 
457
458
459
460
461
462
463
 
464
465
466
 
467
468
469
 
470
471
472
473
...
476
477
478
 
479
480
481
482
...
563
564
565
 
566
567
568
569
...
639
640
641
 
642
643
644
645
...
647
648
649
 
650
651
652
 
653
654
655
656
...
660
661
662
 
663
664
665
666
0
@@ -18,10 +18,9 @@
0
 # limitations under the License.
0
 
0
 ;; basic declarations that allow nuke to run in mininush
0
-(global NO 0)
0
-(global YES 1)
0
 (set exit (NuBridgedFunction functionWithName:"exit" signature:"vi"))
0
 
0
+;; system-level helpers
0
 (function SH (command)
0
      (puts "nuke: #{command}")
0
      (set result (system command))
0
@@ -29,6 +28,9 @@
0
          (puts "nuke: terminating on command error (return code #{result})")
0
          (exit result)))
0
 
0
+(macro ifDarwin (eval (append '(if (eq (uname) "Darwin")) margs)))
0
+(macro ifLinux (eval (append '(if (eq (uname) "Linux")) margs)))
0
+
0
 (class NSString
0
      ;; Change the extension at the end of a file name to a new specified value.
0
      (imethod (id) stringByReplacingPathExtensionWith:(id) newExtension is
0
@@ -223,8 +225,10 @@
0
      (unless @cflags (set @cflags "-g"))
0
      (unless @mflags (set @mflags "-fobjc-exceptions"))
0
      (unless @includes (set @includes ""))
0
- (unless (and @arch (@arch length))
0
- (set @arch (list (NSString stringWithShellCommand:"arch"))))
0
+ (ifDarwin
0
+ (then (unless (and @arch (@arch length))
0
+ (set @arch (list (NSString stringWithShellCommand:"arch")))))
0
+ (else (set @arch (list "x86-linux"))))
0
      (@arch each: (do (architecture) (system "mkdir -p build/#{architecture}")))
0
      
0
      (unless @ldflags ;; not for compilation, but common across all builds
0
@@ -240,7 +244,7 @@
0
                          (set objectName "build/#{architecture}/")
0
                          (objectName appendString:((sourceName fileName) stringByReplacingPathExtensionWith:"o"))
0
                          ((@c_objects objectForKey:architecture) addObject: objectName)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                              (then (set archflags "-arch #{architecture}"))
0
                              (else (set archflags "")))
0
                          (file objectName => sourceName is
0
@@ -256,7 +260,7 @@
0
                          (set objectName "build/#{architecture}/")
0
                          (objectName appendString:((sourceName fileName) stringByReplacingPathExtensionWith:"o"))
0
                          ((@m_objects objectForKey:architecture) addObject: objectName)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                              (then (set archflags "-arch #{architecture}"))
0
                              (else (set archflags "")))
0
                          (file objectName => sourceName is
0
@@ -328,7 +332,7 @@
0
                      (do (architecture)
0
                          (set application_executable "build/#{architecture}/application-#{@application}")
0
                          (@application_executables addObject:application_executable)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                              (then (set archflags "-arch #{architecture}"))
0
                              (else (set archflags "")))
0
                          (file application_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
0
@@ -336,7 +340,7 @@
0
                                (SH command))))
0
               ;; application fat executable
0
               (file @application_executable_name => @application_executable_dir @application_executables is
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                         (then (set command "lipo -create #{(@application_executables join)} -output '#{@application_executable_name}'"))
0
                         (else (set command "cp '#{(@application_executables objectAtIndex:0)}' '#{@application_executable_name}'")))
0
                     (SH command)))
0
@@ -450,20 +454,20 @@
0
                          (else "")))
0
      
0
      (set @framework_executable_name "#{@framework_contents_dir}/#{@framework}")
0
-
0
+
0
      ;; framework architecture-specific executable
0
      (set @framework_executables (NSMutableArray array))
0
      (@arch each:
0
             (do (architecture)
0
                 (set framework_executable "build/#{architecture}/framework-#{@framework}")
0
                 (@framework_executables addObject:framework_executable)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set archflags "-arch #{architecture}"))
0
                     (else (set archflags "")))
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set installnameflag "-install_name #{@framework_executable_name}"))
0
                     (else (set installnameflag "")))
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set dylibflag "-dynamiclib"))
0
                     (else (set dylibflag "-shared")))
0
                 (file framework_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
0
@@ -472,7 +476,7 @@
0
      
0
      ;; framework fat executable
0
      (file @framework_executable_name => @framework_contents_dir @framework_executables is
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                (then (set command "lipo -create #{(@framework_executables join)} -output '#{@framework_executable_name}'"))
0
                (else (set command "cp '#{(@framework_executables objectAtIndex:0)}' '#{@framework_executable_name}'")))
0
            (SH command))
0
@@ -559,7 +563,7 @@
0
             (do (architecture)
0
                 (set bundle_executable "build/#{architecture}/bundle-#{@bundle}")
0
                 (@bundle_executables addObject:bundle_executable)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set archflags "-arch #{architecture}"))
0
                     (else (set archflags "")))
0
                 (file bundle_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
0
@@ -635,7 +639,7 @@
0
 (macro dylib-tasks
0
      (unless (and @arch (@arch length))
0
              (set @arch (list (NSString stringWithShellCommand:"arch"))))
0
- (set libext (if (eq (uname) "Darwin") (then "dylib") (else "so")))
0
+ (set libext (ifDarwin (then "dylib") (else "so")))
0
      
0
      ;; library architecture-specific executable
0
      (set @library_executables (NSMutableArray array))
0
@@ -643,10 +647,10 @@
0
             (do (architecture)
0
                 (set library_executable "build/#{architecture}/#{@dylib}.#{libext}")
0
                 (@library_executables addObject:library_executable)
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set dylibflag "-dynamiclib"))
0
                     (else (set dylibflag "-shared")))
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                     (then (set archflags "-arch #{architecture}"))
0
                     (else (set archflags "")))
0
                 (file library_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
0
@@ -656,7 +660,7 @@
0
      ;; fat dynamic library
0
      (set @library_executable_name "#{@dylib}.#{libext}")
0
      (file @library_executable_name => @library_executables is
0
- (if (eq (uname) "Darwin")
0
+ (ifDarwin
0
                (then (set command "lipo -create #{(@library_executables join)} -output '#{@library_executable_name}'"))
0
                (else (set command "cp '#{(@library_executables objectAtIndex:0)}' '#{@library_executable_name}'")))
0
            (SH command))

Comments

    No one has commented yet.