Skip to content

Commit

Permalink
all: run v fmt -w . in project root (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon authored Aug 11, 2024
1 parent eda8de2 commit e8c308d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 102 deletions.
16 changes: 8 additions & 8 deletions android/compile.v
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ pub fn compile_v_to_c(opt CompileOptions) !VMetaInfo {

v_compile_opt := VCompileOptions{
verbosity: opt.verbosity
cache: opt.cache
flags: opt.v_flags
work_dir: os.join_path(opt.work_dir, 'v')
input: opt.input
cache: opt.cache
flags: opt.v_flags
work_dir: os.join_path(opt.work_dir, 'v')
input: opt.input
}

v_meta_dump := v_dump_meta(v_compile_opt)!
Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn compile(opt CompileOptions) ! {
v_meta_dump := compile_v_to_c(opt) or {
return IError(CompileError{
kind: .v_to_c
err: err.msg()
err: err.msg()
})
}
v_cflags := v_meta_dump.c_flags
Expand Down Expand Up @@ -251,7 +251,7 @@ pub fn compile(opt CompileOptions) ! {
vicd := compile_v_imports_c_dependencies(opt, imported_modules) or {
return IError(CompileError{
kind: .c_to_o
err: err.msg()
err: err.msg()
})
}
mut o_files := vicd.o_files.clone()
Expand Down Expand Up @@ -431,7 +431,7 @@ pub fn compile(opt CompileOptions) ! {
job_util.run_jobs(jobs, opt.parallel, opt.verbosity) or {
return IError(CompileError{
kind: .c_to_o
err: err.msg()
err: err.msg()
})
}
jobs.clear()
Expand Down Expand Up @@ -468,7 +468,7 @@ pub fn compile(opt CompileOptions) ! {
job_util.run_jobs(jobs, opt.parallel, opt.verbosity) or {
return IError(CompileError{
kind: .o_to_so
err: err.msg()
err: err.msg()
})
}

Expand Down
12 changes: 6 additions & 6 deletions android/keystore.v
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub fn resolve_keystore(default_ks Keystore) !Keystore {
}

return Keystore{
path: file
password: password
alias: alias
path: file
password: password
alias: alias
alias_password: alias_password
}
}
Expand Down Expand Up @@ -87,9 +87,9 @@ pub fn generate_debug_keystore(file_path string) !Keystore {
]
util.run_or_error(keytool_cmd)!
return Keystore{
path: file_path
password: password
alias: alias
path: file_path
password: password
alias: alias
alias_password: alias_password
}
}
4 changes: 2 additions & 2 deletions android/ndk/compiler_flags.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub fn compiler_flag_generator(ndk_version string) FlagGen {
pub fn compiler_flags_from_config(ndk_version string, flag_config FlagConfig) !FlagResult {
gen := compiler_flag_generator(ndk_version)
return FlagResult{
flags: gen.flags(flag_config)!
ld_flags: gen.ld_flags(flag_config)!
flags: gen.flags(flag_config)!
ld_flags: gen.ld_flags(flag_config)!
ld_flags_exe: gen.ld_flags_exe(flag_config)!
}
}
Expand Down
50 changes: 25 additions & 25 deletions cli/cli.v
Original file line number Diff line number Diff line change
Expand Up @@ -96,56 +96,56 @@ pub fn args_to_options(arguments []string, defaults Options) !(Options, &flag.Fl

mut opt := Options{
assets_extra: fp.string_multi('assets', `a`, 'Asset dir(s) to include in build')
libs_extra: fp.string_multi('libs', `l`, 'Lib dir(s) to include in build')
v_flags: fp.string_multi('flag', `f`, 'Additional flags for the V compiler')
libs_extra: fp.string_multi('libs', `l`, 'Lib dir(s) to include in build')
v_flags: fp.string_multi('flag', `f`, 'Additional flags for the V compiler')
//
c_flags: fp.string_multi('cflag', `c`, 'Additional flags for the C compiler')
archs: fp.string('archs', 0, defaults.archs.join(','), 'Comma separated string with any of ${android.default_archs}').split(',')
c_flags: fp.string_multi('cflag', `c`, 'Additional flags for the C compiler')
archs: fp.string('archs', 0, defaults.archs.join(','), 'Comma separated string with any of ${android.default_archs}').split(',')
gles_version: fp.int('gles', 0, defaults.gles_version, 'GLES version to use from any of ${android.supported_gles_versions}')
//
device_id: fp.string('device', `d`, defaults.device_id, 'Deploy to device <id>. Use "auto" to use first available.')
run: 'run' in cmd_flags // fp.bool('run', `r`, false, 'Run the app on the device after successful deployment.')
device_log: fp.bool('log', 0, defaults.device_log, 'Enable device logging after deployment.')
device_log_raw: fp.bool('log-raw', 0, defaults.device_log_raw, 'Enable unfiltered, full device logging after deployment.')
device_id: fp.string('device', `d`, defaults.device_id, 'Deploy to device <id>. Use "auto" to use first available.')
run: 'run' in cmd_flags // fp.bool('run', `r`, false, 'Run the app on the device after successful deployment.')
device_log: fp.bool('log', 0, defaults.device_log, 'Enable device logging after deployment.')
device_log_raw: fp.bool('log-raw', 0, defaults.device_log_raw, 'Enable unfiltered, full device logging after deployment.')
clear_device_log: fp.bool('log-clear', 0, defaults.clear_device_log, 'Clear the log buffer on the device before deployment.')
log_tags: fp.string_multi('log-tag', 0, 'Additional tags to include in output when using --log')
log_tags: fp.string_multi('log-tag', 0, 'Additional tags to include in output when using --log')
//
keystore: fp.string('keystore', 0, defaults.keystore, 'Use this keystore file to sign the package')
keystore: fp.string('keystore', 0, defaults.keystore, 'Use this keystore file to sign the package')
keystore_alias: fp.string('keystore-alias', 0, defaults.keystore_alias, 'Use this keystore alias from the keystore file to sign the package')
//
dump_usage: fp.bool('help', `h`, defaults.dump_usage, 'Show this help message and exit')
cache: !fp.bool('nocache', 0, defaults.cache, 'Do not use build cache')
cache: !fp.bool('nocache', 0, defaults.cache, 'Do not use build cache')
//
app_name: fp.string('name', 0, defaults.app_name, 'Pretty app name')
package_id: fp.string('package-id', 0, defaults.package_id, 'App package ID (e.g. "org.company.app")')
app_name: fp.string('name', 0, defaults.app_name, 'Pretty app name')
package_id: fp.string('package-id', 0, defaults.package_id, 'App package ID (e.g. "org.company.app")')
package_overrides_path: fp.string('package-overrides', 0, defaults.package_overrides_path,
'Package file overrides path (e.g. "/tmp/java")')
package_format: fp.string('package', `p`, defaults.package_format, 'App package format. Any of ${android.supported_package_formats}')
activity_name: fp.string('activity-name', 0, defaults.activity_name, 'The name of the main activity (e.g. "VActivity")')
icon: fp.string('icon', 0, defaults.icon, 'App icon')
version_code: fp.int('version-code', 0, defaults.version_code, 'Build version code (android:versionCode)')
activity_name: fp.string('activity-name', 0, defaults.activity_name, 'The name of the main activity (e.g. "VActivity")')
icon: fp.string('icon', 0, defaults.icon, 'App icon')
version_code: fp.int('version-code', 0, defaults.version_code, 'Build version code (android:versionCode)')
//
output: fp.string('output', `o`, defaults.output, 'Path to output (dir/file)')
//
verbosity: verbosity
parallel: !fp.bool('no-parallel', 0, false, 'Do not run tasks in parallel.')
parallel: !fp.bool('no-parallel', 0, false, 'Do not run tasks in parallel.')
//
build_tools: fp.string('build-tools', 0, defaults.build_tools, 'Version of build-tools to use (--list-build-tools)')
api_level: fp.string('api', 0, defaults.api_level, 'Android API level to use (--list-apis)')
build_tools: fp.string('build-tools', 0, defaults.build_tools, 'Version of build-tools to use (--list-build-tools)')
api_level: fp.string('api', 0, defaults.api_level, 'Android API level to use (--list-apis)')
min_sdk_version: fp.int('min-sdk-version', 0, defaults.min_sdk_version, 'Minimum SDK version version code (android:minSdkVersion)')
//
ndk_version: fp.string('ndk-version', 0, defaults.ndk_version, 'Android NDK version to use (--list-ndks)')
//
work_dir: defaults.work_dir
//
list_ndks: fp.bool('list-ndks', 0, defaults.list_ndks, 'List available NDK versions')
list_apis: fp.bool('list-apis', 0, defaults.list_apis, 'List available API levels')
list_ndks: fp.bool('list-ndks', 0, defaults.list_ndks, 'List available NDK versions')
list_apis: fp.bool('list-apis', 0, defaults.list_apis, 'List available API levels')
list_build_tools: fp.bool('list-build-tools', 0, defaults.list_build_tools, 'List available Build-tools versions')
list_devices: fp.bool('list-devices', 0, defaults.list_devices, 'List available device IDs (including running emulators)')
list_devices: fp.bool('list-devices', 0, defaults.list_devices, 'List available device IDs (including running emulators)')
//
screenshot: fp.string('screenshot', 0, '', 'Take a screenshot on a device and save it to /path/to/file.png or /path/to/directory')
screenshot_delay: fp.float('screenshot-delay', 0, 0.0, 'Wait for this amount of seconds before taking screenshot')
screenshot_on_log: fp.string('screenshot-on-log', 0, '', 'Wait for this string to appear in the device log before taking a screenshot')
screenshot: fp.string('screenshot', 0, '', 'Take a screenshot on a device and save it to /path/to/file.png or /path/to/directory')
screenshot_delay: fp.float('screenshot-delay', 0, 0.0, 'Wait for this amount of seconds before taking screenshot')
screenshot_on_log: fp.string('screenshot-on-log', 0, '', 'Wait for this string to appear in the device log before taking a screenshot')
screenshot_on_log_timeout: fp.float('screenshot-on-log-timeout', 0, 0.0, 'Timeout after this amount of seconds if --screenshot-on-log string is not detected')
}

Expand Down
100 changes: 52 additions & 48 deletions cli/options.v
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ pub fn (mut opt Options) resolve(exit_on_error bool) {
// resolve_keystore returns an `android.Keystore` resolved from `Options`.
pub fn (opt &Options) resolve_keystore() !android.Keystore {
mut keystore := android.Keystore{
path: opt.keystore
password: opt.keystore_password
alias: opt.keystore_alias
path: opt.keystore
password: opt.keystore_password
alias: opt.keystore_alias
alias_password: opt.keystore_alias_password
}
if !os.is_file(keystore.path) {
Expand Down Expand Up @@ -508,19 +508,23 @@ pub fn (opt &Options) as_android_deploy_options() !android.DeployOptions {

deploy_opt := android.DeployOptions{
verbosity: opt.verbosity
format: format
format: format
// keystore: keystore
activity_name: opt.activity_name
work_dir: opt.work_dir
v_flags: opt.v_flags
device_id: opt.device_id
deploy_file: opt.output
kill_adb: os.getenv('VAB_KILL_ADB') != ''
activity_name: opt.activity_name
work_dir: opt.work_dir
v_flags: opt.v_flags
device_id: opt.device_id
deploy_file: opt.output
kill_adb: os.getenv('VAB_KILL_ADB') != ''
clear_device_log: opt.clear_device_log
device_log: opt.device_log || opt.device_log_raw
log_mode: if opt.device_log_raw { android.LogMode.raw } else { android.LogMode.filtered }
device_log: opt.device_log || opt.device_log_raw
log_mode: if opt.device_log_raw {
android.LogMode.raw
} else {
android.LogMode.filtered
}
log_tags: log_tags
run: run
run: run
}

return deploy_opt
Expand All @@ -529,19 +533,19 @@ pub fn (opt &Options) as_android_deploy_options() !android.DeployOptions {
// as_android_compile_options returns `android.CompileOptions` based on the fields in `Options`.
pub fn (opt &Options) as_android_compile_options() android.CompileOptions {
comp_opt := android.CompileOptions{
verbosity: opt.verbosity
cache: opt.cache
parallel: opt.parallel
is_prod: opt.is_prod
gles_version: opt.gles_version
v_flags: opt.v_flags
c_flags: opt.c_flags
archs: opt.archs
work_dir: opt.work_dir
input: opt.input
ndk_version: opt.ndk_version
lib_name: opt.lib_name
api_level: opt.api_level
verbosity: opt.verbosity
cache: opt.cache
parallel: opt.parallel
is_prod: opt.is_prod
gles_version: opt.gles_version
v_flags: opt.v_flags
c_flags: opt.c_flags
archs: opt.archs
work_dir: opt.work_dir
input: opt.input
ndk_version: opt.ndk_version
lib_name: opt.lib_name
api_level: opt.api_level
min_sdk_version: opt.min_sdk_version
}
return comp_opt
Expand All @@ -560,26 +564,26 @@ pub fn (opt &Options) as_android_package_options() android.PackageOptions {
}

pck_opt := android.PackageOptions{
verbosity: opt.verbosity
work_dir: opt.work_dir
is_prod: opt.is_prod
api_level: opt.api_level
verbosity: opt.verbosity
work_dir: opt.work_dir
is_prod: opt.is_prod
api_level: opt.api_level
min_sdk_version: opt.min_sdk_version
gles_version: opt.gles_version
build_tools: opt.build_tools
app_name: opt.app_name
lib_name: opt.lib_name
package_id: opt.package_id
format: format
activity_name: opt.activity_name
icon: opt.icon
version_code: opt.version_code
v_flags: opt.v_flags
input: opt.input
assets_extra: opt.assets_extra
libs_extra: opt.libs_extra
output_file: opt.output
overrides_path: opt.package_overrides_path
gles_version: opt.gles_version
build_tools: opt.build_tools
app_name: opt.app_name
lib_name: opt.lib_name
package_id: opt.package_id
format: format
activity_name: opt.activity_name
icon: opt.icon
version_code: opt.version_code
v_flags: opt.v_flags
input: opt.input
assets_extra: opt.assets_extra
libs_extra: opt.libs_extra
output_file: opt.output
overrides_path: opt.package_overrides_path
}
return pck_opt
}
Expand All @@ -588,9 +592,9 @@ pub fn (opt &Options) as_android_package_options() android.PackageOptions {
pub fn (opt &Options) as_android_screenshot_options(deploy_opts android.DeployOptions) android.ScreenshotOptions {
screenshot_opt := android.ScreenshotOptions{
deploy_options: deploy_opts
path: opt.screenshot
delay: opt.screenshot_delay
on_log: opt.screenshot_on_log
path: opt.screenshot
delay: opt.screenshot_delay
on_log: opt.screenshot_on_log
on_log_timeout: opt.screenshot_on_log_timeout
}
return screenshot_opt
Expand Down
6 changes: 3 additions & 3 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ compiler := ndk.compiler(.c, ndk_version, 'arm64-v8a', '21') or { panic(err) }
// Get recommended, Android specific, flags (also used by e.g. Gradle) for the compiler
// Make sure they fit the compiler you're targeting.
compiler_flags := ndk.compiler_flags_from_config(ndk_version,
arch: 'arm64-v8a'
lang: .c
debug: true // false = if you want production flags (-prod)
arch: 'arm64-v8a'
lang: .c
debug: true // false = if you want production flags (-prod)
cpp_features: ['no-rtti', 'no-exceptions'] // Special features available for C++ compilers, ignored for C compilers
) or { panic(err) }
Expand Down
14 changes: 7 additions & 7 deletions tests/vab_error_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ fn sync_run(job TOMLTestJob) &TOMLTestJobResult {
}

return &TOMLTestJobResult{
success: success
job: job
command: execute
expected: expected
expected_out_path: expected_out_path
found: found
success: success
job: job
command: execute
expected: expected
expected_out_path: expected_out_path
found: found
expected_exit_code: expect_exit_code
exit_code: res.exit_code
exit_code: res.exit_code
}
}

Expand Down
2 changes: 1 addition & 1 deletion util/shelljob.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn sync_run(job ShellJob) &ShellJobResult {
}
res := run(job.cmd)
return &ShellJobResult{
job: job
job: job
result: res
}
}
Expand Down
4 changes: 2 additions & 2 deletions vab.v
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ fn main() {
android.simple_screenshot(
verbosity: opt.verbosity
device_id: opt.device_id
path: opt.screenshot
delay: opt.screenshot_delay
path: opt.screenshot
delay: opt.screenshot_delay
) or {
eprintln('Failed to take screenshot:\n${err}')
exit(1)
Expand Down

0 comments on commit e8c308d

Please sign in to comment.