Download the Windows compiler
We use this for building code to run on the driver's station.
Change-Id: I03cb907f67419e45a3a7204fa61ba2dd73b6687c
diff --git a/WORKSPACE b/WORKSPACE
index cc93fcb..6eab184 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -20,6 +20,10 @@
"//debian:libusb.bzl",
libusb_debs = "files",
)
+load(
+ "//debian:mingw_compiler.bzl",
+ mingw_compiler_debs = "files",
+)
load("//debian:packages.bzl", "generate_repositories_for_debs")
generate_repositories_for_debs(python_debs)
@@ -32,6 +36,8 @@
generate_repositories_for_debs(libusb_debs)
+generate_repositories_for_debs(mingw_compiler_debs)
+
new_http_archive(
name = "python_repo",
build_file = "debian/python.BUILD",
@@ -195,3 +201,10 @@
sha256 = "3ca5cc2d317226f6646866ff9e8c443db3b0f6c82f828e800240982727531590",
url = "http://frc971.org/Build-Dependencies/libusb.tar.gz",
)
+
+new_http_archive(
+ name = "mingw_compiler",
+ build_file = "debian/mingw_compiler.BUILD",
+ sha256 = "45e86a8460f2151a4f0306e7ae7b06761029d2412ee16f63d1e8d2d29354e378",
+ url = "http://frc971.org/Build-Dependencies/mingw_compiler.tar.gz",
+)
diff --git a/debian/BUILD b/debian/BUILD
index f1f38f4..957df39 100644
--- a/debian/BUILD
+++ b/debian/BUILD
@@ -20,6 +20,10 @@
":libusb.bzl",
libusb_debs = "files",
)
+load(
+ ":mingw_compiler.bzl",
+ mingw_compiler_debs = "files",
+)
load("//debian:packages.bzl", "download_packages", "generate_deb_tarball")
py_binary(
@@ -87,6 +91,13 @@
],
)
+download_packages(
+ name = "download_mingw_compiler_deps",
+ packages = [
+ "g++-mingw-w64-x86-64",
+ ],
+)
+
generate_deb_tarball(
name = "python",
files = python_debs,
@@ -111,3 +122,8 @@
name = "libusb",
files = libusb_debs,
)
+
+generate_deb_tarball(
+ name = "mingw_compiler",
+ files = mingw_compiler_debs,
+)
diff --git a/debian/mingw_compiler.BUILD b/debian/mingw_compiler.BUILD
new file mode 100644
index 0000000..7f3f87c
--- /dev/null
+++ b/debian/mingw_compiler.BUILD
@@ -0,0 +1,5 @@
+filegroup(
+ name = "all_files",
+ srcs = glob(["**"]),
+ visibility = ["//visibility:public"],
+)
diff --git a/debian/mingw_compiler.bzl b/debian/mingw_compiler.bzl
new file mode 100644
index 0000000..b9ee857
--- /dev/null
+++ b/debian/mingw_compiler.bzl
@@ -0,0 +1,14 @@
+files = {
+ "binutils-mingw-w64-x86-64_2.25-5+5.2+deb8u1_amd64.deb": "628e9274a1555baa8f9063648f0ce5e5de0c8055d44a3737c8deb1d4c65f6982",
+ "binutils_2.25-5+deb8u1_amd64.deb": "d9e6ac61d1d5bf63b632923c9f678d8fb64d3f9f82a0e31a8229e6e5b0bbb89d",
+ "g++-mingw-w64-x86-64_4.9.1-19+14.3_amd64.deb": "fc2682049ca0b8dade0db46cbbdab0ecdfc5b4a8f495f6cf387fbd085a47d775",
+ "gcc-mingw-w64-base_4.9.1-19+14.3_amd64.deb": "b0cb64084dc2d9fea088d935d41bdad6194942e92b512227bfa3bb988c765868",
+ "gcc-mingw-w64-x86-64_4.9.1-19+14.3_amd64.deb": "3999fa74f4ec8983ed7210fb4d8eff92073af4016aa1e0046d9a980602686516",
+ "libcloog-isl4_0.18.2-1+b2_amd64.deb": "8bb4ba985d65ededbfc24d76d3610af57a70787b635841407558d25a7f06ff49",
+ "libgmp10_6.0.0+dfsg-6_amd64.deb": "155a31b0f716aa3dcd7ee68e9bd57e0b76a6b31f4e41fb2d953e986315437082",
+ "libisl10_0.12.2-2_amd64.deb": "5a091cf30221e183d319f4906a746043be7220061f3b742b2ad958ee79ac01f7",
+ "libmpc3_1.0.2-1_amd64.deb": "0a252dcf89843ee8b402fd226c8fb552d69c82c7013a28e335ba36878468d959",
+ "libmpfr4_3.1.2-2_amd64.deb": "1b6ef16024e7850c4f2d47dbe06cba1143ac36d5584db515f63d5fbd873e3eb2",
+ "mingw-w64-common_3.2.0-2_all.deb": "8bcf240dcd77fdca6542e1614fcf7b5718e0f4b481bef8e9856cde4e03458ec8",
+ "mingw-w64-x86-64-dev_3.2.0-2_all.deb": "ef2ec22f257e62c51fdbeebd1a3ff1bc3e5fe8d1dccfb484f74a9ed7805c64b5",
+}
diff --git a/motors/pistol_grip/BUILD b/motors/pistol_grip/BUILD
index 0a24ba8..75cab98 100644
--- a/motors/pistol_grip/BUILD
+++ b/motors/pistol_grip/BUILD
@@ -80,6 +80,7 @@
output_to_bindir = True,
tools = [
"usb_forward_windows_build.sh",
+ "@mingw_compiler//:all_files",
],
)
diff --git a/motors/pistol_grip/usb_forward_windows_build.sh b/motors/pistol_grip/usb_forward_windows_build.sh
index 3f1022b..64a42d7 100755
--- a/motors/pistol_grip/usb_forward_windows_build.sh
+++ b/motors/pistol_grip/usb_forward_windows_build.sh
@@ -6,15 +6,6 @@
set -u
set -o pipefail
-check_installed() {
- if ! dpkg -l "$1" > /dev/null 2>&1 ; then
- echo "Must install $1" >&2
- exit 1
- fi
-}
-
-check_installed g++-mingw-w64-x86-64
-
readonly SOURCE_FILE="$1"
readonly LIBUSB_ARCHIVE="$2"
readonly OUTPUT="$3"
@@ -24,6 +15,12 @@
mkdir -p "${TEMP}/libusb"
tar xJf "${LIBUSB_ARCHIVE}" -C "${TEMP}/libusb"
+mkdir -p "${TEMP}/compiler_bin"
+ln -s $(readlink -f external/mingw_compiler/usr/bin/x86_64-w64-mingw32-as) "${TEMP}/compiler_bin/as"
+
+export LD_LIBRARY_PATH=external/mingw_compiler/usr/lib/x86_64-linux-gnu:external/mingw_compiler/lib/x86_64-linux-gnu:external/mingw_compiler/usr/lib
+export PATH=external/mingw_compiler/usr/bin:$PATH
+
x86_64-w64-mingw32-g++-posix \
--std=gnu++11 \
-D__USE_MINGW_ANSI_STDIO \
@@ -32,4 +29,5 @@
"${SOURCE_FILE}" \
-static -static-libgcc -static-libstdc++ \
-lws2_32 \
- -L "${TEMP}/libusb/MinGW64/static" -lusb-1.0
+ -L "${TEMP}/libusb/MinGW64/static" -lusb-1.0 \
+ -B"${TEMP}/compiler_bin"