From e8c308dc31157b5dd786b143a67413c2d2f955d0 Mon Sep 17 00:00:00 2001 From: larpon <768942+larpon@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:43:51 +0200 Subject: [PATCH] all: run `v fmt -w .` in project root (#287) --- android/compile.v | 16 +++--- android/keystore.v | 12 ++--- android/ndk/compiler_flags.v | 4 +- cli/cli.v | 50 +++++++++--------- cli/options.v | 100 ++++++++++++++++++----------------- docs/docs.md | 6 +-- tests/vab_error_test.v | 14 ++--- util/shelljob.v | 2 +- vab.v | 4 +- 9 files changed, 106 insertions(+), 102 deletions(-) diff --git a/android/compile.v b/android/compile.v index 75a7f290..6460d616 100644 --- a/android/compile.v +++ b/android/compile.v @@ -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)! @@ -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 @@ -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() @@ -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() @@ -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() }) } diff --git a/android/keystore.v b/android/keystore.v index e54115d0..dfdcaec2 100644 --- a/android/keystore.v +++ b/android/keystore.v @@ -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 } } @@ -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 } } diff --git a/android/ndk/compiler_flags.v b/android/ndk/compiler_flags.v index 992a21eb..206d4645 100644 --- a/android/ndk/compiler_flags.v +++ b/android/ndk/compiler_flags.v @@ -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)! } } diff --git a/cli/cli.v b/cli/cli.v index f98871ec..2d95f1ea 100644 --- a/cli/cli.v +++ b/cli/cli.v @@ -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 . 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 . 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') } diff --git a/cli/options.v b/cli/options.v index 68362c18..e34e99b8 100644 --- a/cli/options.v +++ b/cli/options.v @@ -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) { @@ -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 @@ -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 @@ -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 } @@ -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 diff --git a/docs/docs.md b/docs/docs.md index 64310cb8..bf044fa5 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -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) } diff --git a/tests/vab_error_test.v b/tests/vab_error_test.v index e3bba1ba..ccbf142c 100644 --- a/tests/vab_error_test.v +++ b/tests/vab_error_test.v @@ -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 } } diff --git a/util/shelljob.v b/util/shelljob.v index 306c7a30..4cb09357 100644 --- a/util/shelljob.v +++ b/util/shelljob.v @@ -43,7 +43,7 @@ fn sync_run(job ShellJob) &ShellJobResult { } res := run(job.cmd) return &ShellJobResult{ - job: job + job: job result: res } } diff --git a/vab.v b/vab.v index 109ed17a..25b10f07 100644 --- a/vab.v +++ b/vab.v @@ -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)