mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-06-11 08:14:16 +08:00
use a cached file dependencies in order to reduce the build time
http://hipbyte.myjetbrains.com/youtrack/issue/RM-466 * before % time rake ... snip ... rake 18.01s user 1.64s system 89% cpu 21.877 total * after % time rake ... snip ... rake 2.74s user 1.41s system 119% cpu 3.460 total
This commit is contained in:
@@ -166,7 +166,14 @@ module Motion; module Project;
|
||||
|
||||
# Resolve file dependencies.
|
||||
if config.detect_dependencies == true
|
||||
config.dependencies = Dependency.new(config.files - config.exclude_from_detect_dependencies, config.dependencies).run
|
||||
deps = Dependency.new(config.files - config.exclude_from_detect_dependencies, config.dependencies)
|
||||
deps.cache_path = File.join(objs_build_dir, "dependencies.rb")
|
||||
|
||||
config.dependencies = deps.run
|
||||
unless deps.updated?
|
||||
config.ordered_build_files = deps.ordered_build_files
|
||||
end
|
||||
deps.save_cache(config.ordered_build_files)
|
||||
end
|
||||
|
||||
parallel = ParallelBuilder.new(objs_build_dir, build_file)
|
||||
@@ -609,6 +616,7 @@ EOS
|
||||
require 'ripper'
|
||||
end
|
||||
|
||||
attr_accessor :cache_path
|
||||
@file_paths = []
|
||||
|
||||
def initialize(paths, dependencies)
|
||||
@@ -663,9 +671,49 @@ EOS
|
||||
end
|
||||
end
|
||||
|
||||
@dependencies = dependency
|
||||
return dependency
|
||||
end
|
||||
|
||||
def updated?
|
||||
return true unless File.exist?(@cache_path)
|
||||
|
||||
begin
|
||||
require @cache_path
|
||||
if @dependencies != cached_dependencies
|
||||
return true
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def ordered_build_files
|
||||
return nil unless File.exist?(@cache_path)
|
||||
|
||||
begin
|
||||
require @cache_path
|
||||
cached_ordered_build_files
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def save_cache(ordered_build_files)
|
||||
begin
|
||||
File.open(@cache_path, 'w') { |io|
|
||||
methods =
|
||||
"module Motion; module Project; class Dependency;\n" +
|
||||
"def cached_dependencies; " + @dependencies.inspect + "; end\n" +
|
||||
"def cached_ordered_build_files; " + ordered_build_files.inspect + "; end\n" +
|
||||
"end; end; end"
|
||||
io.write(methods)
|
||||
}
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
class Constant < Ripper::SexpBuilder
|
||||
attr_accessor :defined
|
||||
attr_accessor :referred
|
||||
|
||||
@@ -255,6 +255,10 @@ module Motion; module Project
|
||||
end
|
||||
end
|
||||
|
||||
def ordered_build_files=(order)
|
||||
@ordered_build_files ||= order
|
||||
end
|
||||
|
||||
def spec_core_files
|
||||
@spec_core_files ||= begin
|
||||
# Core library + core helpers.
|
||||
|
||||
Reference in New Issue
Block a user