From 78c2756719b5ac7fd199c7bd8ca982a958ecab54 Mon Sep 17 00:00:00 2001 From: konsolebox Date: Sun, 3 Apr 2022 15:27:17 +0800 Subject: [PATCH] Rearrange Rakefile code --- Rakefile | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/Rakefile b/Rakefile index d57789a..1bb1505 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,23 @@ # build, clean, clobber, release[remote] + require 'bundler/gem_tasks' -# compile, compile:digest/kangarootwelve -require 'rake/extensiontask' -Rake::ExtensionTask.new('digest/kangarootwelve', Bundler::GemHelper.gemspec) +# clean + +CLEAN.include "ext/digest/kangarootwelve/Makefile" +CLEAN.include "ext/digest/kangarootwelve/**/*.o" +CLEAN.include "ext/digest/kangarootwelve/**/*.so" + +# clobber + +if File.exist?(".git") + CLOBBER.include "LICENSE.XKCP" + CLOBBER.include "ext/digest/kangarootwelve/XKCP" + CLOBBER.include "ext/digest/kangarootwelve/targets" +end # initialize_xkcp + desc "Initialize and update XKCP submodule" task :initialize_xkcp => ".git" do |t| puts "Initializing and updating XKCP submodule" @@ -16,6 +28,7 @@ file "XKCP/Makefile.build" => :initialize_xkcp file "XKCP/README.markdown" => :initialize_xkcp # import_xkcp_license + task :import_xkcp_license do Rake::Task["XKCP/README.markdown"].invoke puts "Extracting XKCP license from \"XKCP/README.markdown\" and saving it to \"LICENSE.XKCP\"." @@ -30,11 +43,8 @@ end.instance_eval do end end -Rake::Task[:build].prerequisites.unshift :import_xkcp_files -Rake::Task[:build].prerequisites.unshift :import_xkcp_license -Rake::Task[:build].prerequisites.unshift :clobber - # import_xkcp_files_lazy + task :import_xkcp_files_lazy do Rake::Task[:import_xkcp_files].invoke end.instance_eval do @@ -43,9 +53,20 @@ end.instance_eval do end end +# build + +Rake::Task[:build].prerequisites.unshift :import_xkcp_files +Rake::Task[:build].prerequisites.unshift :import_xkcp_license +Rake::Task[:build].prerequisites.unshift :clobber + +# compile, compile:digest/kangarootwelve + +require 'rake/extensiontask' +Rake::ExtensionTask.new('digest/kangarootwelve', Bundler::GemHelper.gemspec) Rake::Task[:compile].prerequisites.unshift :import_xkcp_files_lazy # compile_lazy + task :compile_lazy do Rake::Task[:compile].invoke end.instance_eval do @@ -55,23 +76,16 @@ end.instance_eval do end # test + require 'rake/testtask' + Rake::TestTask.new(:test => :compile_lazy) do |t| t.test_files = FileList['test/test.rb'] t.verbose = true end # default -task :default => [:compile, :test] -if File.exist?(".git") - CLOBBER.include "LICENSE.XKCP" - CLOBBER.include "ext/digest/kangarootwelve/XKCP" - CLOBBER.include "ext/digest/kangarootwelve/targets" -end - -CLEAN.include "ext/digest/kangarootwelve/Makefile" -CLEAN.include "ext/digest/kangarootwelve/**/*.o" -CLEAN.include "ext/digest/kangarootwelve/**/*.so" +task :default => [:compile, :test] # Run `rake --tasks` or `rake --tasks --all` for a list of tasks.