expressir 1.3.0-aarch64-linux-gnu
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.cross_rubies +20 -0
- data/.github/workflows/rake.yml +313 -0
- data/.github/workflows/release.yml +181 -0
- data/.gitignore +23 -0
- data/.gitmodules +6 -0
- data/.hound.yml +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +18 -0
- data/.yardopts +11 -0
- data/Gemfile +4 -0
- data/README.adoc +155 -0
- data/Rakefile +17 -0
- data/bin/console +11 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/docs/development.md +90 -0
- data/exe/expressir +22 -0
- data/exe/format +18 -0
- data/exe/format-test +81 -0
- data/exe/generate-parser +51 -0
- data/expressir.gemspec +48 -0
- data/lib/expressir/cli/ui.rb +36 -0
- data/lib/expressir/cli.rb +21 -0
- data/lib/expressir/config.rb +23 -0
- data/lib/expressir/express/2.7/express_parser.so +0 -0
- data/lib/expressir/express/3.0/express_parser.so +0 -0
- data/lib/expressir/express/3.1/express_parser.so +0 -0
- data/lib/expressir/express/3.2/express_parser.so +0 -0
- data/lib/expressir/express/cache.rb +51 -0
- data/lib/expressir/express/formatter.rb +1608 -0
- data/lib/expressir/express/hyperlink_formatter.rb +36 -0
- data/lib/expressir/express/model_visitor.rb +24 -0
- data/lib/expressir/express/parser.rb +84 -0
- data/lib/expressir/express/resolve_references_model_visitor.rb +31 -0
- data/lib/expressir/express/schema_head_formatter.rb +23 -0
- data/lib/expressir/express/visitor.rb +2588 -0
- data/lib/expressir/model/cache.rb +17 -0
- data/lib/expressir/model/data_type.rb +9 -0
- data/lib/expressir/model/data_types/aggregate.rb +31 -0
- data/lib/expressir/model/data_types/array.rb +31 -0
- data/lib/expressir/model/data_types/bag.rb +25 -0
- data/lib/expressir/model/data_types/binary.rb +22 -0
- data/lib/expressir/model/data_types/boolean.rb +10 -0
- data/lib/expressir/model/data_types/enumeration.rb +25 -0
- data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
- data/lib/expressir/model/data_types/generic.rb +26 -0
- data/lib/expressir/model/data_types/generic_entity.rb +26 -0
- data/lib/expressir/model/data_types/integer.rb +10 -0
- data/lib/expressir/model/data_types/list.rb +28 -0
- data/lib/expressir/model/data_types/logical.rb +10 -0
- data/lib/expressir/model/data_types/number.rb +10 -0
- data/lib/expressir/model/data_types/real.rb +19 -0
- data/lib/expressir/model/data_types/select.rb +28 -0
- data/lib/expressir/model/data_types/set.rb +25 -0
- data/lib/expressir/model/data_types/string.rb +22 -0
- data/lib/expressir/model/declaration.rb +9 -0
- data/lib/expressir/model/declarations/attribute.rb +47 -0
- data/lib/expressir/model/declarations/constant.rb +34 -0
- data/lib/expressir/model/declarations/entity.rb +53 -0
- data/lib/expressir/model/declarations/function.rb +67 -0
- data/lib/expressir/model/declarations/interface.rb +28 -0
- data/lib/expressir/model/declarations/interface_item.rb +23 -0
- data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
- data/lib/expressir/model/declarations/parameter.rb +34 -0
- data/lib/expressir/model/declarations/procedure.rb +64 -0
- data/lib/expressir/model/declarations/remark_item.rb +21 -0
- data/lib/expressir/model/declarations/rule.rb +71 -0
- data/lib/expressir/model/declarations/schema.rb +117 -0
- data/lib/expressir/model/declarations/schema_version.rb +22 -0
- data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
- data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
- data/lib/expressir/model/declarations/type.rb +45 -0
- data/lib/expressir/model/declarations/unique_rule.rb +31 -0
- data/lib/expressir/model/declarations/variable.rb +34 -0
- data/lib/expressir/model/declarations/where_rule.rb +31 -0
- data/lib/expressir/model/expression.rb +9 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +19 -0
- data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
- data/lib/expressir/model/expressions/binary_expression.rb +53 -0
- data/lib/expressir/model/expressions/entity_constructor.rb +22 -0
- data/lib/expressir/model/expressions/function_call.rb +22 -0
- data/lib/expressir/model/expressions/interval.rb +34 -0
- data/lib/expressir/model/expressions/query_expression.rb +35 -0
- data/lib/expressir/model/expressions/unary_expression.rb +27 -0
- data/lib/expressir/model/identifier.rb +34 -0
- data/lib/expressir/model/literal.rb +9 -0
- data/lib/expressir/model/literals/binary.rb +19 -0
- data/lib/expressir/model/literals/integer.rb +19 -0
- data/lib/expressir/model/literals/logical.rb +23 -0
- data/lib/expressir/model/literals/real.rb +19 -0
- data/lib/expressir/model/literals/string.rb +22 -0
- data/lib/expressir/model/model_element.rb +208 -0
- data/lib/expressir/model/reference.rb +9 -0
- data/lib/expressir/model/references/attribute_reference.rb +22 -0
- data/lib/expressir/model/references/group_reference.rb +22 -0
- data/lib/expressir/model/references/index_reference.rb +27 -0
- data/lib/expressir/model/references/simple_reference.rb +24 -0
- data/lib/expressir/model/repository.rb +23 -0
- data/lib/expressir/model/statement.rb +9 -0
- data/lib/expressir/model/statements/alias.rb +35 -0
- data/lib/expressir/model/statements/assignment.rb +22 -0
- data/lib/expressir/model/statements/case.rb +25 -0
- data/lib/expressir/model/statements/case_action.rb +22 -0
- data/lib/expressir/model/statements/compound.rb +19 -0
- data/lib/expressir/model/statements/escape.rb +10 -0
- data/lib/expressir/model/statements/if.rb +25 -0
- data/lib/expressir/model/statements/null.rb +10 -0
- data/lib/expressir/model/statements/procedure_call.rb +22 -0
- data/lib/expressir/model/statements/repeat.rb +47 -0
- data/lib/expressir/model/statements/return.rb +19 -0
- data/lib/expressir/model/statements/skip.rb +10 -0
- data/lib/expressir/model/supertype_expression.rb +9 -0
- data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
- data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
- data/lib/expressir/model.rb +79 -0
- data/lib/expressir/version.rb +3 -0
- data/lib/expressir.rb +24 -0
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +384 -0
- data/spec/acceptance/version_spec.rb +27 -0
- data/spec/expressir/express/cache_spec.rb +89 -0
- data/spec/expressir/express/formatter_spec.rb +173 -0
- data/spec/expressir/express/parser_spec.rb +141 -0
- data/spec/expressir/model/model_element_spec.rb +318 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/console_helper.rb +29 -0
- data/spec/syntax/multiple.exp +23 -0
- data/spec/syntax/multiple.yaml +198 -0
- data/spec/syntax/multiple_formatted.exp +71 -0
- data/spec/syntax/multiple_hyperlink_formatted.exp +71 -0
- data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
- data/spec/syntax/remark.exp +193 -0
- data/spec/syntax/remark.yaml +471 -0
- data/spec/syntax/remark_formatted.exp +228 -0
- data/spec/syntax/single.exp +4 -0
- data/spec/syntax/single.yaml +18 -0
- data/spec/syntax/single_formatted.exp +10 -0
- data/spec/syntax/single_formatted.yaml +36 -0
- data/spec/syntax/syntax.exp +333 -0
- data/spec/syntax/syntax.yaml +3509 -0
- data/spec/syntax/syntax_formatted.exp +902 -0
- data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/spec/syntax/syntax_schema_head_formatted.exp +18 -0
- metadata +390 -0
@@ -0,0 +1,384 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
require "shellwords"
|
3
|
+
|
4
|
+
WINDOWS_PLATFORM_REGEX = /mingw|mswin/.freeze
|
5
|
+
LINUX_GNU_PLATFORM_REGEX = /linux-gnu/.freeze
|
6
|
+
DARWIN_PLATFORM_REGEX = /darwin/.freeze
|
7
|
+
GLIBC_MIN_VERSION = "2.17".freeze
|
8
|
+
|
9
|
+
CrossRuby = Struct.new(:version, :host) do
|
10
|
+
def dll_staging_path
|
11
|
+
"tmp/#{platform}/stage/lib/expressir/express/#{minor_ver}/express_parser.#{dll_ext}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def windows?
|
15
|
+
!!(platform =~ WINDOWS_PLATFORM_REGEX)
|
16
|
+
end
|
17
|
+
|
18
|
+
def linux_gnu?
|
19
|
+
!!(platform =~ LINUX_GNU_PLATFORM_REGEX)
|
20
|
+
end
|
21
|
+
|
22
|
+
def darwin?
|
23
|
+
!!(platform =~ DARWIN_PLATFORM_REGEX)
|
24
|
+
end
|
25
|
+
|
26
|
+
def ver
|
27
|
+
@ver ||= version[/\A[^-]+/]
|
28
|
+
end
|
29
|
+
|
30
|
+
def minor_ver
|
31
|
+
@minor_ver ||= ver[/\A\d\.\d(?=\.)/]
|
32
|
+
end
|
33
|
+
|
34
|
+
def minor_ver_digi
|
35
|
+
@minor_ver_digi = minor_ver.delete(".").to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
def ucrt?
|
39
|
+
minor_ver_digi >= 31
|
40
|
+
end
|
41
|
+
|
42
|
+
def api_ver_suffix
|
43
|
+
case minor_ver
|
44
|
+
when nil
|
45
|
+
raise "CrossRuby.api_ver_suffix: unsupported version: #{ver}"
|
46
|
+
else
|
47
|
+
minor_ver.delete(".") << "0"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# rubocop:disable Metrics/MethodLength
|
52
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
53
|
+
def platform
|
54
|
+
@platform ||=
|
55
|
+
case host
|
56
|
+
when /\Ax86_64.*mingw32/
|
57
|
+
if ucrt?
|
58
|
+
"x64-mingw-ucrt"
|
59
|
+
else
|
60
|
+
"x64-mingw32"
|
61
|
+
end
|
62
|
+
when "x86_64-linux-gnu"
|
63
|
+
"x86_64-linux-gnu"
|
64
|
+
when "aarch64-linux-gnu"
|
65
|
+
"aarch64-linux-gnu"
|
66
|
+
when /\Ax86_64-darwin/
|
67
|
+
"x86_64-darwin"
|
68
|
+
when /\Aarm64-darwin/
|
69
|
+
"arm64-darwin"
|
70
|
+
else
|
71
|
+
raise "CrossRuby.platform: unsupported host: #{host}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def tag
|
76
|
+
@tag ||=
|
77
|
+
case platform
|
78
|
+
when "x86_64-linux-gnu"
|
79
|
+
"x86_64-linux"
|
80
|
+
when "aarch64-linux-gnu"
|
81
|
+
"aarch64-linux"
|
82
|
+
else
|
83
|
+
platform
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def tool(name)
|
88
|
+
(@binutils_prefix ||=
|
89
|
+
case platform
|
90
|
+
when /x64-mingw(32|-ucrt)/
|
91
|
+
"x86_64-w64-mingw32-"
|
92
|
+
when /(x86_64|aarch64)-linux-gnu/
|
93
|
+
# We do believe that we are on Linux and can use native tools
|
94
|
+
""
|
95
|
+
when /x86_64.*darwin/
|
96
|
+
"x86_64-apple-darwin-"
|
97
|
+
when /a.*64.*darwin/
|
98
|
+
"aarch64-apple-darwin-"
|
99
|
+
else
|
100
|
+
raise "CrossRuby.tool: unmatched platform: #{platform}"
|
101
|
+
end) + name
|
102
|
+
end
|
103
|
+
|
104
|
+
def target_file_format
|
105
|
+
case platform
|
106
|
+
when /64-mingw(32|-ucrt)/
|
107
|
+
"pei-x86-64"
|
108
|
+
when "x86_64-linux-gnu"
|
109
|
+
"elf64-x86-64"
|
110
|
+
when "aarch64-linux-gnu"
|
111
|
+
"elf64-little"
|
112
|
+
when "x86_64-darwin"
|
113
|
+
"Mach-O 64-bit x86-64"
|
114
|
+
when "arm64-darwin"
|
115
|
+
"Mach-O arm64"
|
116
|
+
else
|
117
|
+
raise "CrossRuby.target_file_format: unmatched platform: #{platform}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
# rubocop:enable Metrics/MethodLength
|
121
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
122
|
+
|
123
|
+
def dll_ext
|
124
|
+
darwin? ? "bundle" : "so"
|
125
|
+
end
|
126
|
+
|
127
|
+
def verify_format(dump, dll)
|
128
|
+
format_match = (/file format #{Regexp.quote(target_file_format)}\s/ === dump)
|
129
|
+
format_error = "Unexpected file format for '#{dll}', '#{target_file_format}' required"
|
130
|
+
raise format_error unless format_match
|
131
|
+
end
|
132
|
+
|
133
|
+
def verify_entry_windows(dump, dll)
|
134
|
+
unless /Table.*\sInit_express_parser\s/mi === dump
|
135
|
+
raise "Export function Init_express_parser not in dll #{dll}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def verify_entry_linux(dll)
|
140
|
+
nm = `#{["env", "LANG=C", tool("nm"), "-D", dll].shelljoin}`
|
141
|
+
unless nm.include?(" T Init_express_parser")
|
142
|
+
raise "Export function Init_express_parser not in dll #{dll}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def verify_entry_darwin(dll)
|
147
|
+
nm = `#{["env", "LANG=C", tool("nm"), "-g", dll].shelljoin}`
|
148
|
+
unless / T _?Init_express_parser/.match?(nm)
|
149
|
+
raise "Export function Init_express_parser not in dll #{dll}"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def verify_entry(dump, dll)
|
154
|
+
case platform
|
155
|
+
when WINDOWS_PLATFORM_REGEX
|
156
|
+
verify_entry_windows(dump, dll)
|
157
|
+
when LINUX_GNU_PLATFORM_REGEX
|
158
|
+
verify_entry_linux(dll)
|
159
|
+
when DARWIN_PLATFORM_REGEX
|
160
|
+
verify_entry_darwin(dll)
|
161
|
+
else
|
162
|
+
raise "CrossRuby.verify_entry: unmatched platform: #{platform}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# rubocop:disable Metrics/MethodLength
|
167
|
+
def allowed_dlls_ucrt
|
168
|
+
["kernel32.dll",
|
169
|
+
"api-ms-win-crt-convert-l1-1-0.dll",
|
170
|
+
"api-ms-win-crt-environment-l1-1-0.dll",
|
171
|
+
"api-ms-win-crt-heap-l1-1-0.dll",
|
172
|
+
"api-ms-win-crt-locale-l1-1-0.dll",
|
173
|
+
"api-ms-win-crt-private-l1-1-0.dll",
|
174
|
+
"api-ms-win-crt-runtime-l1-1-0.dll",
|
175
|
+
"api-ms-win-crt-stdio-l1-1-0.dll",
|
176
|
+
"api-ms-win-crt-string-l1-1-0.dll",
|
177
|
+
"api-ms-win-crt-time-l1-1-0.dll",
|
178
|
+
"api-ms-win-crt-filesystem-l1-1-0.dll",
|
179
|
+
"api-ms-win-crt-math-l1-1-0.dll",
|
180
|
+
"libwinpthread-1.dll",
|
181
|
+
"x64-ucrt-ruby#{api_ver_suffix}.dll"]
|
182
|
+
end
|
183
|
+
# rubocop:enable Metrics/MethodLength
|
184
|
+
|
185
|
+
def allowed_dlls_mingw
|
186
|
+
[
|
187
|
+
"kernel32.dll",
|
188
|
+
"msvcrt.dll",
|
189
|
+
"libwinpthread-1.dll",
|
190
|
+
"x64-msvcrt-ruby#{api_ver_suffix}.dll",
|
191
|
+
]
|
192
|
+
end
|
193
|
+
|
194
|
+
def allowed_dlls_windows
|
195
|
+
if ucrt?
|
196
|
+
allowed_dlls_ucrt
|
197
|
+
else
|
198
|
+
allowed_dlls_mingw
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def allowed_dlls_linux
|
203
|
+
suffix = (platform == "x86_64-linux-gnu" ? "x86-64" : "aarch64")
|
204
|
+
[
|
205
|
+
"ld-linux-#{suffix}.so",
|
206
|
+
"libc.so",
|
207
|
+
"libm.so",
|
208
|
+
"libstdc++.so",
|
209
|
+
"libgcc_s.so",
|
210
|
+
"libpthread.so",
|
211
|
+
]
|
212
|
+
end
|
213
|
+
|
214
|
+
def allowed_dlls_darwin
|
215
|
+
[
|
216
|
+
"/usr/lib/libSystem.B.dylib",
|
217
|
+
"/usr/lib/libc++.1.dylib",
|
218
|
+
]
|
219
|
+
end
|
220
|
+
|
221
|
+
def allowed_dlls
|
222
|
+
case platform
|
223
|
+
when WINDOWS_PLATFORM_REGEX
|
224
|
+
allowed_dlls_windows
|
225
|
+
when LINUX_GNU_PLATFORM_REGEX
|
226
|
+
allowed_dlls_linux
|
227
|
+
when DARWIN_PLATFORM_REGEX
|
228
|
+
allowed_dlls_darwin
|
229
|
+
else
|
230
|
+
raise "CrossRuby.allowed_dlls: unmatched platform: #{platform}"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def actual_dlls_linux(dump)
|
235
|
+
dump.scan(/NEEDED\s+(.*)/).map(&:first).uniq
|
236
|
+
end
|
237
|
+
|
238
|
+
def actual_dlls_windows(dump)
|
239
|
+
dump.scan(/DLL Name: (.*)$/).map { |x| x.first.downcase }.uniq
|
240
|
+
end
|
241
|
+
|
242
|
+
def actual_dlls_darwin(dll)
|
243
|
+
ldd = `#{[tool("otool"), "-L", dll].shelljoin}`
|
244
|
+
ldd.scan(/^\t([^ ]+) /).map(&:first).uniq
|
245
|
+
end
|
246
|
+
|
247
|
+
def actual_dlls(dump, dll)
|
248
|
+
case platform
|
249
|
+
when DARWIN_PLATFORM_REGEX
|
250
|
+
actual_dlls_darwin(dll)
|
251
|
+
when LINUX_GNU_PLATFORM_REGEX
|
252
|
+
actual_dlls_linux(dump)
|
253
|
+
when WINDOWS_PLATFORM_REGEX
|
254
|
+
actual_dlls_windows(dump)
|
255
|
+
else
|
256
|
+
raise "CrossRuby.actual_dlls: unmatched platform: #{platform}"
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def verify_imports(dump, dll)
|
261
|
+
l = actual_dlls(dump, dll)
|
262
|
+
libs = allowed_dlls
|
263
|
+
l.delete_if { |ln| libs.any? { |lib| ln.include?(lib) } }
|
264
|
+
unless l.empty?
|
265
|
+
raise "Unexpected references in '#{dll}' : #{l}"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def lib_ref_versions(data)
|
270
|
+
# Build a hash of library versions like {"LIBUDEV"=>"183", "GLIBC"=>"2.17"}
|
271
|
+
data.each.with_object({}) do |(lib, ver), h|
|
272
|
+
if !h[lib] || ver.split(".").map(&:to_i).pack("C*") > h[lib].split(".").map(&:to_i).pack("C*")
|
273
|
+
h[lib] = ver
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def verify_glibc_version(dump, dll)
|
279
|
+
ref_versions_data = dump.scan(/0x[\da-f]+ 0x[\da-f]+ \d+ (\w+)_([\d.]+)$/i)
|
280
|
+
ref_ver = lib_ref_versions(ref_versions_data)
|
281
|
+
|
282
|
+
unless ref_ver["GLIBC"].delete(".").to_i <= GLIBC_MIN_VERSION.delete(".").to_i
|
283
|
+
raise "Unexpected GLIBC version #{ref_ver['GLIBC']} for #{dll}, #{GLIBC_MIN_VERSION} or lower is expected"
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
CROSS_RUBIES = File.read(".cross_rubies").split("\n").filter_map do |line|
|
289
|
+
case line
|
290
|
+
when /\A([^#]+):([^#]+)/
|
291
|
+
CrossRuby.new($1, $2)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
ENV["RUBY_CC_VERSION"] = CROSS_RUBIES.map(&:ver).uniq.join(":")
|
296
|
+
|
297
|
+
require "rake_compiler_dock"
|
298
|
+
|
299
|
+
def verify_dll(dll, cross_ruby)
|
300
|
+
dump = `#{["env", "LANG=C", cross_ruby.tool("objdump"), "-p", dll].shelljoin}`
|
301
|
+
cross_ruby.verify_format(dump, dll)
|
302
|
+
cross_ruby.verify_entry(dump, dll)
|
303
|
+
cross_ruby.verify_imports(dump, dll)
|
304
|
+
# Not sure if it is required, probably not
|
305
|
+
# I am keeping related code as a reference for future advances
|
306
|
+
# cross_ruby.verify_glibc_version(dump, dll) if cross_ruby.linux_gnu?
|
307
|
+
|
308
|
+
puts "#{dll}: passed shared library sanity checks"
|
309
|
+
end
|
310
|
+
|
311
|
+
CROSS_RUBIES.each do |cross_ruby|
|
312
|
+
unless Rake::Task.task_defined?(cross_ruby.dll_staging_path)
|
313
|
+
task cross_ruby.dll_staging_path do |t|
|
314
|
+
verify_dll t.name, cross_ruby
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def gem_builder(plat)
|
320
|
+
# use Task#invoke because the pkg/*gem task is defined at runtime
|
321
|
+
Rake::Task["native:#{plat}"].invoke
|
322
|
+
Rake::Task["pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(plat)}.gem"].invoke
|
323
|
+
end
|
324
|
+
|
325
|
+
REDHAT_PREREQ = "sudo yum install -y git".freeze
|
326
|
+
UBUNTU_PREREQ = "sudo apt-get update -y && sudo apt-get install -y automake autoconf libtool build-essential".freeze
|
327
|
+
|
328
|
+
def pre_req(plat)
|
329
|
+
case plat
|
330
|
+
when /linux/
|
331
|
+
"if [[ $(awk -F= '/^NAME/{print $2}' /etc/os-release) == '\"Ubuntu\"' ]]; then #{UBUNTU_PREREQ}; else #{REDHAT_PREREQ}; fi"
|
332
|
+
else
|
333
|
+
UBUNTU_PREREQ.to_s
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
namespace "gem" do
|
338
|
+
CROSS_RUBIES.find_all { |cr| cr.windows? || cr.linux_gnu? || cr.darwin? }
|
339
|
+
.map { |cr| { platform: cr.platform, tag: cr.tag } }
|
340
|
+
.uniq { |hash| hash[:platform] }.each do |hash|
|
341
|
+
plat = hash[:platform]
|
342
|
+
tag = hash[:tag]
|
343
|
+
|
344
|
+
desc "build native gem for #{plat} platform"
|
345
|
+
task plat do
|
346
|
+
RakeCompilerDock.sh <<~RCD, platform: tag
|
347
|
+
#{pre_req(plat)} && gem install bundler --no-document &&
|
348
|
+
bundle && bundle exec rake gem:#{plat}:builder MAKE="nice make -j`nproc`"
|
349
|
+
RCD
|
350
|
+
end
|
351
|
+
|
352
|
+
namespace plat do
|
353
|
+
desc "build native gem for #{plat} platform (guest container)"
|
354
|
+
task "builder" do
|
355
|
+
gem_builder(plat)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
desc "build native gems for windows"
|
361
|
+
multitask "windows" => CROSS_RUBIES.find_all(&:windows?).map(&:platform).uniq
|
362
|
+
|
363
|
+
desc "build native gems for linux"
|
364
|
+
multitask "linux-gnu" => CROSS_RUBIES.find_all(&:linux_gnu?).map(&:platform).uniq
|
365
|
+
|
366
|
+
desc "build native gems for darwin"
|
367
|
+
multitask "darwin" => CROSS_RUBIES.find_all(&:darwin?).map(&:platform).uniq
|
368
|
+
end
|
369
|
+
|
370
|
+
require "rake/extensiontask"
|
371
|
+
|
372
|
+
Rake::ExtensionTask.new("express_parser", GEMSPEC) do |ext|
|
373
|
+
ext.ext_dir = "ext/express-parser"
|
374
|
+
ext.lib_dir = File.join(*["lib", "expressir", "express", ENV.fetch("FAT_DIR", nil)].compact)
|
375
|
+
ext.config_options << ENV.fetch("EXTOPTS", nil)
|
376
|
+
ext.cross_compile = true
|
377
|
+
ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
|
378
|
+
ext.cross_config_options << "--enable-cross-build"
|
379
|
+
|
380
|
+
ext.cross_compiling do |spec|
|
381
|
+
spec.files.reject! { |path| File.fnmatch?("ext/*", path) }
|
382
|
+
spec.dependencies.reject! { |dep| dep.name == "rice" }
|
383
|
+
end
|
384
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Expressir" do
|
4
|
+
describe "version" do
|
5
|
+
it "has a version number" do |example|
|
6
|
+
print "\n[#{example.description}] "
|
7
|
+
expect(Expressir::VERSION).not_to be nil
|
8
|
+
|
9
|
+
# Validate Object Space
|
10
|
+
GC.start
|
11
|
+
GC.verify_compaction_references
|
12
|
+
GC.verify_internal_consistency
|
13
|
+
end
|
14
|
+
|
15
|
+
it "displays the current verison" do |example|
|
16
|
+
print "\n[#{example.description}] "
|
17
|
+
command = %w(version)
|
18
|
+
output = capture_stdout { Expressir::Cli.start(command) }
|
19
|
+
expect(output).to include("Version #{Expressir::VERSION}")
|
20
|
+
|
21
|
+
# Validate Object Space
|
22
|
+
GC.start
|
23
|
+
GC.verify_compaction_references
|
24
|
+
GC.verify_internal_consistency
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "tempfile"
|
3
|
+
require "spec_helper"
|
4
|
+
require "expressir/express/parser"
|
5
|
+
require "expressir/express/cache"
|
6
|
+
|
7
|
+
TEST_VERSION = "0.0.0".freeze
|
8
|
+
|
9
|
+
RSpec.describe Expressir::Express::Cache do
|
10
|
+
describe ".to_file" do
|
11
|
+
it "exports an object" do |example|
|
12
|
+
print "\n[#{example.description}] "
|
13
|
+
temp_file = Tempfile.new
|
14
|
+
|
15
|
+
repository = Expressir::Model::Repository.new
|
16
|
+
|
17
|
+
begin
|
18
|
+
Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
|
19
|
+
|
20
|
+
size = File.size(temp_file)
|
21
|
+
|
22
|
+
expect(size).to be > 0
|
23
|
+
ensure
|
24
|
+
temp_file.close
|
25
|
+
temp_file.unlink
|
26
|
+
end
|
27
|
+
|
28
|
+
# Validate Object Space
|
29
|
+
GC.start
|
30
|
+
GC.verify_compaction_references
|
31
|
+
GC.verify_internal_consistency
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".from_file" do
|
36
|
+
it "throws an exception if the cache file does not exist" do |example|
|
37
|
+
print "\n[#{example.description}] "
|
38
|
+
expect do
|
39
|
+
Expressir::Express::Cache.from_file("non-existing-file", test_overwrite_version: TEST_VERSION)
|
40
|
+
end.to raise_error(Errno::ENOENT)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "parses a file" do |example|
|
44
|
+
print "\n[#{example.description}] "
|
45
|
+
temp_file = Tempfile.new
|
46
|
+
|
47
|
+
repository = Expressir::Model::Repository.new
|
48
|
+
|
49
|
+
begin
|
50
|
+
Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
|
51
|
+
|
52
|
+
result = Expressir::Express::Cache.from_file(temp_file, test_overwrite_version: TEST_VERSION)
|
53
|
+
|
54
|
+
expect(result).to be_instance_of(Expressir::Model::Repository)
|
55
|
+
ensure
|
56
|
+
temp_file.close
|
57
|
+
temp_file.unlink
|
58
|
+
end
|
59
|
+
|
60
|
+
# Validate Object Space
|
61
|
+
GC.start
|
62
|
+
GC.verify_compaction_references
|
63
|
+
GC.verify_internal_consistency
|
64
|
+
end
|
65
|
+
|
66
|
+
it "fails parsing a file from a different Expressir version" do |example|
|
67
|
+
print "\n[#{example.description}] "
|
68
|
+
temp_file = Tempfile.new
|
69
|
+
|
70
|
+
repository = Expressir::Model::Repository.new
|
71
|
+
|
72
|
+
begin
|
73
|
+
Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
|
74
|
+
|
75
|
+
expect do
|
76
|
+
Expressir::Express::Cache.from_file(temp_file)
|
77
|
+
end.to raise_error(Expressir::Error)
|
78
|
+
ensure
|
79
|
+
temp_file.close
|
80
|
+
temp_file.unlink
|
81
|
+
end
|
82
|
+
|
83
|
+
# Validate Object Space
|
84
|
+
GC.start
|
85
|
+
GC.verify_compaction_references
|
86
|
+
GC.verify_internal_consistency
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "spec_helper"
|
3
|
+
require "expressir/express/parser"
|
4
|
+
require "expressir/express/formatter"
|
5
|
+
require "expressir/express/schema_head_formatter"
|
6
|
+
require "expressir/express/hyperlink_formatter"
|
7
|
+
|
8
|
+
RSpec.describe Expressir::Express::Formatter do
|
9
|
+
describe ".format" do
|
10
|
+
it "exports an object (single.exp)" do |example|
|
11
|
+
print "\n[#{example.description}] "
|
12
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
|
13
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "single_formatted.exp")
|
14
|
+
|
15
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
16
|
+
|
17
|
+
result = Expressir::Express::Formatter.format(repo)
|
18
|
+
# File.write(formatted_exp_file, result)
|
19
|
+
expected_result = File.read(formatted_exp_file)
|
20
|
+
|
21
|
+
expect(result).to eq(expected_result)
|
22
|
+
|
23
|
+
# Validate Object Space
|
24
|
+
GC.start
|
25
|
+
GC.verify_compaction_references
|
26
|
+
GC.verify_internal_consistency
|
27
|
+
end
|
28
|
+
|
29
|
+
it "exports an object (multiple.exp)" do |example|
|
30
|
+
print "\n[#{example.description}] "
|
31
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
|
32
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_formatted.exp")
|
33
|
+
|
34
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
35
|
+
|
36
|
+
result = Expressir::Express::Formatter.format(repo)
|
37
|
+
# File.write(formatted_exp_file, result)
|
38
|
+
expected_result = File.read(formatted_exp_file)
|
39
|
+
|
40
|
+
expect(result).to eq(expected_result)
|
41
|
+
GC.start
|
42
|
+
GC.verify_compaction_references
|
43
|
+
GC.verify_internal_consistency
|
44
|
+
end
|
45
|
+
|
46
|
+
it "exports an object (remark.exp)" do |example|
|
47
|
+
print "\n[#{example.description}] "
|
48
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "remark.exp")
|
49
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "remark_formatted.exp")
|
50
|
+
|
51
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
52
|
+
|
53
|
+
result = Expressir::Express::Formatter.format(repo)
|
54
|
+
# File.write(formatted_exp_file, result)
|
55
|
+
expected_result = File.read(formatted_exp_file)
|
56
|
+
|
57
|
+
expect(result).to eq(expected_result)
|
58
|
+
|
59
|
+
# Validate Object Space
|
60
|
+
GC.start
|
61
|
+
GC.verify_compaction_references
|
62
|
+
GC.verify_internal_consistency
|
63
|
+
end
|
64
|
+
|
65
|
+
it "exports an object (syntax.exp)" do |example|
|
66
|
+
print "\n[#{example.description}] "
|
67
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
|
68
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_formatted.exp")
|
69
|
+
|
70
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
71
|
+
|
72
|
+
result = Expressir::Express::Formatter.format(repo)
|
73
|
+
# File.write(formatted_exp_file, result)
|
74
|
+
expected_result = File.read(formatted_exp_file)
|
75
|
+
|
76
|
+
expect(result).to eq(expected_result)
|
77
|
+
|
78
|
+
# Validate Object Space
|
79
|
+
GC.start
|
80
|
+
GC.verify_compaction_references
|
81
|
+
GC.verify_internal_consistency
|
82
|
+
end
|
83
|
+
|
84
|
+
it "exports an object with schema head formatter (syntax.exp)" do |example|
|
85
|
+
print "\n[#{example.description}] "
|
86
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
|
87
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_schema_head_formatted.exp")
|
88
|
+
|
89
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
90
|
+
|
91
|
+
formatter = Class.new(Expressir::Express::Formatter) do
|
92
|
+
include Expressir::Express::SchemaHeadFormatter
|
93
|
+
end
|
94
|
+
result = formatter.format(repo)
|
95
|
+
# File.write(formatted_exp_file, result)
|
96
|
+
expected_result = File.read(formatted_exp_file)
|
97
|
+
|
98
|
+
expect(result).to eq(expected_result)
|
99
|
+
|
100
|
+
# Validate Object Space
|
101
|
+
GC.start
|
102
|
+
GC.verify_compaction_references
|
103
|
+
GC.verify_internal_consistency
|
104
|
+
end
|
105
|
+
|
106
|
+
it "exports an object with hyperlink formatter (syntax.exp)" do |example|
|
107
|
+
print "\n[#{example.description}] "
|
108
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
|
109
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_hyperlink_formatted.exp")
|
110
|
+
|
111
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
112
|
+
|
113
|
+
formatter = Class.new(Expressir::Express::Formatter) do
|
114
|
+
include Expressir::Express::HyperlinkFormatter
|
115
|
+
end
|
116
|
+
result = formatter.format(repo)
|
117
|
+
# File.write(formatted_exp_file, result)
|
118
|
+
expected_result = File.read(formatted_exp_file)
|
119
|
+
|
120
|
+
expect(result).to eq(expected_result)
|
121
|
+
|
122
|
+
# Validate Object Space
|
123
|
+
GC.start
|
124
|
+
GC.verify_compaction_references
|
125
|
+
GC.verify_internal_consistency
|
126
|
+
end
|
127
|
+
|
128
|
+
it "exports an object with hyperlink formatter (multiple.exp)" do |example|
|
129
|
+
print "\n[#{example.description}] "
|
130
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
|
131
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_hyperlink_formatted.exp")
|
132
|
+
|
133
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
134
|
+
|
135
|
+
formatter = Class.new(Expressir::Express::Formatter) do
|
136
|
+
include Expressir::Express::HyperlinkFormatter
|
137
|
+
end
|
138
|
+
result = formatter.format(repo)
|
139
|
+
# File.write(formatted_exp_file, result)
|
140
|
+
expected_result = File.read(formatted_exp_file)
|
141
|
+
|
142
|
+
expect(result).to eq(expected_result)
|
143
|
+
|
144
|
+
# Validate Object Space
|
145
|
+
GC.start
|
146
|
+
GC.verify_compaction_references
|
147
|
+
GC.verify_internal_consistency
|
148
|
+
end
|
149
|
+
|
150
|
+
it "exports an object with schema head and hyperlink formatter (multiple.exp)" do |example|
|
151
|
+
print "\n[#{example.description}] "
|
152
|
+
exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
|
153
|
+
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_schema_head_hyperlink_formatted.exp")
|
154
|
+
|
155
|
+
repo = Expressir::Express::Parser.from_file(exp_file)
|
156
|
+
|
157
|
+
formatter = Class.new(Expressir::Express::Formatter) do
|
158
|
+
include Expressir::Express::SchemaHeadFormatter
|
159
|
+
include Expressir::Express::HyperlinkFormatter
|
160
|
+
end
|
161
|
+
result = formatter.format(repo)
|
162
|
+
# File.write(formatted_exp_file, result)
|
163
|
+
expected_result = File.read(formatted_exp_file)
|
164
|
+
|
165
|
+
expect(result).to eq(expected_result)
|
166
|
+
|
167
|
+
# Validate Object Space
|
168
|
+
GC.start
|
169
|
+
GC.verify_compaction_references
|
170
|
+
GC.verify_internal_consistency
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|