From 37ef5bfdde90187174f56a02ac2700703c46c226 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Tue, 7 Feb 2023 17:20:39 -0600 Subject: [PATCH] Replace dashes in Java package names with underscores when generating native headers This was causing a ninja issue where the native headers were always being generated because io.github.hse-project.hse_Hse.h was being expected, but io.github.hse_project.hse_Hse.h was actually generated. --- mesonbuild/modules/java.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/modules/java.py b/mesonbuild/modules/java.py index 792d70b91..6861ee0a7 100644 --- a/mesonbuild/modules/java.py +++ b/mesonbuild/modules/java.py @@ -75,13 +75,16 @@ class JavaModule(NewExtensionModule): classes = T.cast('T.List[str]', kwargs.get('classes')) package = kwargs.get('package') + if package: + sanitized_package = package.replace("-", "_").replace(".", "_") + headers: T.List[str] = [] for clazz in classes: - underscore_clazz = clazz.replace(".", "_") + sanitized_clazz = clazz.replace(".", "_") if package: - headers.append(f'{package.replace(".", "_")}_{underscore_clazz}.h') + headers.append(f'{sanitized_package}_{sanitized_clazz}.h') else: - headers.append(f'{underscore_clazz}.h') + headers.append(f'{sanitized_clazz}.h') javac = self.__get_java_compiler(state)