lib/esruby/build.rb in esruby-0.0.9 vs lib/esruby/build.rb in esruby-0.0.10

- old
+ new

@@ -11,11 +11,11 @@ new_build = super @build = new_build new_build end - def_delegators :@configuration, :root_directory, :ruby_sources, :build_directory, + def_delegators :@configuration, :root_directory, :build_directory, :build_mode, :output, :mruby_directory, :gems def initialize(&block) @configuration = Configuration.new @configuration.instance_eval(&block) @@ -53,14 +53,17 @@ js_files = [] Gem::Specification.specifications.each do |specification| js_files += specification.appended_js_sources end js_files += @configuration.appended_js_sources - js_files << "#{gem_directory}/resources/js/esruby.js" js_files end + def ruby_sources + @configuration.ruby_sources + ["#{gem_directory}/resources/rb/append.rb"] + end + def build_mruby_config template = File.read("#{gem_directory}/resources/build_config.eruby") eruby = Erubis::Eruby.new(template) config = {} config[:prepended_js_sources] = prepended_js_sources @@ -115,11 +118,11 @@ js_arguments = prepended_js_sources.map { |path| "--pre-js #{path}" }.join(" ") js_arguments += " " js_arguments += appended_js_sources.map { |path| "--post-js #{path}" }.join(" ") RakeFileUtils.sh "#{mrbc} -B app -o #{build_directory}/app.c #{ruby_sources.join(" ")}" RakeFileUtils.sh "emcc --bind -I #{mruby_directory}/include #{build_directory}/app.c -o #{build_directory}/app.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}" - RakeFileUtils.sh "emcc -std=c++11 --bind -I #{mruby_directory}/include #{gem_directory}/resources/cpp/esruby.cpp -o #{build_directory}/esruby.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}" - RakeFileUtils.sh "emcc --bind -I #{mruby_directory}/include -o #{build_directory}/output.js #{build_directory}/app.o #{build_directory}/esruby.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}" + RakeFileUtils.sh "emcc -std=c++11 --bind -I #{mruby_directory}/include #{gem_directory}/resources/cpp/main.cpp -o #{build_directory}/main.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}" + RakeFileUtils.sh "emcc --bind -I #{mruby_directory}/include -o #{build_directory}/output.js #{build_directory}/app.o #{build_directory}/main.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}" #if build.build_mode == 'production' # sh "java -jar #{PROJECT_DIRECTORY}/emsdk/emscripten/incoming/third_party/closure-compiler/compiler.jar --js #{build.absolute_build_directory}/output.js --js_output_file #{build.absolute_output}" #else FileUtils.cp("#{build_directory}/output.js", "#{output}") #end