Skip to content

Commit

Permalink
Rearrange Rakefile code
Browse files Browse the repository at this point in the history
  • Loading branch information
konsolebox committed Apr 3, 2022
1 parent 01bcb51 commit 78c2756
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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\"."
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.

0 comments on commit 78c2756

Please sign in to comment.