Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#685: Update bazel #439

Merged
merged 25 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/check_bazel_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
sudo apt-get install -y openjdk-11-jdk libzmq3-dev
- name: Java Tests
run: |
export USE_BAZEL_VERSION=6.4.0
export USE_BAZEL_VERSION=7.2.1
bazel test //javacontainer/test/...
working-directory: ./exaudfclient/base
- name: ExaudfLib Tests
run: |
export USE_BAZEL_VERSION=6.4.0
export USE_BAZEL_VERSION=7.2.1
bazel test //exaudflib/test/...
working-directory: ./exaudfclient/base

3 changes: 2 additions & 1 deletion exaudfclient/base/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ bazel-out
bazel-src
bazel-testlogs
graph.in
graph.png
graph.png
MODULE.bazel.lock
58 changes: 58 additions & 0 deletions exaudfclient/base/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################

module(name="exaudfclient", version = "1.0")

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "googletest", version = "1.15.0")
bazel_dep(name = "rules_java", version = "6.1.1")
bazel_dep(name = "rules_jvm_external", version = "6.2")

python_local_repository = use_repo_rule("//:python_repository.bzl", "python_local_repository")
python_local_repository(name = "python3", python_version="python3")

numpy_local_repository = use_repo_rule("//:python_repository.bzl", "numpy_local_repository")

numpy_local_repository(name = "numpy")

zmq_local_repository = use_repo_rule("//:zmq_repository.bzl", "zmq_local_repository")
zmq_local_repository(name = "zmq")

protobuf_local_repository = use_repo_rule("//:protobuf_repository.bzl", "protobuf_local_repository")
protobuf_local_repository(name = "protobuf")


new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")

new_local_repository(
name = "ssl",
build_file_content = """
cc_library(
name = "ssl",
srcs = ["usr/lib/x86_64-linux-gnu/libssl.so","usr/lib/x86_64-linux-gnu/libcrypto.so"],
hdrs = glob(["usr/include/openssl/*.h"]),
includes = ["usr/include/openssl"],
visibility = ["//visibility:public"]
)
""",
path = "/",
)


java_local_repository = use_repo_rule("//:java_repository.bzl", "java_local_repository")
java_local_repository(name = "java")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"com.exasol:udf-api-java:1.0.5",
],
repositories = [
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "maven")
81 changes: 0 additions & 81 deletions exaudfclient/base/WORKSPACE

This file was deleted.

