-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRakefile
More file actions
132 lines (117 loc) · 3.54 KB
/
Rakefile
File metadata and controls
132 lines (117 loc) · 3.54 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# frozen_string_literal: true
require "bundler/setup"
require "syntax_tree/rake_tasks"
require "fileutils"
require "tomlrb"
require "shellwords"
require "tempfile"
SyntaxTree::Rake::WriteTask.new do |t|
t.source_files = FileList[%w[./Rakefile ./scripts/**/*.rb]]
end
SyntaxTree::Rake::CheckTask.new do |t|
t.source_files = FileList[%w[./Rakefile ./scripts/**/*.rb]]
end
suffixes = {
"_input" => ".aui2",
"_output" => ".auo2",
"_filter" => ".auf2",
"_module" => ".mod2",
"_plugin" => ".aux2"
}
main_crates = %w[
aviutl2
aviutl2-sys
aviutl2-macros
aviutl2-alias
aviutl2-eframe
]
def au2(*args)
command = ["au2", *args].map { |arg| Shellwords.escape(arg.to_s) }.join(" ")
sh command
end
def replace_suffix(name, suffixes)
suffixes.each do |key, value|
return name.sub(/#{key}$/, "#{value}") if name.end_with?(key)
end
raise "Invalid file name: #{name}"
end
desc "ビルドしたプラグインをC:/ProgramData/AviUtl2/Pluginまたは指定したディレクトリにインストールします"
task :install, %w[target dest] do |task, args|
if !(target = args.target)
puts "Usage: rake install[target[,dest]]"
puts "Example: rake install[debug]"
exit 1
end
dest_dir = args.dest || "C:/ProgramData/AviUtl2/Plugin"
script_dir = dest_dir + "/../Script"
FileUtils.mkdir_p(dest_dir)
FileUtils.mkdir_p(script_dir)
Dir
.glob("./examples/*/Cargo.toml")
.each do |manifest|
cargo_toml = Tomlrb.load_file(manifest)
unless cargo_toml.key?("lib") &&
cargo_toml["lib"]["crate-type"]&.include?("cdylib")
puts "Skip: #{manifest} is not a cdylib"
next
end
name = cargo_toml["lib"]["name"]
file = "./target/#{target}/#{name}.dll"
dest_name = replace_suffix(name, suffixes)
raise "Invalid file name: #{file}" if dest_name == name
if dest_name.end_with?("mod2")
FileUtils.cp(file, File.join(script_dir, dest_name), verbose: true)
else
FileUtils.cp(file, File.join(dest_dir, dest_name), verbose: true)
end
end
end
desc "./test_environment下にAviUtl2をセットアップし、debugビルドへのシンボリックリンクを作成します"
task :debug_setup do |task, args|
au2("prepare", "--force")
end
desc "リリースアセットを作成します"
task :release, ["tag"] do |task, args|
if !(tag = args.tag)
puts "Usage: rake release[tag]"
puts "Example: rake release[0.1.0]"
exit 1
end
FileUtils.rm_rf("./release")
au2("release", "--set-version", tag)
end
desc "コードをフォーマットします"
task :format do
Rake::Task["stree:write"].invoke
sh "cargo fmt"
end
desc "コードのフォーマットをチェックします"
task :check_format do
Rake::Task["stree:check"].invoke
sh "cargo fmt -- --check"
end
desc "コードをLintします"
task :lint do
sh "cargo clippy --all-targets --all-features -- -D warnings"
sh(
{ "RUSTDOCFLAGS" => "-D warnings" },
"cargo doc --no-deps #{main_crates.map { |c| "--package #{c}" }.join(" ")}"
)
end
desc "コードをテストします"
task :test do
sh "cargo test --all-features"
end
desc "ドキュメントを生成します"
task :doc do
FileUtils.rm_rf("./target/doc")
# NOTE:
# cargo-docs-rsは複数パッケージのドキュメントを一括で生成できないので使わない
sh(
{ "RUSTDOCFLAGS" => "--cfg docsrs" },
"cargo +nightly doc --no-deps --all-features #{main_crates.map { |c| "--package #{c}" }.join(" ")}"
)
File.write("./target/doc/_redirects", <<~TEXT)
/ /aviutl2/ 308
TEXT
end