Created
          January 31, 2012 17:23 
        
      - 
      
- 
        Save mysteriouspants/1711700 to your computer and use it in GitHub Desktop. 
    ARMED AND FULLY OPERATIONAL RAKEFILE!!!!
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'rake/clean' | |
| CC = 'clang' | |
| CXX = 'clang++' | |
| LD = CC | |
| PRODUCTS = { | |
| # executable => source file with the main method | |
| 'example_main' => 'example_main.m', | |
| 'default_description_example' => 'default_description_example.m' | |
| } | |
| CFLAGS = [ | |
| '-DDEBUG', | |
| '-std=c99', | |
| '-fobjc-arc' | |
| ].join(' ') | |
| LIBS = [ | |
| '-framework Foundation' | |
| ].join(' ') | |
| OBJC_SOURCES = FileList['*.m'] | |
| O_FILES = OBJC_SOURCES.ext('.o') | |
| rule '.o' => ['.m'] do |t| | |
| sh "#{CC} #{t.source} #{CFLAGS} -c -o #{t.name}" | |
| end | |
| OBJC_SOURCES.each do |src| | |
| file src.ext(".o") => src | |
| end | |
| PRODUCTS.each do |product, source| | |
| # remove the object files for other products to avoid "multiple _main method" errors | |
| object_files = O_FILES - (PRODUCTS.values - [source]).map{|f|f.ext('.o')} | |
| desc 'Build executable for \''+product+'\'' | |
| file product => object_files do |t| | |
| sh "#{LD} #{LIBS} #{object_files} -o #{t.name}" | |
| end | |
| end | |
| CLEAN.include("**/*.o") | |
| CLOBBER.include(PRODUCTS.keys) | |
| desc 'build them ALL: '+PRODUCTS.keys.join(' ') | |
| task :all => PRODUCTS.keys | |
| task :default => 'all' | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment