-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
69 lines (53 loc) · 1.65 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
require "json"
require "fileutils"
require "rake/clean"
require "rake/loaders/makefile"
CLEAN.include("./build/*")
CLEAN.include("./dist/*")
CLEAN.include("./releases/*")
CLEAN.include("./src/ruby/**/*.cpp")
CLEAN.include("./include/ruby")
task default: "linux:build"
require_relative "rakelib/helpers"
ephemeral_files_for_ruby.each do |file|
task file do
FileUtils.mkdir_p("include/#{File.dirname(file)}")
cpp_file = "src/#{file.ext}.cpp"
ruby_code = File.read("src/#{file.ext}.rb")
write_hpp_file(file)
write_cpp_file(file, cpp_file, ruby_code)
end
end
multitask setup_ephemeral_files: ephemeral_files_for_ruby
task "lint:check" => [:setup_ephemeral_files] do
sh Builder.builders["linux"].lint
end
task "lint:fix" => [:setup_ephemeral_files] do
sh Builder.builders["linux"].lint(fix: true)
end
task "format:check" do
sh "clang-format --dry-run -Werror $(git ls-files *.cpp)"
sh "clang-format --dry-run -Werror $(git ls-files *.hpp)"
end
task "format:fix" do
sh "clang-format -i $(git ls-files *.{cpp,hpp})"
end
rule ".o" => ->(file) { source_for(file) } do |task|
FileUtils.mkdir_p(File.dirname(task.name))
sh Builder.o_command_for(task)
end
rule ".mf" => ->(file) { source_for(file) } do |task|
data = `#{Builder.mf_command_for(task)}`
file, deps = data.split(":")
deps = deps.split.select { |dep| File.exist? dep }
Rake::Task[file].enhance deps
end
PLATFORMS.each { |platform|
VARIANTS.each { |variant|
task "build:#{platform}:#{variant}" do |task|
FileUtils.mkdir_p("./dist/#{platform}/#{variant}")
Builder.builders[platform].variant = variant
sh Builder.builders[platform].compile
end
}
}