aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-07-27 15:26:43 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-07-27 16:26:29 +0200
commit92caf38a4ae74889391eefa9b7196804d8f2c948 (patch)
tree3b4bac0a86b688cce46ed01ed577f45330798662 /src/main
parent7677e243d2ca2857103fccb47561677b1b19b841 (diff)
Windows: check in the icon resource file
The icon resource is a simple object file, built by rc.exe, but rc.exe is part of the Windows Kit, not of Visual Studio, and we have no reliable way to locate it, so we can't reliably rebuild the icon resource from source. Rather than having a brittle genrule that may or may not find the resource compiler, thus may or may not successfully build the icon resource and thus fail the whole build for //src:bazel.exe, let's just use a prebuilt object file. In a subsequent commit I'll add a script that can rebuild this file. Change-Id: Ia1f31ca9e78378088f93c9db144a2b708d690893 PiperOrigin-RevId: 163332738
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cpp/BUILD4
-rw-r--r--src/main/native/windows/BUILD23
-rw-r--r--src/main/native/windows/compile-resources.sh46
-rw-r--r--src/main/native/windows/gen_vsenv_stub.sh67
-rw-r--r--src/main/native/windows/resources.obin0 -> 5556 bytes
5 files changed, 7 insertions, 133 deletions
diff --git a/src/main/cpp/BUILD b/src/main/cpp/BUILD
index 8619eea015..cbd0654c0f 100644
--- a/src/main/cpp/BUILD
+++ b/src/main/cpp/BUILD
@@ -83,8 +83,8 @@ cc_binary(
"global_variables.h",
"main.cc",
] + select({
- "//src:windows": ["//src/main/native/windows:resources"],
- "//src:windows_msvc": ["//src/main/native/windows:resources"],
+ "//src:windows": ["//src/main/native/windows:resources.o"],
+ "//src:windows_msvc": ["//src/main/native/windows:resources.o"],
"//conditions:default": [],
}),
copts = select({
diff --git a/src/main/native/windows/BUILD b/src/main/native/windows/BUILD
index f4251a82b5..f0674c6ea5 100644
--- a/src/main/native/windows/BUILD
+++ b/src/main/native/windows/BUILD
@@ -1,5 +1,10 @@
package(default_visibility = ["//visibility:private"])
+exports_files(
+ ["resources.o"],
+ visibility = ["//src/main/cpp:__pkg__"],
+)
+
filegroup(
name = "srcs",
srcs = glob(["**"]),
@@ -48,21 +53,3 @@ genrule(
"//src/tools/android/java/com/google/devtools/build/android:__subpackages__",
],
)
-
-genrule(
- name = "resources",
- srcs = ["//site:images/favicon.ico"],
- outs = ["resources.o"],
- cmd = " ".join([
- "$(location compile-resources.sh)",
- "$(location //site:images/favicon.ico)",
- "$@",
- "$(location gen_vsenv_stub.sh)",
- ]),
- output_to_bindir = 1,
- tools = [
- "compile-resources.sh",
- "gen_vsenv_stub.sh",
- ],
- visibility = ["//src/main/cpp:__pkg__"],
-)
diff --git a/src/main/native/windows/compile-resources.sh b/src/main/native/windows/compile-resources.sh
deleted file mode 100644
index 92f81dee01..0000000000
--- a/src/main/native/windows/compile-resources.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash -eu
-
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ICON=$1
-OUTPUT=$2
-VCVARS_SETTER=$3
-
-export TMP="$(mktemp -d)"
-OWD=$(pwd)
-trap "cd \"$OWD\" && rm -fr \"$TMP\"" EXIT
-
-# Stage the source files in the temp directory.
-# The resource compiler generates its outputs next to its sources, and we don't
-# want to pollute the source tree with output files.
-mkdir -p "$TMP/$(dirname "$ICON")"
-cp $ICON $TMP/$ICON
-
-# Create the batch file that sets up the VC environment and runs the Resource
-# Compiler.
-RUNNER=$TMP/vs.bat
-"$VCVARS_SETTER" $RUNNER
-echo "@rc /nologo bazel.rc" >> $RUNNER
-chmod +x $RUNNER
-
-# Run the script and move the output to its final location.
-cd $TMP
-cat > bazel.rc <<EOF
-1 ICON "${ICON//\//\\}"
-EOF
-
-./vs.bat
-cd $OWD
-mv $TMP/bazel.res $OUTPUT
diff --git a/src/main/native/windows/gen_vsenv_stub.sh b/src/main/native/windows/gen_vsenv_stub.sh
deleted file mode 100644
index 723cbf5d3e..0000000000
--- a/src/main/native/windows/gen_vsenv_stub.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash -eu
-
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -eu
-OUTPUT=$1
-
-function fail() {
- echo >&2 "ERROR: $@"
- exit 1
-}
-
-# Ensure the PATH is set up correctly.
-if ! which which >&/dev/null ; then
- PATH="/bin:/usr/bin:$PATH"
- which which >&/dev/null \
- || fail "System PATH is not set up correctly, cannot run GNU bintools"
-fi
-
-# Find Visual Studio. We don't have any regular environment variables available
-# so this is the best we can do.
-if [ -z "${BAZEL_VS+set}" ]; then
- VSVERSION="$(ls "C:/Program Files (x86)" \
- | grep -E "Microsoft Visual Studio [0-9]+" \
- | sort --version-sort \
- | tail -n 1)"
- [[ -n "$VSVERSION" ]] || fail "Visual Studio not found"
- BAZEL_VS="C:/Program Files (x86)/$VSVERSION"
-fi
-VSVARS="${BAZEL_VS}/VC/VCVARSALL.BAT"
-
-# Check if Visual Studio 2017 is installed. Look for it at the default
-# locations.
-if [ ! -f "${VSVARS}" ]; then
- VSVARS="C:/Program Files (x86)/Microsoft Visual Studio/2017/"
- VSEDITION="BuildTools"
- if [ -d "${VSVARS}Enterprise" ]; then
- VSEDITION="Enterprise"
- elif [ -d "${VSVARS}Professional" ]; then
- VSEDITION="Professional"
- elif [ -d "${VSVARS}Community" ]; then
- VSEDITION="Community"
- fi
- VSVARS+="$VSEDITION/VC/Auxiliary/Build/VCVARSALL.BAT"
-fi
-
-if [ ! -f "${VSVARS}" ]; then
- fail "VCVARSALL.bat not found, check your Visual Studio installation"
-fi
-
-cat > "$OUTPUT" <<EOF
-@call "${VSVARS}" amd64
-EOF
-
-chmod +x "$OUTPUT"
diff --git a/src/main/native/windows/resources.o b/src/main/native/windows/resources.o
new file mode 100644
index 0000000000..afed5dce79
--- /dev/null
+++ b/src/main/native/windows/resources.o
Binary files differ