mtbuild 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGES.md +1 -1
 - data/lib/mtbuild.rb +1 -0
 - data/lib/mtbuild/dsl.rb +17 -0
 - data/lib/mtbuild/loaders/makefile.rb +42 -0
 - data/lib/mtbuild/mtfile_task.rb +51 -0
 - data/lib/mtbuild/toolchains/gcc.rb +8 -3
 - data/lib/mtbuild/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2421f140e27fc06f4acc05b65ceeae4ad18807a2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 226f8ccef5e4c26851f2a16838b51a9447dd5918
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b78783ed1b5e6905891c75e31fd46b5f15b09110334d4596033967e0b4a851c27a6f66ac38a3146e5718201f1bfc14ac44c6d25cb212eed3b80afb00c0842eae
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 68e1a5e8e8100d6a6cd1c3e68b3c453675e2be3f9e6a4423d9475ae276a80fad0c954fbf6a6238e063a980cd559a2eb8bb0f33c38c61f3b72830c8693178fca7
         
     | 
    
        data/CHANGES.md
    CHANGED
    
    
    
        data/lib/mtbuild.rb
    CHANGED
    
    | 
         @@ -7,6 +7,7 @@ require "mtbuild/dsl" 
     | 
|
| 
       7 
7 
     | 
    
         
             
            require "mtbuild/framework_project"
         
     | 
| 
       8 
8 
     | 
    
         
             
            require "mtbuild/framework_task"
         
     | 
| 
       9 
9 
     | 
    
         
             
            require "mtbuild/mtbuild"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "mtbuild/mtfile_task"
         
     | 
| 
       10 
11 
     | 
    
         
             
            require "mtbuild/staticlibrary_project"
         
     | 
| 
       11 
12 
     | 
    
         
             
            require "mtbuild/staticlibrary_task"
         
     | 
| 
       12 
13 
     | 
    
         
             
            require "mtbuild/test_application_project"
         
     | 
    
        data/lib/mtbuild/dsl.rb
    CHANGED
    
    | 
         @@ -41,6 +41,23 @@ module MTBuild 
     | 
|
| 
       41 
41 
     | 
    
         
             
                  return versioner_configuration
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
      
 44 
     | 
    
         
            +
                # Declare an MT file task.
         
     | 
| 
      
 45 
     | 
    
         
            +
                #
         
     | 
| 
      
 46 
     | 
    
         
            +
                # Example:
         
     | 
| 
      
 47 
     | 
    
         
            +
                #   mtfile "config.cfg" => ["config.template"] do
         
     | 
| 
      
 48 
     | 
    
         
            +
                #     open("config.cfg", "w") do |outfile|
         
     | 
| 
      
 49 
     | 
    
         
            +
                #       open("config.template") do |infile|
         
     | 
| 
      
 50 
     | 
    
         
            +
                #         while line = infile.gets
         
     | 
| 
      
 51 
     | 
    
         
            +
                #           outfile.puts line
         
     | 
| 
      
 52 
     | 
    
         
            +
                #         end
         
     | 
| 
      
 53 
     | 
    
         
            +
                #       end
         
     | 
| 
      
 54 
     | 
    
         
            +
                #     end
         
     | 
| 
      
 55 
     | 
    
         
            +
                #  end
         
     | 
| 
      
 56 
     | 
    
         
            +
                #
         
     | 
| 
      
 57 
     | 
    
         
            +
                def mtfile(*args, &block)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  MTBuild::MTFileTask.define_task(*args, &block)
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       44 
61 
     | 
    
         
             
              end
         
     | 
| 
       45 
62 
     | 
    
         | 
| 
       46 
63 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module MTBuild
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              # Makefile loader to be used with the import file loader.
         
     | 
| 
      
 4 
     | 
    
         
            +
              class MakefileLoader
         
     | 
| 
      
 5 
     | 
    
         
            +
                include Rake::DSL
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                SPACE_MARK = "\0"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # Load the makefile dependencies in +fn+.
         
     | 
| 
      
 10 
     | 
    
         
            +
                def load(fn)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  lines = File.read fn
         
     | 
