diff options
| author | Joel Klinghed <the_jk@opera.com> | 2023-01-23 15:01:32 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@opera.com> | 2023-01-23 15:01:32 +0100 |
| commit | 92cc27f86abfb8ac307801c53b61c9ec4fe4220d (patch) | |
| tree | 93962ce3250457e5dcd82fa4b6ebfd1ca28f5b8c | |
| parent | e66638ce69cfc645739f84c6cbf3488947aca3d0 (diff) | |
Allow partial variant match
Not all subprojects have all the variants that the app project has.
| -rw-r--r-- | bin/flycheck-android-java.py | 17 | ||||
| -rw-r--r-- | bin/flycheck-android-kotlin.py | 17 |
2 files changed, 32 insertions, 2 deletions
diff --git a/bin/flycheck-android-java.py b/bin/flycheck-android-java.py index 37c1b68..3c0912c 100644 --- a/bin/flycheck-android-java.py +++ b/bin/flycheck-android-java.py @@ -120,6 +120,21 @@ Otherwise return None.""" return files[0:i] + files[i + 1:] return None +def split_variant(variant): + ret = [] + last = 0 + for i in range(0, len(variant)): + if variant[i:i+1].isupper(): + ret.append(variant[last:i]) + last = i + ret.append(variant[last:]) + return ret + +def match_variant(variant1, variant2): + v1 = split_variant(variant1) + v2 = split_variant(variant2) + return all(x in v1 for x in v2) or all(x in v2 for x in v1) + def figure_out_java_compilation(sessiondir, sourcefile, tempfile, checkstyle, variant, run_gen, force=False): """Get options for Java compilation from gradle project and run javac.""" @@ -207,7 +222,7 @@ def figure_out_java_compilation(sessiondir, sourcefile, tempfile, checkstyle, if variant: for v in variants: data = v['data'] - if 'variant' in data and data['variant'] == variant: + if 'variant' in data and match_variant(data['variant'], variant): if not fallback: fallback = data files = file_in_list(sourcefile, data['files']) diff --git a/bin/flycheck-android-kotlin.py b/bin/flycheck-android-kotlin.py index a7994c9..8a383db 100644 --- a/bin/flycheck-android-kotlin.py +++ b/bin/flycheck-android-kotlin.py @@ -121,6 +121,21 @@ Otherwise return None.""" return files[0:i] + files[i + 1:] return None +def split_variant(variant): + ret = [] + last = 0 + for i in range(0, len(variant)): + if variant[i:i+1].isupper(): + ret.append(variant[last:i]) + last = i + ret.append(variant[last:]) + return ret + +def match_variant(variant1, variant2): + v1 = split_variant(variant1) + v2 = split_variant(variant2) + return all(x in v1 for x in v2) or all(x in v2 for x in v1) + def figure_out_kotlin_compilation(sessiondir, sourcefile, tempfile, detekt, variant, run_gen, force=False): """Get options for Kotlin compilation from gradle project and run kotlinc.""" @@ -200,7 +215,7 @@ def figure_out_kotlin_compilation(sessiondir, sourcefile, tempfile, detekt, if variant: for v in variants: data = v['data'] - if 'variant' in data and data['variant'] == variant: + if 'variant' in data and match_variant(data['variant'], variant): if not fallback: fallback = data files = file_in_list(sourcefile, data['files']) |
