From d8abf91fdf5ffeb17ef0f9433b858656d67832f1 Mon Sep 17 00:00:00 2001 From: Larpon Date: Wed, 22 Nov 2023 08:45:51 +0100 Subject: [PATCH] all: fix compiler warnings about new `semver` overload operators (#274) --- android/env/env.v | 4 ++-- android/package.v | 20 ++++++++++---------- cli/options.v | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/android/env/env.v b/android/env/env.v index 52628770..40985485 100644 --- a/android/env/env.v +++ b/android/env/env.v @@ -316,7 +316,7 @@ fn install_opt(opt InstallOptions) !bool { if version_check != '' { sv_check := semver.from(version_check) or { panic(err) } comp_sv := semver.from(ndk.min_supported_version) or { panic(err) } - if sv_check.lt(comp_sv) { + if sv_check < comp_sv { eprintln('Notice: Skipping install. NDK ${item} is lower than supported ${ndk.min_supported_version}...') return true } @@ -341,7 +341,7 @@ fn install_opt(opt InstallOptions) !bool { if version_check != '' { sv_check := semver.from(version_check) or { panic(err) } comp_sv := semver.from(sdk.min_supported_build_tools_version) or { panic(err) } - if sv_check.lt(comp_sv) { + if sv_check < comp_sv { eprintln('Notice: Skipping install. build-tools "${item}" is lower than supported ${sdk.min_supported_build_tools_version}...') return true } diff --git a/android/package.v b/android/package.v index 66f4b433..257c193a 100644 --- a/android/package.v +++ b/android/package.v @@ -201,7 +201,7 @@ fn package_apk(opt PackageOptions) ! { mut javac_source_version := '1.7' mut javac_target_version := '1.7' - if jdk_semantic_version.ge(semver.build(20, 0, 0)) { + if jdk_semantic_version >= semver.build(20, 0, 0) { javac_source_version = '1.8' javac_target_version = '1.8' } @@ -230,7 +230,7 @@ fn package_apk(opt PackageOptions) ! { // TODO Workaround dx and Java > 8 (1.8.0) BUG // Error message we are trying to prevent: // -Djava.ext.dirs=C:lib is not supported. Use -classpath instead. - if jdk_semantic_version.gt(semver.build(1, 8, 0)) { + if jdk_semantic_version > semver.build(1, 8, 0) { if os.exists(dx) { mut patched_dx := os.join_path(os.dir(dx), os.file_name(dx).all_before_last('.') + '_patched.bat') @@ -271,7 +271,7 @@ fn package_apk(opt PackageOptions) ! { } // Dex either with `dx` or `d8` - if build_tools_semantic_version.ge(semver.build(28, 0, 1)) { + if build_tools_semantic_version >= semver.build(28, 0, 1) { mut class_files := os.walk_ext('obj', '.class') class_files = class_files.map(fn (e string) string { $if windows { @@ -411,7 +411,7 @@ fn package_apk(opt PackageOptions) ! { // TODO Workaround apksigner and Java > 8 (1.8.0) BUG // Error message we are trying to prevent: // -Djava.ext.dirs=C:lib is not supported. Use -classpath instead. - if jdk_semantic_version.gt(semver.build(1, 8, 0)) && os.exists(apksigner) { + if jdk_semantic_version > semver.build(1, 8, 0) && os.exists(apksigner) { mut patched_apksigner := os.join_path(os.dir(apksigner), os.file_name(apksigner).all_before_last('.') + '_patched.bat') if !os.exists(patched_apksigner) { @@ -644,7 +644,7 @@ fn package_aab(opt PackageOptions) ! { mut javac_source_version := '1.7' mut javac_target_version := '1.7' - if jdk_semantic_version.ge(semver.build(20, 0, 0)) { + if jdk_semantic_version >= semver.build(20, 0, 0) { javac_source_version = '1.8' javac_target_version = '1.8' } @@ -732,7 +732,7 @@ fn package_aab(opt PackageOptions) ! { // TODO Workaround dx and Java > 8 (1.8.0) BUG // Error message we are trying to prevent: // -Djava.ext.dirs=C:lib is not supported. Use -classpath instead. - if jdk_semantic_version.gt(semver.build(1, 8, 0)) { + if jdk_semantic_version > semver.build(1, 8, 0) { if os.exists(dx) { mut patched_dx := os.join_path(os.dir(dx), os.file_name(dx).all_before_last('.') + '_patched.bat') @@ -778,7 +778,7 @@ fn package_aab(opt PackageOptions) ! { } // Dex either with `dx` or `d8` - if build_tools_semantic_version.ge(semver.build(28, 0, 1)) { + if build_tools_semantic_version >= semver.build(28, 0, 1) { mut class_files := os.walk_ext('classes', '.class') class_files = class_files.filter(!it.contains('$')) // Filter out R$xxx.class files class_files = class_files.map(fn (e string) string { @@ -832,9 +832,9 @@ fn package_aab(opt PackageOptions) ! { // com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: File 'base.zip' does not seem to be a valid ZIP file. // ... // Caused by: java.util.zip.ZipException: invalid CEN header (bad signature) - if jdk_semantic_version.le(semver.build(1, 8, 0)) - || (jdk_semantic_version.ge(semver.build(20, 0, 0)) - && jdk_semantic_version.lt(semver.build(21, 0, 0))) { + if jdk_semantic_version <= semver.build(1, 8, 0) + || (jdk_semantic_version >= semver.build(20, 0, 0) + && jdk_semantic_version < semver.build(21, 0, 0)) { $if !windows { if opt.verbosity > 1 { println('Working around Java/bundletool/ZIP64 BUG...') diff --git a/cli/options.v b/cli/options.v index 91196cba..68362c18 100644 --- a/cli/options.v +++ b/cli/options.v @@ -215,7 +215,7 @@ pub fn (opt &Options) validate_env() { panic(@MOD + '.' + @FN + ':' + @LINE + ' error converting jdk_version "${jdk_version}" to semantic version.\nsemver: ${err}') } - if !jdk_semantic_version.ge(semver.build(1, 8, 0)) { // NOTE When did this break:.satisfies('1.8.*') ??? + if !(jdk_semantic_version >= semver.build(1, 8, 0)) { // NOTE When did this break:.satisfies('1.8.*') ??? // Some Android tools like `sdkmanager` in cmdline-tools;1.0 only worked with Java 8 JDK (1.8.x). // (Absolute mess, yes) eprintln('Java JDK version ${jdk_version} is not supported') @@ -254,7 +254,7 @@ pub fn (opt &Options) validate_env() { // The NDK version is sniffed from the directory it resides in (which can be anything) // So we only report back if the verion can be read if ndk_semantic_version := semver.from(opt.ndk_version) { - if ndk_semantic_version.lt(semver.build(21, 1, 0)) { + if ndk_semantic_version < semver.build(21, 1, 0) { eprintln('Android NDK >= 21.1.x is currently needed. "${opt.ndk_version}" is too low.') eprintln('Please provide a valid path via ANDROID_NDK_ROOT') eprintln('or run `${exe_short_name} install "ndk;"`')