Skip to content

Commit

Permalink
Merge branch 'topic/install_java_sources' into 'master'
Browse files Browse the repository at this point in the history
Install the Java bindings sources unconditionally

Closes AdaCore#654

See merge request eng/libadalang/langkit!834
  • Loading branch information
HugoGGuerrier committed Apr 17, 2023
2 parents 4ad4929 + 8b01fd6 commit ccf8711
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 1 addition & 3 deletions langkit/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def __init__(self,
self.lib_name_low
)
self.java_jni = path.join(self.java_dir, "jni")
self.java_native_config = path.join(self.java_dir, "native_image")

self.lib_project = path.join(self.lib_root, f"{self.lib_name_low}.gpr")
self.mains_project = path.join(self.lib_root, "mains.gpr")
Expand Down Expand Up @@ -322,7 +321,6 @@ def setup_directories(self, ctx: CompileCtx) -> None:
self.java_dir,
self.java_package,
self.java_jni,
self.java_native_config,
]:
if not path.exists(d):
os.makedirs(d)
Expand Down Expand Up @@ -750,7 +748,7 @@ def emit_java_api(self, ctx: CompileCtx) -> None:
(
"java_api/reflect_json",
"reflect_config.json",
self.java_native_config,
self.java_dir,
None
),
(
Expand Down
23 changes: 9 additions & 14 deletions langkit/libmanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ def do_install(self, args: argparse.Namespace) -> None:
build_mode = self.build_modes[0].value

lib_name = self.lib_name.lower()
lib_name_camel = lib_name.capitalize()

self.gprinstall(
args,
Expand Down Expand Up @@ -1244,6 +1245,14 @@ def do_install(self, args: argparse.Namespace) -> None:
os.path.join('ocaml', 'dune'),
os.path.join('ocaml', 'dune-project'),
os.path.join('ocaml', lib_name + '.opam'),
os.path.join('java', 'Makefile'),
os.path.join('java', 'pom.xml'),
os.path.join('java', 'reflect_config.json'),
os.path.join('java', 'jni',
f'com_adacore_{lib_name}_{lib_name_camel}_NI_LIB.h'),
os.path.join('java', 'jni', 'jni_impl.c'),
os.path.join('java', 'src', 'main', 'java', 'com', 'adacore',
lib_name, f'{lib_name_camel}.java'),
]:
install_path = os.path.dirname(self.dirs.install_dir(fpath))
if not path.isdir(install_path):
Expand All @@ -1254,20 +1263,6 @@ def do_install(self, args: argparse.Namespace) -> None:
f, os.path.join(install_path, os.path.basename(f))
)

# If Java is enabled, install using Maven
if args.enable_java:
# Install the Java bindings in the Maven repository
self.maven_command(['install'], args)

# Put the bindings JAR in the installation folder
jar_name = f'{lib_name}.jar'
jar_file = self.dirs.build_dir('java', 'target', jar_name)
install_file = self.dirs.install_dir('java', jar_name)
install_path = os.path.dirname(install_file)
if not path.isdir(install_path):
os.makedirs(install_path)
shutil.copyfile(jar_file, install_file)

def do_setenv(self, args: argparse.Namespace) -> None:
"""
Unless --json is passed, display Bourne shell commands that setup
Expand Down

0 comments on commit ccf8711

Please sign in to comment.