Skip to content

Commit

Permalink
all: fix compiler warnings about new semver overload operators (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon authored Nov 22, 2023
1 parent 04ee8d8 commit d8abf91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions android/env/env.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
20 changes: 10 additions & 10 deletions android/package.v
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -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:<path>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')
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:<path>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) {
Expand Down Expand Up @@ -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'
}
Expand Down Expand Up @@ -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:<path>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')
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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...')
Expand Down
4 changes: 2 additions & 2 deletions cli/options.v
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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;<version>"`')
Expand Down

0 comments on commit d8abf91

Please sign in to comment.