4 changes: 2 additions & 2 deletions exaudfclient/base/java_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def _java_local_repository_impl(repository_ctx):
defines = '"ENABLE_JAVA_VM"'
build_file_content = """
cc_library(
name = "{name}",
name = "java",
srcs = glob(["{prefix}/include/*.h"], allow_empty=False),
hdrs = glob(["{prefix}/include/*.h","{prefix}/include/linux/*.h"], allow_empty=False),
includes = ["{prefix}/include","{prefix}/include/linux"],
defines = [{defines}],
linkopts = ["-ljvm","-L{rpath_libjvm}",'-Wl,-rpath','{rpath_libjvm}'],
visibility = ["//visibility:public"]
)""".format( name=repository_ctx.name, defines=defines, prefix="java", rpath_libjvm=path_to_libjvm)
)""".format( defines=defines, prefix="java", rpath_libjvm=path_to_libjvm)
print(build_file_content)

repository_ctx.symlink(prefix, "./java")
Expand Down
150 changes: 101 additions & 49 deletions exaudfclient/base/javacontainer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,40 @@ package(default_visibility = ["//visibility:public"])
genrule(
name = "exascript_java_tmp_cc",
cmd = """
mkdir -p $(location java_src)/com/exasol/swig
mkdir -p java_src/com/exasol/swig
mkdir -p build_exascript_java_tmp_cc/exaudflib
cp "$(location //exaudflib:swig/script_data_transfer_objects_wrapper.h)" "$(location //exaudflib:exascript.i)" build_exascript_java_tmp_cc/exaudflib
cd build_exascript_java_tmp_cc
swig -v -O -DEXTERNAL_PROCESS -Wall -c++ -java -addextern -module exascript_java -package com.exasol.swig -outdir "../$(location java_src)/com/exasol/swig" -o "../$(location exascript_java_tmp.cc)" exaudflib/exascript.i
""",
outs = ["exascript_java_tmp.cc","java_src"],
cd build_exascript_java_tmp_cc
swig -v -O -DEXTERNAL_PROCESS -Wall -c++ -java -addextern -module exascript_java -package com.exasol.swig -outdir "../java_src/com/exasol/swig" -o "../exascript_java_tmp.cc" exaudflib/exascript.i
cd ..
cp java_src/com/exasol/swig/ConnectionInformationWrapper.java $(location orig/com/exasol/swig/ConnectionInformationWrapper.java)
cp java_src/com/exasol/swig/exascript_java.java $(location orig/com/exasol/swig/exascript_java.java)
cp java_src/com/exasol/swig/exascript_javaJNI.java $(location orig/com/exasol/swig/exascript_javaJNI.java)
cp java_src/com/exasol/swig/ExportSpecificationWrapper.java $(location orig/com/exasol/swig/ExportSpecificationWrapper.java)
cp java_src/com/exasol/swig/ImportSpecificationWrapper.java $(location orig/com/exasol/swig/ImportSpecificationWrapper.java)
cp java_src/com/exasol/swig/Metadata.java $(location orig/com/exasol/swig/Metadata.java)
cp java_src/com/exasol/swig/ResultHandler.java $(location orig/com/exasol/swig/ResultHandler.java)
cp java_src/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java $(location orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java)
cp java_src/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java $(location orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java)
cp java_src/com/exasol/swig/SWIGVM_datatype_e.java $(location orig/com/exasol/swig/SWIGVM_datatype_e.java)
cp java_src/com/exasol/swig/SWIGVM_itertype_e.java $(location orig/com/exasol/swig/SWIGVM_itertype_e.java)
cp java_src/com/exasol/swig/TableIterator.java $(location orig/com/exasol/swig/TableIterator.java)
cp exascript_java_tmp.cc $(location exascript_java_tmp.cc)
""",
outs = ["orig/com/exasol/swig/ConnectionInformationWrapper.java",
"orig/com/exasol/swig/exascript_java.java",
"orig/com/exasol/swig/exascript_javaJNI.java",
"orig/com/exasol/swig/ExportSpecificationWrapper.java",
"orig/com/exasol/swig/ImportSpecificationWrapper.java",
"orig/com/exasol/swig/Metadata.java",
"orig/com/exasol/swig/ResultHandler.java",
"orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java",
"orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java",
"orig/com/exasol/swig/SWIGVM_datatype_e.java",
"orig/com/exasol/swig/SWIGVM_itertype_e.java",
"orig/com/exasol/swig/TableIterator.java",
"exascript_java_tmp.cc"
],
srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h"]
)

Expand All @@ -18,25 +45,14 @@ genrule(
cmd = """
mkdir build_exascript_java_tmp_h
cp "$(location //exaudflib:swig/script_data_transfer_objects_wrapper.h)" "$(location //exaudflib:exascript.i)" build_exascript_java_tmp_h
cp -r "$(location exascript_java_tmp.cc)" "$(location java_src)" build_exascript_java_tmp_h
cp -r "$(location exascript_java_tmp.cc)" build_exascript_java_tmp_h
cd build_exascript_java_tmp_h
swig -v -DEXTERNAL_PROCESS -c++ -java -external-runtime "../$(location exascript_java_tmp.h)"
""",
outs = ["exascript_java_tmp.h"],
srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h", ":exascript_java_tmp.cc", ":java_src"]
srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h", ":exascript_java_tmp.cc"]
)

genrule(
name = "exascript_java_int",
cmd = """
cp -r $(locations :exascript_java_tmp_cc) .
FILES=`ls java_src/com/exasol/swig/*.java`
python3 $(location //:build_integrated.py) "$(location exascript_java_int.h)" $$FILES
""",
outs = ["exascript_java_int.h"],
srcs = [":exascript_java_tmp_cc"],
tools = ["//:build_integrated.py"]
)

