Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Adding Bazel Platforms support #3779

Merged
merged 19 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ load(
)
jar_jar_repositories()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
],
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
)

http_archive(
name = "rules_python",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
Expand Down
3 changes: 0 additions & 3 deletions docker/compile/Dockerfile.debian10
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM openjdk:11.0.6-jdk-buster

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

Expand Down
7 changes: 2 additions & 5 deletions docker/compile/Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@

FROM rockylinux:8.5

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

RUN yum -y upgrade
RUN yum -y install \
RUN yum -y upgrade \
&& yum -y install \
ant \
automake \
curl \
Expand Down
3 changes: 0 additions & 3 deletions docker/compile/Dockerfile.ubuntu18.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM ubuntu:18.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
Expand Down
3 changes: 0 additions & 3 deletions docker/compile/Dockerfile.ubuntu20.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM ubuntu:20.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
Expand Down
3 changes: 0 additions & 3 deletions docker/compile/Dockerfile.ubuntu22.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM ubuntu:22.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM ubuntu

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion docker/dist/Dockerfile.dist.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#syntax=docker/dockerfile:1.2
FROM rockylinux:8.5

RUN yum -y install epel-release \
RUN yum -y upgrade \
&& yum -y install \
curl \
java-11-openjdk-headless \
Expand Down
5 changes: 0 additions & 5 deletions docker/scripts/compile-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ dockerfile_path_for_platform() {
echo "$SCRATCH_DIR/compile/Dockerfile.$1"
}

copy_bazel_rc_to() {
cp $PROJECT_DIR/tools/docker/bazel.rc $1
}

nicknezis marked this conversation as resolved.
Show resolved Hide resolved
DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM)
verify_dockerfile_exists $DOCKER_FILE
copy_bazel_rc_to $SCRATCH_DIR/bazelrc

echo "Building heron-compiler container"
docker buildx build -t heron-compiler:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR
Expand Down
21 changes: 3 additions & 18 deletions docker/scripts/compile-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,14 @@ cd $SCRATCH_DIR
echo "Extracting source"
tar -C . -xzf $SOURCE_TARBALL

if [[ "$TARGET_PLATFORM" =~ "ubuntu" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "centos" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "rocky" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "debian" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "darwin" ]]; then
CONFIG_PLATFORM=darwin_nostyle
else
echo "Unknown platform: $TARGET_PLATFORM"
exit 1
fi

bazel version
./bazel_configure.py
bazel clean

echo "Creating packages"
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/packages:tarpkgs
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/packages:binpkgs
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/images:heron.tar
bazel build -c opt --copt=-O3 scripts/packages:tarpkgs
bazel build -c opt --copt=-O3 scripts/packages:binpkgs
bazel build -c opt --copt=-O3 scripts/images:heron.tar

