Skip to content
Browse files

New ifDarwin macro simplifies Nukefiles, minor text edits.

  • Loading branch information...
1 parent a300ca7 commit 3aa086ba65e7ee9ba3a0e9687eb408c78732b388 Tim Burks committed
Showing with 59 additions and 55 deletions.
  1. +35 −35 Nukefile
  2. +1 −1 README
  3. +1 −1 nu/doc.nu
  4. +22 −18 tools/nuke
View
70 Nukefile
@@ -34,38 +34,38 @@ END)
(set @nib_files '("share/nu/resources/English.lproj/MainMenu.nib"))
;; libraries
-(if (eq (uname) "Darwin")
- (then (set @frameworks '("Cocoa"))
- (set @libs '("edit" "ffi" ))
- (set @lib_dirs (NSMutableArray arrayWithObject:"/usr/lib")))
- (else (set @frameworks nil)
- (set @libs (list "readline" "ffi" "m" ))
- (set @lib_dirs (NSMutableArray arrayWithList:(list "../lib")))))
+(ifDarwin
+ (then (set @frameworks '("Cocoa"))
+ (set @libs '("edit" "ffi" ))
+ (set @lib_dirs (NSMutableArray arrayWithObject:"/usr/lib")))
+ (else (set @frameworks nil)
+ (set @libs (list "readline" "ffi" "m" ))
+ (set @lib_dirs (NSMutableArray arrayWithList:(list "../lib")))))
(if (NSFileManager directoryExistsNamed:"#{@prefix}/lib") (@lib_dirs addObject:"#{@prefix}/lib"))
;; includes
-(if (eq (uname) "Darwin")
- (then (set @includes " -I ./include -I ./include/Nu "))
- (else (set @includes " -I ./include -I ./include/Nu -I /usr/local/include")))
+(ifDarwin
+ (then (set @includes " -I ./include -I ./include/Nu "))
+ (else (set @includes " -I ./include -I ./include/Nu -I /usr/local/include")))
(if (NSFileManager directoryExistsNamed:"#{@prefix}/include") (@includes appendString:" -I #{@prefix}/include"))
-(if (eq (uname) "Darwin")
- (then (if (NSFileManager fileExistsNamed:"/usr/lib/libffi.dylib")
- (then ;; Use the libffi that ships with OS X.
- (@includes appendString:" -I /usr/include"))
- (else ;; Use the libffi that is distributed with Nu.
- (@includes appendString:" -I ./libffi/include")
- (@lib_dirs addObject:"./libffi"))))
- (else ;; Use the libffi that ships with Linux
- (@includes appendString:" -I /usr/include")))
+(ifDarwin
+ (then (if (NSFileManager fileExistsNamed:"/usr/lib/libffi.dylib")
+ (then ;; Use the libffi that ships with OS X.
+ (@includes appendString:" -I /usr/include"))
+ (else ;; Use the libffi that is distributed with Nu.
+ (@includes appendString:" -I ./libffi/include")
+ (@lib_dirs addObject:"./libffi"))))
+ (else ;; Use the libffi that ships with Linux
+ (@includes appendString:" -I /usr/include")))
;; framework description
(set @framework "Nu")
(set @framework_identifier "nu.programming.framework")
(set @framework_icon_file "nu.icns")
-(if (eq (uname) "Darwin") (then (set @framework_initializer "NuInit")))
+(ifDarwin (then (set @framework_initializer "NuInit")))
(set @framework_creator_code "????")
;; for Linux, we build Nu as a dynamic library
@@ -82,19 +82,19 @@ END)
(" -isysroot /Developer/SDKs/MacOSX10.4u.sdk"))
(else "")))
-(if (eq (uname) "Darwin")
+(ifDarwin
(then (set @cflags "-Wall -g -DDARWIN -DMACOSX #{@sdk} #{@leopard} -std=gnu99")
(set @mflags "-fobjc-exceptions")) ;; Want to try Apple's new GC? Add this: "-fobjc-gc"
(else (set @cflags "-Wall -DLINUX -g -std=gnu99 ")
(set @mflags "-fobjc-exceptions -fconstant-string-class=NSConstantString")))
-(if (eq (uname) "Darwin")
- ;; use this to build a universal binary
- (then (set @arch '("ppc" "i386")))
- ;; or this to just build for your current platform
- (else (set @arch '("i386"))))
+(ifDarwin
+ (then (set @arch '("ppc" "i386")))) ;; build a universal binary
-(if (eq (uname) "Darwin")
+;; or set this to just build for your chosen platform
+;; (set @arch '("i386"))
+
+(ifDarwin
(then (set @ldflags
((list
(cond ;; statically link in pcre since most people won't have it..
@@ -117,18 +117,18 @@ END)
;; Setup the tasks for compilation and framework-building.
;; These are defined in the nuke application source file.
(compilation-tasks)
-(if (eq (uname) "Darwin")
+(ifDarwin
(then (framework-tasks))
(else (dylib-tasks)))
(task "framework" => "#{@framework_headers_dir}/Nu.h")
-(if (eq (uname) "Darwin")
+(ifDarwin
(file "#{@framework_headers_dir}/Nu.h" => "objc/Nu.h" @framework_headers_dir is
(SH "cp include/Nu/Nu.h #{@framework_headers_dir}")))
(task "clobber" => "clean" is
- (if (eq (uname) "Darwin")
+ (ifDarwin
(SH "rm -rf nush #{@framework_dir} doc"))
((filelist "^examples/[^/]*$") each:
(do (example-dir)
@@ -140,7 +140,7 @@ END)
(do (architecture)
(set nush_thin_binary "build/#{architecture}/nush")
(nush_thin_binaries addObject:nush_thin_binary)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then
(file nush_thin_binary => "framework" "build/#{architecture}/main.o" is
(SH "#{@cc} #{@cflags} #{@mflags} main/main.m -arch #{architecture} -F. -framework Nu #{@ldflags} -o #{(target name)}")))
@@ -149,7 +149,7 @@ END)
(SH "#{@cc} #{@cflags} #{@mflags} main/main.m #{@library_executable_name} #{@ldflags} -o #{(target name)}"))))))
(file "nush" => "framework" nush_thin_binaries is
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (SH "lipo -create #{(nush_thin_binaries join)} -output #{(target name)}"))
(else (SH "cp '#{(nush_thin_binaries objectAtIndex:0)}' '#{(target name)}'"))))
@@ -179,7 +179,7 @@ END)
(do (program)
(SH "sudo cp tools/#{program} #{@installprefix}/bin")))
(SH "sudo cp nush #{@installprefix}/bin")
- (if (eq (uname) "Darwin")
+ (ifDarwin
;; install the framework
(SH "sudo rm -rf #{@destdir}/Library/Frameworks/#{@framework}.framework")
(SH "ditto #{@framework}.framework #{@destdir}/Library/Frameworks/#{@framework}.framework"))
@@ -187,12 +187,12 @@ END)
;; install the dynamic library
(SH "sudo cp #{@library_executable_name} #{@installprefix}/lib")
;; copy the headers
- (SH "sudo rm -rf /usr/local/include/Nu")
+ (SH "sudo rm -rf /usr/local/include/Nu")
(SH "sudo cp -rp include/Nu /usr/local/include"))
(SH "sudo mkdir -p #{@installprefix}/share")
(SH "sudo rm -rf #{@installprefix}/share/nu")
(SH "sudo cp -rp share/nu #{@installprefix}/share/nu")
- (if (eq (uname) "Darwin")
+ (ifDarwin
(SH "sudo ditto examples #{@installprefix}/share/nu/examples")))
;; Build a disk image for distributing the framework.
View
2 README
@@ -26,7 +26,7 @@ Ruby, while adding the syntactic simplicity and flexibility of Lisp.
LEGAL
Nu is copyrighted open-source software that is released under the Apache
-Public License, version 2.0. For details on the license, see the LICENSE file.
+License, version 2.0. For details on the license, see the LICENSE file.
In its use to name a programming language, "Nu" is a trademark of Neon Design
Technology, Inc.
View
2 nu/doc.nu
@@ -477,7 +477,7 @@ END))
</div>
<div style="float:left">
<h1><a href="/">Programming Nu</a></h1>
-<h3>Reduce, Reuse, and Recycle <em>code</em>.</h3>
+<h3>Website for the Nu programming language.</h3>
</div>END) (else "")))
;;;;;;;;;;;;; Footer Template ;;;;;;;;;;;;;;;;;
View
40 tools/nuke
@@ -18,10 +18,9 @@
# limitations under the License.
;; basic declarations that allow nuke to run in mininush
-(global NO 0)
-(global YES 1)
(set exit (NuBridgedFunction functionWithName:"exit" signature:"vi"))
+;; system-level helpers
(function SH (command)
(puts "nuke: #{command}")
(set result (system command))
@@ -29,6 +28,9 @@
(puts "nuke: terminating on command error (return code #{result})")
(exit result)))
+(macro ifDarwin (eval (append '(if (eq (uname) "Darwin")) margs)))
+(macro ifLinux (eval (append '(if (eq (uname) "Linux")) margs)))
+
(class NSString
;; Change the extension at the end of a file name to a new specified value.
(imethod (id) stringByReplacingPathExtensionWith:(id) newExtension is
@@ -223,8 +225,10 @@
(unless @cflags (set @cflags "-g"))
(unless @mflags (set @mflags "-fobjc-exceptions"))
(unless @includes (set @includes ""))
- (unless (and @arch (@arch length))
- (set @arch (list (NSString stringWithShellCommand:"arch"))))
+ (ifDarwin
+ (then (unless (and @arch (@arch length))
+ (set @arch (list (NSString stringWithShellCommand:"arch")))))
+ (else (set @arch (list "x86-linux"))))
(@arch each: (do (architecture) (system "mkdir -p build/#{architecture}")))
(unless @ldflags ;; not for compilation, but common across all builds
@@ -240,7 +244,7 @@
(set objectName "build/#{architecture}/")
(objectName appendString:((sourceName fileName) stringByReplacingPathExtensionWith:"o"))
((@c_objects objectForKey:architecture) addObject: objectName)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
(file objectName => sourceName is
@@ -256,7 +260,7 @@
(set objectName "build/#{architecture}/")
(objectName appendString:((sourceName fileName) stringByReplacingPathExtensionWith:"o"))
((@m_objects objectForKey:architecture) addObject: objectName)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
(file objectName => sourceName is
@@ -328,7 +332,7 @@
(do (architecture)
(set application_executable "build/#{architecture}/application-#{@application}")
(@application_executables addObject:application_executable)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
(file application_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
@@ -336,7 +340,7 @@
(SH command))))
;; application fat executable
(file @application_executable_name => @application_executable_dir @application_executables is
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set command "lipo -create #{(@application_executables join)} -output '#{@application_executable_name}'"))
(else (set command "cp '#{(@application_executables objectAtIndex:0)}' '#{@application_executable_name}'")))
(SH command)))
@@ -450,20 +454,20 @@
(else "")))
(set @framework_executable_name "#{@framework_contents_dir}/#{@framework}")
-
+
;; framework architecture-specific executable
(set @framework_executables (NSMutableArray array))
(@arch each:
(do (architecture)
(set framework_executable "build/#{architecture}/framework-#{@framework}")
(@framework_executables addObject:framework_executable)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set installnameflag "-install_name #{@framework_executable_name}"))
(else (set installnameflag "")))
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set dylibflag "-dynamiclib"))
(else (set dylibflag "-shared")))
(file framework_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
@@ -472,7 +476,7 @@
;; framework fat executable
(file @framework_executable_name => @framework_contents_dir @framework_executables is
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set command "lipo -create #{(@framework_executables join)} -output '#{@framework_executable_name}'"))
(else (set command "cp '#{(@framework_executables objectAtIndex:0)}' '#{@framework_executable_name}'")))
(SH command))
@@ -559,7 +563,7 @@
(do (architecture)
(set bundle_executable "build/#{architecture}/bundle-#{@bundle}")
(@bundle_executables addObject:bundle_executable)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
(file bundle_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
@@ -635,7 +639,7 @@
(macro dylib-tasks
(unless (and @arch (@arch length))
(set @arch (list (NSString stringWithShellCommand:"arch"))))
- (set libext (if (eq (uname) "Darwin") (then "dylib") (else "so")))
+ (set libext (ifDarwin (then "dylib") (else "so")))
;; library architecture-specific executable
(set @library_executables (NSMutableArray array))
@@ -643,10 +647,10 @@
(do (architecture)
(set library_executable "build/#{architecture}/#{@dylib}.#{libext}")
(@library_executables addObject:library_executable)
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set dylibflag "-dynamiclib"))
(else (set dylibflag "-shared")))
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set archflags "-arch #{architecture}"))
(else (set archflags "")))
(file library_executable => (@c_objects objectForKey:architecture) (@m_objects objectForKey:architecture) is
@@ -656,7 +660,7 @@
;; fat dynamic library
(set @library_executable_name "#{@dylib}.#{libext}")
(file @library_executable_name => @library_executables is
- (if (eq (uname) "Darwin")
+ (ifDarwin
(then (set command "lipo -create #{(@library_executables join)} -output '#{@library_executable_name}'"))
(else (set command "cp '#{(@library_executables objectAtIndex:0)}' '#{@library_executable_name}'")))
(SH command))

0 comments on commit 3aa086b

Please sign in to comment.
Something went wrong with that request. Please try again.