forked from ruby/prism
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
71 lines (56 loc) · 1.77 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/extensiontask"
require "rake/clean"
task compile: :make
task compile_no_debug: :make_no_debug
task default: [:check_manifest, :compile, :test]
require_relative "templates/template"
desc "Generate all ERB template based files"
task templates: Prism::TEMPLATES
def windows?
RUBY_PLATFORM.include?("mingw")
end
def run_script(command)
command = "sh #{command}" if windows?
sh command
end
task make: [:templates] do
sh "make"
end
task make_no_debug: [:templates] do
sh "make all-no-debug"
end
# decorate the gem build task with prerequisites
task build: [:templates, :check_annotations, :check_manifest]
# the C extension
task "compile:prism" => ["templates"] # must be before the ExtensionTask is created
if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
Rake::ExtensionTask.new(:compile) do |ext|
ext.name = "prism"
ext.ext_dir = "ext/prism"
ext.lib_dir = "lib/prism"
ext.gem_spec = Gem::Specification.load("prism.gemspec")
end
elsif RUBY_ENGINE == "jruby"
require 'rake/javaextensiontask'
# This compiles java to make sure any templating changes produces valid code.
Rake::JavaExtensionTask.new(:compile) do |ext|
ext.name = "prism"
ext.ext_dir = "java"
ext.lib_dir = "tmp"
ext.source_version = "1.8"
ext.target_version = "1.8"
ext.gem_spec = Gem::Specification.load("prism.gemspec")
end
end
# So `rake clobber` will delete generated files
CLOBBER.concat(Prism::TEMPLATES)
CLOBBER.concat(["build"])
CLOBBER << "lib/prism/prism.#{RbConfig::CONFIG["DLEXT"]}"
Prism::TEMPLATES.each do |filepath|
desc "Generate #{filepath}"
file filepath => ["templates/#{filepath}.erb", "templates/template.rb", "config.yml"] do |t|
Prism.template(t.name)
end
end