| 
      
 12 
     | 
    
         
            +
                  lines.gsub!(/\\ /, SPACE_MARK)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  lines.gsub!(/#[^\n]*\n/m, "")
         
     | 
| 
      
 14 
     | 
    
         
            +
                  lines.gsub!(/\\\n/, ' ')
         
     | 
| 
      
 15 
     | 
    
         
            +
                  lines.each_line do |line|
         
     | 
| 
      
 16 
     | 
    
         
            +
                    return false if not process_line(line)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  return true
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                private
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                # Process one logical line of makefile data.
         
     | 
| 
      
 24 
     | 
    
         
            +
                def process_line(line)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  file_tasks, args = line.split(':', 2)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  return if args.nil?
         
     | 
| 
      
 27 
     | 
    
         
            +
                  dependents = args.split.map { |d| respace(d) }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  dependents.each { |d| return false if not File.file?d }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  file_tasks.scan(/\S+/) do |file_task|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    file_task = respace(file_task)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    file file_task => dependents
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                def respace(str)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  str.tr SPACE_MARK, ' '
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              # Install the handler
         
     | 
| 
      
 41 
     | 
    
         
            +
              Rake.application.add_loader('mf', MakefileLoader.new)
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake/task.rb'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/early_time'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module MTBuild
         
     | 
| 
      
 5 
     | 
    
         
            +
              # #########################################################################
         
     | 
| 
      
 6 
     | 
    
         
            +
              # A FileTask is a task that includes time based dependencies.  If any of a
         
     | 
| 
      
 7 
     | 
    
         
            +
              # FileTask's prerequisites have a timestamp that is later than the file
         
     | 
| 
      
 8 
     | 
    
         
            +
              # represented by this task, then the file must be rebuilt (using the
         
     | 
| 
      
 9 
     | 
    
         
            +
              # supplied actions).
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              class MTFileTask < Rake::Task
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                # Is this file task needed?  Yes if it doesn't exist, or if its time stamp
         
     | 
| 
      
 14 
     | 
    
         
            +
                # is out of date.
         
     | 
| 
      
 15 
     | 
    
         
            +
                def needed?
         
     | 
| 
      
 16 
     | 
    
         
            +
                  ! File.exist?(name) || out_of_date?(timestamp) || @force_needed
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def force_needed()
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @force_needed = true
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                # Time stamp for file task.
         
     | 
| 
      
 24 
     | 
    
         
            +
                def timestamp
         
     | 
| 
      
 25 
     | 
    
         
            +
                  if File.exist?(name)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    File.mtime(name.to_s)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  else
         
     | 
| 
      
 28 
     | 
    
         
            +
                    Rake::EARLY
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                private
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # Are there any prerequisites with a later time than the given time stamp?
         
     | 
| 
      
 35 
     | 
    
         
            +
                def out_of_date?(stamp)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                # ----------------------------------------------------------------
         
     | 
| 
      
 40 
     | 
    
         
            +
                # Task class methods.
         
     | 
| 
      
 41 
     | 
    
         
            +
                #
         
     | 
| 
      
 42 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 43 
     | 
    
         
            +
                  # Apply the scope to the task name according to the rules for this kind
         
     | 
| 
      
 44 
     | 
    
         
            +
                  # of task.  File based tasks ignore the scope when creating the name.
         
     | 
| 
      
 45 
     | 
    
         
            +
                  def scope_name(scope, task_name)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    task_name
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module MTBuild
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'mtbuild/loaders/makefile'
         
     | 
| 
       2 
3 
     | 
    
         
             
              require 'mtbuild/toolchain'
         
     | 
| 
       3 
4 
     | 
    
         
             
              require 'mtbuild/utils'
         
     | 
| 
       4 
5 
     | 
    
         
             
              require 'rake/clean'
         
     | 
| 
       5 
     | 
    
         
            -
              require 'rake/loaders/makefile'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              Toolchain.register_toolchain(:gcc, 'MTBuild::ToolchainGcc')
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -56,11 +56,14 @@ module MTBuild 
     | 
|
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
                    file_type = get_file_type(source_file)
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                     
     | 
| 
      
 59 
     | 
    
         
            +
                    mtfile object_file => [source_file] do |t|
         
     | 
| 
       60 
60 
     | 
    
         
             
                      command_line = construct_compile_command(file_type, [source_file], get_include_paths, t.name)
         
     | 
| 
       61 
61 
     | 
    
         
             
                      sh command_line
         
     | 
| 
       62 
62 
     | 
    
         
             
                    end
         
     | 
| 
       63 
     | 
    
         
            -
                     
     | 
| 
      
 63 
     | 
    
         
            +
                    # Load dependencies if the dependencies file exists and the object file is not already scheduled to be rebuilt
         
     | 
| 
      
 64 
     | 
    
         
            +
                    if File.file?(dependency_file) and not Rake::Task[object_file].needed?
         
     | 
| 
      
 65 
     | 
    
         
            +
                      Rake::Task[object_file].force_needed() if not MTBuild::MakefileLoader.new.load(dependency_file)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end
         
     | 
| 
       64 
67 
     | 
    
         
             
                  end
         
     | 
| 
       65 
68 
     | 
    
         
             
                  return object_files, object_folders
         
     | 
| 
       66 
69 
     | 
    
         
             
                end
         
     | 
| 
         @@ -155,6 +158,8 @@ module MTBuild 
     | 
|
| 
       155 
158 
     | 
    
         
             
                  return 'gcc'
         
     | 
| 
       156 
159 
     | 
    
         
             
                end
         
     | 
| 
       157 
160 
     | 
    
         | 
| 
      
 161 
     | 
    
         
            +
                include MTBuild::DSL
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
       158 
163 
     | 
    
         
             
              end
         
     | 
| 
       159 
164 
     | 
    
         | 
| 
       160 
165 
     | 
    
         
             
            end
         
     | 
    
        data/lib/mtbuild/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mtbuild
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jerry Ryle
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-03-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -110,7 +110,9 @@ files: 
     | 
|
| 
       110 
110 
     | 
    
         
             
            - lib/mtbuild/framework_configuration.rb
         
     | 
| 
       111 
111 
     | 
    
         
             
            - lib/mtbuild/framework_project.rb
         
     | 
| 
       112 
112 
     | 
    
         
             
            - lib/mtbuild/framework_task.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
            - lib/mtbuild/loaders/makefile.rb
         
     | 
| 
       113 
114 
     | 
    
         
             
            - lib/mtbuild/mtbuild.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
            - lib/mtbuild/mtfile_task.rb
         
     | 
| 
       114 
116 
     | 
    
         
             
            - lib/mtbuild/organized_package_task.rb
         
     | 
| 
       115 
117 
     | 
    
         
             
            - lib/mtbuild/project.rb
         
     | 
| 
       116 
118 
     | 
    
         
             
            - lib/mtbuild/staticlibrary_configuration.rb
         
     |