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 7 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
29 changes: 20 additions & 9 deletions exaudfclient/base/javacontainer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,48 @@ 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 ..
tar cf java_src.tar ./java_src
tomuben marked this conversation as resolved.
Show resolved Hide resolved
cp java_src.tar $(location java_src.tar)
cp exascript_java_tmp.cc $(location exascript_java_tmp.cc)
""",
outs = ["java_src.tar",
"exascript_java_tmp.cc"
],
srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h"]
)

genrule(
name = "exascript_java_tmp_h",
cmd = """
mkdir build_exascript_java_tmp_h
cp $(location :java_src.tar) .
tar xf java_src.tar
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)" java_src build_exascript_java_tmp_h
tomuben marked this conversation as resolved.
Show resolved Hide resolved
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", ":java_src.tar"]
)

genrule(
name = "exascript_java_int",
cmd = """
cp -r $(locations :exascript_java_tmp_cc) .
cp $(locations :java_src.tar) .
tar xf java_src.tar
ls -la java_src
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"],
srcs = [":java_src.tar"],
tools = ["//:build_integrated.py"]
)
tomuben marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -52,6 +62,7 @@ genrule(
TMPDIR=`mktemp -d`
cp -r -L $(location //:filter_swig_code.py) $(locations :exascript_java_tmp_cc) $$TMPDIR
(cd $$TMPDIR &&
tar xf java_src.tar
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)"
tomuben marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions exaudfclient/base/protobuf_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def _protobuf_local_repository_impl(repository_ctx):
print("protobuf include prefix in environment specified; %s"%include_prefix)
build_file_content = """
cc_library(
name = "{name}",
name = "protobuf",
srcs = glob(["protobuf/lib/**/libprotobuf*.so"]),
hdrs = glob(["protobuf/include/**"]),
includes = ["protobuf/include/"],
visibility = ["//visibility:public"]
)""".format( name=repository_ctx.name)
)"""
print(build_file_content)

repository_ctx.symlink(library_prefix, "./protobuf/lib")
Expand Down
22 changes: 12 additions & 10 deletions exaudfclient/base/python_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ def _get_lib_glob(binary, version, p_repository_ctx):
return lib_glob

def _python_local_repository_impl(repository_ctx):
python_prefix_env_var = repository_ctx.name.upper() + "_PREFIX"
python_version = repository_ctx.attr.python_version
python_prefix_env_var = python_version.upper() + "_PREFIX"
if python_prefix_env_var in repository_ctx.os.environ:
prefix = repository_ctx.os.environ[python_prefix_env_var]
else:
fail("Environment Variable %s not found"%python_prefix_env_var)
print("python prefix in environment specified; %s"%prefix)

python_version_env_var = repository_ctx.name.upper() + "_VERSION"
python_version_env_var = python_version.upper() + "_VERSION"
if python_version_env_var in repository_ctx.os.environ:
version = repository_ctx.os.environ[python_version_env_var]
if repository_ctx.name == "python3" and version.startswith("2"):
fail("Wrong python version specified in environment variable %s, got binary name '%s', but version number '%s'"%(python_version_env_var,repository_ctx.name,version))
if repository_ctx.name == "python" or version.startswith("2"):
fail("Python 2 is not supported anymore, but specified in environment variable %s, got %s, %s"%(python_version_env_var,repository_ctx.name,version))
if python_version == "python3" and version.startswith("2"):
fail("Wrong python version specified in environment variable %s, got binary name '%s', but version number '%s'"%(python_version_env_var,python_version,version))
if python_version == "python" or version.startswith("2"):
fail("Python 2 is not supported anymore, but specified in environment variable %s, got %s, %s"%(python_version_env_var,python_version,version))
else:
fail("Environment Variable %s not found"%python_version_env_var)
print("python version in environment specified; %s"%version)
Expand All @@ -66,7 +67,7 @@ cc_library(
includes = ["{include_dir}"],
defines = [{defines}],
visibility = ["//visibility:public"]
)""".format(lib_glob=lib_glob[1:], include_dir=include_dir[1:], name=repository_ctx.name, defines=defines_str)
)""".format(lib_glob=lib_glob[1:], include_dir=include_dir[1:], name=python_version, defines=defines_str)
print(build_file_content)

repository_ctx.symlink(prefix, "."+prefix)
Expand All @@ -75,7 +76,8 @@ cc_library(
python_local_repository = repository_rule(
implementation=_python_local_repository_impl,
local = True,
environ = ["PYTHON3_PREFIX", "PYTHON3_VERSION"])
environ = ["PYTHON3_PREFIX", "PYTHON3_VERSION"],
attrs = {"python_version": attr.string()})


def _get_numpy_include_dir(binary,p_repository_ctx):
Expand Down Expand Up @@ -117,13 +119,13 @@ def _numpy_local_repository_impl(repository_ctx):
hdrs = numpy_include_dir + "/*/*.h"
build_file_content = """
cc_library(
name = "{name}",
name = "numpy",
srcs = [],
hdrs = glob(["{hdrs}"]),
includes = ["{includes}"],
defines = [{defines}],
visibility = ["//visibility:public"]
)""".format(hdrs=hdrs, includes=numpy_include_dir, name=repository_ctx.name, defines=defines_str)
)""".format(hdrs=hdrs, includes=numpy_include_dir, defines=defines_str)
print(build_file_content)

repository_ctx.symlink(prefix, "."+prefix)
Expand Down
4 changes: 2 additions & 2 deletions exaudfclient/base/zmq_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def _zmq_local_repository_impl(repository_ctx):
print("zmq include prefix in environment specified; %s"%include_prefix)
build_file_content = """
cc_library(
name = "{name}",
name = "zmq",
srcs = glob(["zmq/lib/**/libzmq.so"]),
hdrs = glob(["zmq/include/zmq*"]),
includes = ["zmq/include/"],
visibility = ["//visibility:public"]
)""".format( name=repository_ctx.name)
)"""
print(build_file_content)

repository_ctx.symlink(library_prefix, "./zmq/lib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ protobuf|4.25.3
pcre|8.45
chrpath|0.16
tomuben marked this conversation as resolved.
Show resolved Hide resolved
openjdk|11.0.15
bazel|5.2.0
bazel|7.2.1
gxx_linux-64|11.2.0
gcc_linux-64|11.2.0
make|4.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ protobuf|4.25.3
pcre|8.45
chrpath|0.16
openjdk|11.0.15
bazel|5.2.0
bazel|7.2.1
gxx_linux-64|12.1.0
gcc_linux-64|12.1.0
make|4.3
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY scripts /scripts
RUN mkdir -p /build_info/packages
COPY build_deps/packages /build_info/packages/build_deps

ENV BAZEL_PACKAGE_VERSION="5.2.0"
ENV BAZEL_PACKAGE_VERSION="7.2.1"
ENV BAZEL_PACKAGE_FILE="bazel_$BAZEL_PACKAGE_VERSION-linux-x86_64.deb"
ENV BAZEL_PACKAGE_URL="https://github.com/bazelbuild/bazel/releases/download/$BAZEL_PACKAGE_VERSION/$BAZEL_PACKAGE_FILE"

Expand Down