File bazel.spec of Package bazel

#
# spec file for package bazel
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null)

#Workaround for s390x (Java 1.8 runs out of memory)
%ifarch s390x
%if 0%{?suse_version} > 1500
%define openjdktouse java-12-openjdk-devel
%else
%define openjdktouse java-11-openjdk-devel
%endif
%else
%define openjdktouse java-1_8_0-openjdk-devel
%endif

Name:           bazel
Version:        4.2.1
Release:        13.10
Summary:        Tool for the automation of building and testing of software
License:        Apache-2.0
Group:          Development/Tools/Building
URL:            http://bazel.io/
Source0:        https://github.com/bazelbuild/bazel/releases/download/%{version}/%{name}-%{version}-dist.zip
Source1:        https://github.com/bazelbuild/bazel/releases/download/%{version}/%{name}-%{version}-dist.zip.sig
BuildRequires:  gcc-c++
BuildRequires:  java-1_8_0-openjdk-devel
BuildRequires:  pkgconfig
BuildRequires:  python3
BuildRequires:  unzip
BuildRequires:  zip
BuildRequires:  pkgconfig(bash-completion)
BuildRequires:  pkgconfig(zlib)
Requires(post):	update-alternatives
Requires(postun): update-alternatives
Requires:       %{openjdktouse}
ExcludeArch:    %ix86

%description
Tool for the automation of building and testing of software. It supports Java,
C++ and Go as programing languages. It also has a support for Android and iOS
as mobile operating systems.

%prep
%setup -q -c
# Remove executable permissions
chmod 0644 AUTHORS CHANGELOG.md CONTRIBUTORS LICENSE
# Use Python 3
find . -type f \( -name "*.py" -o -name "*.txt" \) -exec sed -i 's|#!.*python.*|#!/usr/bin/python3|' "{}" +
find . -type f -name "*.java" -exec sed -i 's|#!/usr/bin/env python|#!/usr/bin/python3|' "{}" +
sed -i -e \
    "s/String pythonExecutableName = .*$/String pythonExecutableName = \"python3\";/" \
    src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
# Fix collision between grpc's gettid and glibc's gettid
find third_party/grpc -type f -name "*.cc" -exec sed -i -e 's|gettid(|my_gettid(|g' {} +

%build
%ifarch aarch64 %arm
export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms200m"
%endif
%ifarch s390x
export BAZEL_JAVAC_OPTS="-J-Xmx4g -J-Xms1g"
%endif
CC=gcc
CXX=g++
EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh
./scripts/generate_bash_completion.sh \
    --bazel=output/bazel \
    --output=output/bazel-complete.bash \
    --prepend=scripts/bazel-complete-header.bash \
    --prepend=scripts/bazel-complete-template.bash
./output/bazel shutdown

%install
export NO_BRP_STRIP_DEBUG=true
export NO_DEBUGINFO_STRIP_DEBUG=true
%define __debug_install_post %{nil}
: >debugfiles.list
: >debugsources.list
: >debugsourcefiles.list

install -Dm0755 output/bazel %{buildroot}%{_bindir}/bazel
install -Dm0644 output/bazel-complete.bash %{buildroot}%{_datadir}/bash-completion/completions/bazel

%files
%doc AUTHORS CHANGELOG.md CONTRIBUTORS
%license LICENSE
%{_bindir}/bazel
%{_datadir}/bash-completion/completions/bazel

%changelog
* Mon Apr 27 2020 MichaƂ Rostecki <mrostecki@opensuse.org>
- Initial release
openSUSE Build Service is sponsored by