mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix warnings/errors due to the vfmt change
This commit is contained in:
@@ -5,7 +5,7 @@ import flag
|
||||
import strings
|
||||
|
||||
const (
|
||||
tool_version = '0.0.4'
|
||||
tool_version = '0.0.4'
|
||||
tool_description = 'Converts a list of arbitrary files into a single v module file.'
|
||||
)
|
||||
|
||||
@@ -20,29 +20,26 @@ mut:
|
||||
|
||||
fn (context Context) header() string {
|
||||
mut header_s := ''
|
||||
header_s += 'module ${context.module_name}\n'
|
||||
header_s += 'module $context.module_name\n'
|
||||
header_s += '\n'
|
||||
allfiles := context.files.join(' ')
|
||||
|
||||
mut options := []string{}
|
||||
if context.prefix.len > 0 {
|
||||
options << '-p ${context.prefix}'
|
||||
options << '-p $context.prefix'
|
||||
}
|
||||
if context.module_name.len > 0 {
|
||||
options << '-m ${context.module_name}'
|
||||
options << '-m $context.module_name'
|
||||
}
|
||||
if context.write_file.len > 0 {
|
||||
options << '-w ${context.write_file}'
|
||||
options << '-w $context.write_file'
|
||||
}
|
||||
soptions := options.join(' ')
|
||||
|
||||
header_s += '// File generated by:\n'
|
||||
header_s += '// v bin2v ${allfiles} ${soptions}\n'
|
||||
header_s += '// v bin2v $allfiles $soptions\n'
|
||||
header_s += '// Please, do not edit this file.\n'
|
||||
header_s += '// Your changes may be overwritten.\n'
|
||||
header_s += '\n'
|
||||
header_s += 'const (\n'
|
||||
|
||||
return header_s
|
||||
}
|
||||
|
||||
@@ -54,14 +51,14 @@ fn (context Context) file2v(file string) string {
|
||||
mut sb := strings.new_builder(1000)
|
||||
fname := os.file_name(file)
|
||||
fname_no_dots := fname.replace('.', '_')
|
||||
byte_name := '${context.prefix}${fname_no_dots}'.to_lower()
|
||||
byte_name := '$context.prefix$fname_no_dots'.to_lower()
|
||||
fbytes := os.read_bytes(file) or {
|
||||
eprintln('Error: $err')
|
||||
return ''
|
||||
}
|
||||
fbyte := fbytes[0]
|
||||
sb.write(' ${byte_name}_len = ${fbytes.len}\n')
|
||||
sb.write(' ${byte_name} = [ byte(${fbyte}), \n ')
|
||||
sb.write(' ${byte_name}_len = $fbytes.len\n')
|
||||
sb.write(' $byte_name = [ byte($fbyte), \n ')
|
||||
for i := 1; i < fbytes.len; i++ {
|
||||
b := int(fbytes[i]).str()
|
||||
sb.write('${b:4s}, ')
|
||||
@@ -71,7 +68,6 @@ fn (context Context) file2v(file string) string {
|
||||
}
|
||||
sb.write('\n]!!\n')
|
||||
sb.write('\n')
|
||||
|
||||
return sb.str()
|
||||
}
|
||||
|
||||
@@ -100,19 +96,19 @@ fn main() {
|
||||
exit(0)
|
||||
}
|
||||
context.files = real_files
|
||||
|
||||
if !context.write_file.ends_with('.v') {
|
||||
context.write_file += '.v'
|
||||
}
|
||||
if context.write_file.len > 0 {
|
||||
mut out_file := os.create(context.write_file) or { panic(err) }
|
||||
mut out_file := os.create(context.write_file) or {
|
||||
panic(err)
|
||||
}
|
||||
out_file.write(context.header())
|
||||
for file in real_files {
|
||||
out_file.write(context.file2v(file))
|
||||
}
|
||||
out_file.write(context.footer())
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
println(context.header())
|
||||
for file in real_files {
|
||||
println(context.file2v(file))
|
||||
|
||||
Reference in New Issue
Block a user