genrule(
name = "filter_swig_code_exascript_java_h",
Expand All @@ -50,26 +66,49 @@ genrule(
name = "filter_swig_code_exascript_java_cc",
cmd = """
TMPDIR=`mktemp -d`
cp -r -L $(location //:filter_swig_code.py) $(locations :exascript_java_tmp_cc) $$TMPDIR
(cd $$TMPDIR &&
mkdir -p "$$TMPDIR"/java_src/com/exasol/swig
cp $(location :orig/com/exasol/swig/TableIterator.java) "$$TMPDIR"/java_src/com/exasol/swig/
cp $(location :orig/com/exasol/swig/ResultHandler.java) "$$TMPDIR"/java_src/com/exasol/swig/
cp $(location :orig/com/exasol/swig/exascript_javaJNI.java) "$$TMPDIR"/java_src/com/exasol/swig/
find "$$TMPDIR"/java_src/com/exasol/swig/ -name *.java -type f -exec chmod 644 {} \\;
cp -r -L $(location //:filter_swig_code.py) $(location :exascript_java_tmp.cc) "$$TMPDIR"
(cd "$$TMPDIR"
python3 filter_swig_code.py "exascript_java.cc" "exascript_java_tmp.cc")
cp $$TMPDIR/exascript_java.cc "$(location exascript_java.cc)"
cp -r $$TMPDIR/java_src/com/exasol/swig/ConnectionInformationWrapper.java "$(location ConnectionInformationWrapper.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/exascript_java.java "$(location exascript_java.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/exascript_javaJNI.java "$(location exascript_javaJNI.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/ExportSpecificationWrapper.java "$(location ExportSpecificationWrapper.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/ImportSpecificationWrapper.java "$(location ImportSpecificationWrapper.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/Metadata.java "$(location Metadata.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/ResultHandler.java "$(location ResultHandler.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java "$(location SWIGTYPE_p_ExecutionGraph__ExportSpecification.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java "$(location SWIGTYPE_p_ExecutionGraph__ImportSpecification.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/SWIGVM_datatype_e.java "$(location SWIGVM_datatype_e.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/SWIGVM_itertype_e.java "$(location SWIGVM_itertype_e.java)"
cp -r $$TMPDIR/java_src/com/exasol/swig/TableIterator.java "$(location TableIterator.java)"
rm -rf $$TMPDIR
cp "$$TMPDIR"/exascript_java.cc $(location :exascript_java.cc)
cp "$$TMPDIR"/java_src/com/exasol/swig/TableIterator.java $(location :filtered/com/exasol/swig/TableIterator.java)
cp "$$TMPDIR"/java_src/com/exasol/swig/ResultHandler.java $(location :filtered/com/exasol/swig/ResultHandler.java)
cp "$$TMPDIR"/java_src/com/exasol/swig/exascript_javaJNI.java $(location :filtered/com/exasol/swig/exascript_javaJNI.java)
rm -rf "$$TMPDIR"
""",
outs = [
"exascript_java.cc",
"filtered/com/exasol/swig/TableIterator.java",
"filtered/com/exasol/swig/ResultHandler.java",
"filtered/com/exasol/swig/exascript_javaJNI.java"
],
srcs = [":exascript_java_tmp.cc", ":orig/com/exasol/swig/TableIterator.java",
":orig/com/exasol/swig/ResultHandler.java", ":orig/com/exasol/swig/exascript_javaJNI.java"],
tools = ["//:filter_swig_code.py"]
)


genrule(
name = "finish_java_package",
tomuben marked this conversation as resolved.
Show resolved Hide resolved
cmd = """
cp $(location filtered/com/exasol/swig/TableIterator.java) $(location TableIterator.java)
cp $(location filtered/com/exasol/swig/ResultHandler.java) $(location ResultHandler.java)
cp $(location filtered/com/exasol/swig/exascript_javaJNI.java) $(location exascript_javaJNI.java)
cp $(location orig/com/exasol/swig/ConnectionInformationWrapper.java) $(location ConnectionInformationWrapper.java)
cp $(location orig/com/exasol/swig/exascript_java.java) $(location exascript_java.java)
cp $(location orig/com/exasol/swig/ExportSpecificationWrapper.java) $(location ExportSpecificationWrapper.java)
cp $(location orig/com/exasol/swig/ImportSpecificationWrapper.java) $(location ImportSpecificationWrapper.java)
cp $(location orig/com/exasol/swig/Metadata.java) $(location Metadata.java)
cp $(location orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java) $(location SWIGTYPE_p_ExecutionGraph__ExportSpecification.java)
cp $(location orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java) $(location SWIGTYPE_p_ExecutionGraph__ImportSpecification.java)
cp $(location orig/com/exasol/swig/SWIGVM_datatype_e.java) $(location SWIGVM_datatype_e.java)
cp $(location orig/com/exasol/swig/SWIGVM_itertype_e.java) $(location SWIGVM_itertype_e.java)
""",
outs = [
"ConnectionInformationWrapper.java",
"exascript_java.java",
"exascript_javaJNI.java",
Expand All @@ -83,13 +122,26 @@ genrule(
"SWIGVM_itertype_e.java",
"TableIterator.java",
],
srcs = [":exascript_java_tmp_cc"],
srcs = [
"filtered/com/exasol/swig/TableIterator.java",
"filtered/com/exasol/swig/ResultHandler.java",
"filtered/com/exasol/swig/exascript_javaJNI.java",
"orig/com/exasol/swig/ConnectionInformationWrapper.java",
"orig/com/exasol/swig/exascript_java.java",
"orig/com/exasol/swig/ExportSpecificationWrapper.java",
"orig/com/exasol/swig/ImportSpecificationWrapper.java",
"orig/com/exasol/swig/Metadata.java",
"orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ExportSpecification.java",
"orig/com/exasol/swig/SWIGTYPE_p_ExecutionGraph__ImportSpecification.java",
"orig/com/exasol/swig/SWIGVM_datatype_e.java",
"orig/com/exasol/swig/SWIGVM_itertype_e.java",
],
tools = ["//:filter_swig_code.py"]
tomuben marked this conversation as resolved.
Show resolved Hide resolved
)

cc_library(
name = "exascript_java",
srcs = [":filter_swig_code_exascript_java_cc",],
srcs = [":exascript_java.cc",],
deps = ["@java//:java","//exaudflib:exaudflib-deps","//exaudflib:header"],
copts= ["-O0","-fno-lto"],
# We limit this target to -O0 (no optimization) and -fno-lto. because otherwise we get compiler warnings of the sort
Expand All @@ -103,7 +155,7 @@ cc_library(
cc_library(
name = "javacontainer",
srcs = [":javacontainer.cc", ":javacontainer.h", ":javacontainer_impl.cc", ":javacontainer_impl.h", ":dummy"],
hdrs = [":exascript_java_int", ":filter_swig_code_exascript_java_h", "exascript_java_jni_decl.h"],
hdrs = [":filter_swig_code_exascript_java_h", "exascript_java_jni_decl.h"],
deps = ["@ssl//:ssl","@java//:java", ":exascript_java", "//exaudflib:header", "//:debug_message_h","//exaudflib:scriptoptionlines"],
# copts= ["-O0","-fno-lto"],
alwayslink=True,
Expand All @@ -122,18 +174,18 @@ java_binary(
srcs = glob(["*.java"])+
#The following are generated classes
[
"ConnectionInformationWrapper.java",
"exascript_java.java",
"exascript_javaJNI.java",
"ExportSpecificationWrapper.java",
"ImportSpecificationWrapper.java",
"Metadata.java",
"ResultHandler.java",
"SWIGTYPE_p_ExecutionGraph__ExportSpecification.java",
"SWIGTYPE_p_ExecutionGraph__ImportSpecification.java",
"SWIGVM_datatype_e.java",
"SWIGVM_itertype_e.java",
"TableIterator.java"
":ConnectionInformationWrapper.java",
":exascript_java.java",
":exascript_javaJNI.java",
":ExportSpecificationWrapper.java",
":ImportSpecificationWrapper.java",
":Metadata.java",
":ResultHandler.java",
":SWIGTYPE_p_ExecutionGraph__ExportSpecification.java",
":SWIGTYPE_p_ExecutionGraph__ImportSpecification.java",
":SWIGVM_datatype_e.java",
":SWIGVM_itertype_e.java",
":TableIterator.java"
],
deps = ["@maven//:com_exasol_udf_api_java"],
create_executable=False,
Expand Down
Loading