Defer several build libraries loading until needed
MODIFY
Rakefile
Rakefile
@@ -10,8 +10,6 @@ $LOAD_PATH << File.join(MRUBY_ROOT, "lib")
# load build systems
require "mruby-core-ext"
require "mruby/build"
-require "mruby/gem"
-require "mruby/lockfile"
# load configuration file
MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"

MODIFY
lib/mruby-core-ext.rb
lib/mruby-core-ext.rb
+autoload :Pathname, 'pathname'
+
class Object
class << self
def attr_block(*syms)

MODIFY
lib/mruby/build.rb
lib/mruby/build.rb
+require "mruby-core-ext"
require "mruby/build/load_gems"
require "mruby/build/command"
module MRuby
+ autoload :Gem, "mruby/gem"
+ autoload :Lockfile, "mruby/lockfile"
+
class << self
def targets
@targets ||= {}

MODIFY
lib/mruby/gem.rb
lib/mruby/gem.rb
-require 'pathname'
require 'forwardable'
-require 'tsort'
-require 'shellwords'
+autoload :TSort, 'tsort'
+autoload :Shellwords, 'shellwords'
module MRuby
module Gem

Defer several build libraries loading until needed