From f9048ed23d68c3a36060acd50c73c80d759c5a3f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 17 Jul 2017 20:24:30 +0200 Subject: Require target in environment scripts --- etc/environments/default | 28 +++++++++++++++++++++------- etc/environments/default-mingw.bat | 19 ++++++++++++------- etc/environments/default-msvc-14.bat | 13 +++---------- etc/environments/default-msvc-15.bat | 13 +++---------- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/etc/environments/default b/etc/environments/default index f4a19aa..92bc5fd 100755 --- a/etc/environments/default +++ b/etc/environments/default @@ -4,7 +4,13 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : TBC; see accompanying LICENSE file +# # Environment setup script for C/C++ compilation. +# +# Note that we assume the compiler's default target is x86_64-* and, if +# requested, i?86-* can be selected with -m32. For other targets you will +# need to adjust the mode selection below. +# c=gcc cxx=g++ @@ -15,12 +21,20 @@ cxx=g++ set -e # Exit on errors. -t="$1" +# Based on target determine what we are building. +# +case "$1" in + x86_64-*) + mode= + ;; + i?86-*) + mode="config.cc.coptions+=-m32" + ;; + *) + echo "unknown target: '$1'" 1>&2 + exit 1 + ;; +esac shift -if test -n "$t"; then - echo "unknown target: $t" 1>&2 - exit 1 -fi - -exec "$@" cc config.c="$c" config.cxx="$cxx" +exec "$@" cc config.c="$c" config.cxx="$cxx" $mode diff --git a/etc/environments/default-mingw.bat b/etc/environments/default-mingw.bat index 3d9bcb1..0491882 100644 --- a/etc/environments/default-mingw.bat +++ b/etc/environments/default-mingw.bat @@ -7,6 +7,9 @@ rem license : TBC; see accompanying LICENSE file rem rem Environment setup script for C/C++ compilation with MinGW GCC. rem +rem Note that we assume the compiler's default target is x86_64-w64-mingw32 +rem and, if requested, i686-w64-mingw32 can be selected with -m32. +rem rem %1 - target rem %2 - bbot executable @@ -20,16 +23,18 @@ set "PATH=$MINGW;%PATH%" rem Based on target determine what we are building. rem -rem Note that an empty argument is passed as "" (literal quotes). -rem -if _%1_ == _""_ ( - rem +if "_%1_" == "_x86_64-w64-mingw32_" ( + set "mode=" ) else ( - echo error: unknown target %1 - goto error + if "_%1_" == "_i686-w64-mingw32_" ( + set "mode=config.cc.coptions+=-m32" + ) else ( + echo error: unknown target %1 + goto error + ) ) -%2 %3 %4 %5 %6 %7 %8 %9 cc config.c=gcc config.cxx=g++ +%2 %3 %4 %5 %6 %7 %8 %9 cc config.c=gcc config.cxx=g++ %mode% if errorlevel 1 goto error goto end diff --git a/etc/environments/default-msvc-14.bat b/etc/environments/default-msvc-14.bat index 2af8136..fe8ebb4 100644 --- a/etc/environments/default-msvc-14.bat +++ b/etc/environments/default-msvc-14.bat @@ -17,10 +17,7 @@ setlocal EnableExtensions EnableDelayedExpansion set "MSVC=C:\Program Files (x86)\Microsoft Visual Studio 14.0" set "VCVARS=%MSVC%\VC\vcvarsall.bat" -rem Based on target determine what we are building. If the target is -rem not specified, then we build 64-bit by default. -rem -rem Note that an empty argument is passed as "" (literal quotes). +rem Based on target determine what we are building. rem if "_%1_" == "_x86_64-microsoft-win32-msvc14.0_" ( set "VCARCH=amd64" @@ -28,12 +25,8 @@ if "_%1_" == "_x86_64-microsoft-win32-msvc14.0_" ( if "_%1_" == "_i386-microsoft-win32-msvc14.0_" ( set "VCARCH=amd64_x86" ) else ( - if _%1_ == _""_ ( - set "VCARCH=amd64" - ) else ( - echo error: unknown target %1 - goto error - ) + echo error: unknown target %1 + goto error ) ) diff --git a/etc/environments/default-msvc-15.bat b/etc/environments/default-msvc-15.bat index 6eecc71..6c900dd 100644 --- a/etc/environments/default-msvc-15.bat +++ b/etc/environments/default-msvc-15.bat @@ -19,10 +19,7 @@ set "MSVC=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" set "VCVARS32=%MSVC%\VC\Auxiliary\Build\vcvarsamd64_x86.bat" set "VCVARS64=%MSVC%\VC\Auxiliary\Build\vcvars64.bat" -rem Based on target determine what we are building. If the target is -rem not specified, then we build 64-bit by default. -rem -rem Note that an empty argument is passed as "" (literal quotes). +rem Based on target determine what we are building. rem if "_%1_" == "_x86_64-microsoft-win32-msvc14.1_" ( set "VCVARS=%VCVARS64%" @@ -30,12 +27,8 @@ if "_%1_" == "_x86_64-microsoft-win32-msvc14.1_" ( if "_%1_" == "_i386-microsoft-win32-msvc14.1_" ( set "VCVARS=%VCVARS32%" ) else ( - if _%1_ == _""_ ( - set "VCVARS=%VCVARS64%" - ) else ( - echo error: unknown target %1 - goto error - ) + echo error: unknown target %1 + goto error ) ) -- cgit v1.1