echo "Moving packages to /$OUTPUT_DIRECTORY"
for file in ./bazel-bin/scripts/packages/*.tar.gz; do
Expand Down
5 changes: 2 additions & 3 deletions docker/scripts/dev-env-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
# After the container is started, you can build Heron with bazel
# (ubuntu config is used in the example):
# ./bazel_configure.py
# bazel build --config=linux heron/...
# bazel build --config=linux scripts/packages:binpkgs
# bazel build heron/...
# bazel build scripts/packages:binpkgs

set -o nounset
set -o errexit
Expand Down Expand Up @@ -69,7 +69,6 @@ dockerfile_path_for_platform() {

copy_extra_files() {
mkdir -p $SCRATCH_DIR/scripts
cp $PROJECT_DIR/tools/docker/bazel.rc $SCRATCH_DIR/bazelrc
cp $DOCKER_DIR/scripts/compile-docker.sh $SCRATCH_DIR/scripts/compile-platform.sh
}

Expand Down
5 changes: 0 additions & 5 deletions docker/scripts/test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ dockerfile_path_for_platform() {
echo "$SCRATCH_DIR/test/Dockerfile.$1"
}

copy_bazel_rc_to() {
cp $PROJECT_DIR/tools/docker/bazel.rc $1
}

DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM)
verify_dockerfile_exists $DOCKER_FILE
copy_bazel_rc_to $SCRATCH_DIR/bazelrc

echo "Building heron-compiler container"
docker buildx build -t heron-compiler:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR
Expand Down
18 changes: 1 addition & 17 deletions docker/scripts/test-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,12 @@ cd $SCRATCH_DIR
echo "Extracting source"
tar -C . -xzf $SOURCE_TARBALL

if [[ "$TARGET_PLATFORM" =~ "ubuntu" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "centos" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "rocky" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "darwin" ]]; then
CONFIG_PLATFORM=darwin
elif [[ "$TARGET_PLATFORM" =~ "debian" ]]; then
CONFIG_PLATFORM=linux_nostyle
else
echo "Unknown platform: $TARGET_PLATFORM"
exit 1
fi

bazel version
./bazel_configure.py
bazel clean

echo "UnitTest"
bazel test -c opt --jobs 25 \
--config=$CONFIG_PLATFORM \
bazel test -c opt \
--test_output=all \
--test_summary=detailed \
heron/... \
Expand Down
6 changes: 2 additions & 4 deletions docker/test/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

FROM centos:centos7

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux
ENV LC_ALL en_US.utf8

RUN yum -y upgrade && yum -y install centos-release-scl-rh
RUN yum -y install \
automake \
Expand All @@ -31,6 +27,7 @@ RUN yum -y install \
devtoolset-8-gcc \
devtoolset-8-gcc-c++ \
git \
glibc-langpack-en \
kernel-devel \
libtool \
make \
Expand All @@ -51,6 +48,7 @@ RUN /usr/bin/ln -sfT /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3 \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++ \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/cpp /usr/bin/cpp

ENV LC_ALL en_US.utf8
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk

ENV bazelVersion 4.2.2
Expand Down
4 changes: 2 additions & 2 deletions docker/test/Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ FROM rockylinux:8.5
# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

RUN yum -y upgrade
RUN yum -y install \
RUN yum -y upgrade \
&& yum -y install \
automake \
curl \
cmake \
Expand Down
4 changes: 2 additions & 2 deletions docker/test/Dockerfile.ubuntu18.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

FROM ubuntu:18.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

RUN apt-get update && apt-get -y install \
g++ \
Expand Down
2 changes: 1 addition & 1 deletion examples/src/scala/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function die {
which scalac || die "scalac must be installed to run this script. Exiting."

rm -f heron-storm.jar
(cd $root && bazel build --config=darwin scripts/packages:tarpkgs)
(cd $root && bazel build scripts/packages:tarpkgs)

# Verify storm and heron bolts compile with heron-storm.jar
scalac -cp bazel-bin/./storm-compatibility/v0.10.2/src/java/heron-storm.jar \
Expand Down
2 changes: 1 addition & 1 deletion heron/common/src/cpp/basics/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cc_library(
"@com_github_corvusoft_kashmir_cpp//:kashmir-cxx",
"@com_google_protobuf//:protobuf",
] + select({
"//tools/platform:darwin": [],
"@platforms//os:osx": [],
"//conditions:default": ["@org_nongnu_libunwind//:libunwind"],
}),
)
2 changes: 1 addition & 1 deletion heron/common/src/cpp/metrics/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cc_library(
"@com_github_google_glog//:glog",
"@com_google_protobuf//:protobuf",
] + select({
"//tools/platform:darwin": [],
"@platforms//os:osx": [],
"//conditions:default": ["@org_nongnu_libunwind//:libunwind"],
}),
)
6 changes: 3 additions & 3 deletions integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ To run integration tests on your mac first run the following to build the test p
the heron client:

```Bash
bazel build --config=darwin integration_test/src/...
bazel run --config=darwin -- scripts/packages:heron-client-install.sh --user
bazel run --config=darwin -- scripts/packages:heron-tools-install.sh --user
bazel build integration_test/src/...
bazel run -- scripts/packages:heron-client-install.sh --user
bazel run -- scripts/packages:heron-tools-install.sh --user
```

To run the local integration tests on your mac run the following from the heron repo's top dir:
Expand Down
4 changes: 2 additions & 2 deletions integration_test/src/python/local_test_runner/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ tuple to an output file and the two files are compared.

To run the tests:

bazel run --config=darwin -- scripts/packages:heron-install.sh --user
bazel build --config=darwin integration_test/src/...
bazel run -- scripts/packages:heron-install.sh --user
bazel build integration_test/src/...
./bazel-bin/integration_test/src/python/local_test_runner/local-test-runner
Loading