-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
138 lines (119 loc) Β· 4.23 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
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
133
134
135
136
137
138
# frozen_string_literal: true
require 'open-uri'
require 'shellwords'
require 'bundler/audit/task'
require 'rubocop/rake_task'
task default: %i[format lint]
desc 'Lint sources'
task lint: %i[lint:clippy lint:rubocop:autocorrect]
namespace :lint do
RuboCop::RakeTask.new(:rubocop)
desc 'Lint Rust sources with Clippy'
task :clippy do
sh 'cargo clippy --workspace --all-features --all-targets'
end
desc 'Lint Rust sources with Clippy restriction pass (unenforced lints)'
task :'clippy:restriction' do
lints = [
'clippy::dbg_macro',
'clippy::get_unwrap',
'clippy::indexing_slicing',
'clippy::panic',
'clippy::print_stdout',
'clippy::expect_used',
'clippy::unwrap_used',
'clippy::todo',
'clippy::unimplemented',
'clippy::unreachable'
]
command = ['cargo', 'clippy', '--'] + lints.flat_map { |lint| ['-W', lint] }
sh command.shelljoin
end
end
desc 'Format sources'
task format: %i[format:rust format:text]
namespace :format do
desc 'Format Rust sources with rustfmt'
task :rust do
sh 'cargo fmt -- --color=auto'
end
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npm run fmt'
end
end
desc 'Format sources'
task fmt: %i[fmt:rust fmt:text]
namespace :fmt do
desc 'Format Rust sources with rustfmt'
task :rust do
sh 'cargo fmt -- --color=auto'
end
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npm run fmt'
end
end
desc 'Build Rust workspace'
task :build do
sh 'cargo build --workspace'
end
desc 'Generate Rust API documentation'
task :doc do
ENV['RUSTDOCFLAGS'] = '-D warnings -D rustdoc::broken_intra_doc_links --cfg docsrs'
sh 'rustup run --install nightly cargo doc --workspace'
end
desc 'Generate Rust API documentation and open it in a web browser'
task :'doc:open' do
ENV['RUSTDOCFLAGS'] = '-D warnings -D rustdoc::broken_intra_doc_links --cfg docsrs'
sh 'rustup run --install nightly cargo doc --workspace --open'
end
desc 'Run Focaccia unit tests'
task :test do
sh 'cargo test --workspace'
end
namespace :unicode do
desc 'Rebuild Rust generated Rust sources from Unicode data'
task :build do
ruby 'scripts/gen_case_lookups.rb'
end
# Per the Unicode Terms of Use -- https://www.unicode.org/copyright.html --
# data found under `https://www.unicode.org/Public/` are considered Unicode
# Data Files and are subject to these constaints:
#
# - Except where otherwise more broadly permitted or licensed:
# - you may not make copies of or modifications to Unicode Products for
# public distribution, or incorporate Unicode Products in whole or in part
# into any product or publication, or otherwise publicly distribute them,
# without the express written permission of Unicode, and
# - you may not copy or extract fonts or font data from any Unicode Products,
# including but not limited to Unicode Code Charts.
# - All Unicode Data Files and Unicode Software are subject to the terms and
# conditions of the free and open-source Unicode License v3, unless otherwise
# indicated by specific restriction, permission, or license identified at the
# point of release or in such software, data file, or other documentation.
#
# The Unicode License v3, which can be found at <https://www.unicode.org/license.txt>
# is included in this repository. The license requires one of:
#
# (a) this copyright and permission notice appear with all copies of the Data
# Files or Software
# (b) this copyright and permission notice appear in associated Documentation
#
# `focaccia` distributes this license as `LICENSE-UNICODE` in crate bundles
# and includes `AND Unicode-3.0` in the `Cargo.toml` SPDX license expression.
# See: https://spdx.org/licenses/Unicode-3.0.html.
#
# Updates to Unicode Data Files performed by this `rake` task also update the
# embedded license.
desc 'Update Unicode data'
task :update do
URI.parse('https://www.unicode.org/license.txt').open do |data|
IO.copy_stream(data, 'LICENSE-UNICODE')
end
URI.parse('https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt').open do |data|
IO.copy_stream(data, 'CaseFolding.txt')
end
end
end
Bundler::Audit::Task.new