aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-10-20 14:40:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-10-20 14:40:39 +0200
commiteb55f9b9b5df5678df0b30f4a0af9f35fcbc4be4 (patch)
tree1c6a906630ef1599bdf6974b5167209b70e2b5b9
parent941e1773216818665914b4adf11582d14f572be4 (diff)
Switch to using options instead of arguments in build batch files
-rw-r--r--build-mingw.bat77
-rw-r--r--build-msvc.bat103
-rwxr-xr-xbuild.sh2
3 files changed, 132 insertions, 50 deletions
diff --git a/build-mingw.bat b/build-mingw.bat
index 11dbb62..ddb8a5d 100644
--- a/build-mingw.bat
+++ b/build-mingw.bat
@@ -9,18 +9,20 @@ goto start
:usage
echo.
-echo Usage: %0 [/?] [^<options^>] ^<cxx^> [^<install-dir^>] [^<trust^>]
+echo Usage: %0 [/?] [^<options^>] ^<cxx^>
echo Options:
-echo --timeout ^<sec^> Network operations timeout in seconds.
-echo --make ^<arg^> Bootstrap using GNU make instead of batch file.
+echo --install-dir ^<dir^> Alternative installation directory.
+echo --repo ^<loc^> Alternative package repository location.
+echo --trust ^<fp^> Repository certificate fingerprint to trust.
+echo --timeout ^<sec^> Network operations timeout in seconds.
+echo --make ^<arg^> Bootstrap using GNU make instead of batch file.
echo.
echo By default the batch file will install into C:\build2. It also expects
echo to find the base utilities in the bin\ subdirectory of the installation
echo directory (C:\build2\bin\ by default).
echo.
-echo The ^<trust^> argument can be used to specify the repository certificate
-echo fingerprint to trust. Two special values are also recognized: 'yes'
-echo (trust everything) and 'no' (trust nothing).
+echo The --trust option recognizes two special values: 'yes' (trust everything)
+echo and 'no' (trust nothing).
echo.
echo The --make option can be used to bootstrap using GNU make. The first
echo --make value should specify the make executable optionally followed by
@@ -51,6 +53,8 @@ set "cdir=build2-toolchain-%cver%"
rem Parse options.
rem
+set "idir=C:\build2"
+set "trust="
set "timeout="
set "make="
@@ -59,6 +63,39 @@ if "_%~1_" == "_/?_" goto usage
if "_%~1_" == "_-h_" goto usage
if "_%~1_" == "_--help_" goto usage
+if "_%~1_" == "_--install-dir_" (
+ if "_%~2_" == "__" (
+ echo error: installation directory expected after --install-dir
+ goto error
+ )
+ set "idir=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--trust_" (
+ if "_%~2_" == "__" (
+ echo error: certificate fingerprint expected after --trust
+ goto error
+ )
+ set "trust=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--repo_" (
+ if "_%~2_" == "__" (
+ echo error: repository location expected after --repo
+ goto error
+ )
+ set "BUILD2_REPO=%~2"
+ shift
+ shift
+ goto options
+)
+
if "_%~1_" == "_--timeout_" (
if "_%~2_" == "__" (
echo error: value in seconds expected after --timeout
@@ -85,9 +122,6 @@ if "_%~1_" == "_--_" shift
rem Validate options and arguments.
rem
-if not "_%timeout%_" == "__" (
- set "timeout=--fetch-timeout %timeout%"
-)
rem Compiler.
rem
@@ -98,30 +132,35 @@ if "_%1_" == "__" (
set "cxx=%1"
)
-rem Installation directory.
+rem @@ Temporarily retained for backwards compatibility.
rem
-if "_%2_" == "__" (
- set "idir=C:\build2"
-) else (
+if not "_%2_" == "__" (
set "idir=%2"
)
+if not "_%3_" == "__" (
+ set "trust=%3"
+)
rem Certificate to trust.
rem
-if "_%3_" == "__" (
- set "trust="
-) else (
- if "_%3_" == "_yes_" (
+if not "_%trust%_" == "__" (
+ if "_%trust%_" == "_yes_" (
set "trust=--trust-yes"
) else (
- if "_%3_" == "_no_" (
+ if "_%trust%_" == "_no_" (
set "trust=--trust-no"
) else (
- set "trust=--trust %3"
+ set "trust=--trust %trust%"
)
)
)
+rem Network timeout.
+rem
+if not "_%timeout%_" == "__" (
+ set "timeout=--fetch-timeout %timeout%"
+)
+
if not exist %idir%\bin\ (
echo error: %idir%\bin\ does not exist
goto error
diff --git a/build-msvc.bat b/build-msvc.bat
index 477950d..0602422 100644
--- a/build-msvc.bat
+++ b/build-msvc.bat
@@ -9,21 +9,19 @@ goto start
:usage
echo.
-echo Usage: %0 [/?] [^<options^>] [^<install-dir^>] [^<trust^>]
+echo Usage: %0 [/?] [^<options^>] [^<cxx^>]
echo Options:
-echo --timeout ^<sec^> Network operations timeout in seconds.
+echo --install-dir ^<dir^> Alternative installation directory.
+echo --repo ^<loc^> Alternative package repository location.
+echo --trust ^<fp^> Repository certificate fingerprint to trust.
+echo --timeout ^<sec^> Network operations timeout in seconds.
echo.
-echo By default the batch file will install into C:\build2. It also expects
-echo to find the base utilities in the bin\ subdirectory of the installation
-echo directory (C:\build2\bin\ by default).
+echo By default the batch file will use cl.exe as the C++ compiler and install
+echo into C:\build2. It also expects to find the base utilities in the bin\
+echo subdirectory of the installation directory (C:\build2\bin\ by default).
echo.
-echo The ^<trust^> argument can be used to specify the repository certificate
-echo fingerprint to trust. Two special values are also recognized: 'yes'
-echo (trust everything) and 'no' (trust nothing).
-echo.
-echo Example usage:
-echo.
-echo %0 D:\build2
+echo The --trust option recognizes two special values: 'yes' (trust everything)
+echo and 'no' (trust nothing).
echo.
echo See the BOOTSTRAP-MSVC file for details.
echo.
@@ -48,6 +46,8 @@ set "cdir=build2-toolchain-%cver%"
rem Parse options.
rem
+set "idir=C:\build2"
+set "trust="
set "timeout="
:options
@@ -55,6 +55,39 @@ if "_%~1_" == "_/?_" goto usage
if "_%~1_" == "_-h_" goto usage
if "_%~1_" == "_--help_" goto usage
+if "_%~1_" == "_--install-dir_" (
+ if "_%~2_" == "__" (
+ echo error: installation directory expected after --install-dir
+ goto error
+ )
+ set "idir=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--trust_" (
+ if "_%~2_" == "__" (
+ echo error: certificate fingerprint expected after --trust
+ goto error
+ )
+ set "trust=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--repo_" (
+ if "_%~2_" == "__" (
+ echo error: repository location expected after --repo
+ goto error
+ )
+ set "BUILD2_REPO=%~2"
+ shift
+ shift
+ goto options
+)
+
if "_%~1_" == "_--timeout_" (
if "_%~2_" == "__" (
echo error: value in seconds expected after --timeout
@@ -65,38 +98,48 @@ if "_%~1_" == "_--timeout_" (
shift
goto options
)
+
if "_%~1_" == "_--_" shift
rem Validate options and arguments.
rem
-if not "_%timeout%_" == "__" (
- set "timeout=--fetch-timeout %timeout%"
-)
-rem Installation directory.
+rem @@ Temporarily retained for backwards compatibility.
rem
-if "_%1_" == "__" (
- set "idir=C:\build2"
-) else (
+if not "_%1_" == "__" (
set "idir=%1"
)
+if not "_%2_" == "__" (
+ set "trust=%2"
+)
+rem Compiler.
+rem
+rem if "_%1_" == "__" (
+ set "cxx=cl"
+rem ) else (
+rem set "cxx=%1"
+rem )
rem Certificate to trust.
rem
-if "_%2_" == "__" (
- set "trust="
-) else (
- if "_%2_" == "_yes_" (
+if not "_%trust%_" == "__" (
+ if "_%trust%_" == "_yes_" (
set "trust=--trust-yes"
) else (
- if "_%2_" == "_no_" (
+ if "_%trust%_" == "_no_" (
set "trust=--trust-no"
) else (
- set "trust=--trust %2"
+ set "trust=--trust %trust%"
)
)
)
+rem Network timeout.
+rem
+if not "_%timeout%_" == "__" (
+ set "timeout=--fetch-timeout %timeout%"
+)
+
if not exist %idir%\bin\ (
echo error: %idir%\bin\ does not exist
goto error
@@ -121,7 +164,7 @@ rem
@rem Verify the compiler works.
@rem
-cl
+%cxx%
@if errorlevel 1 goto error
@rem Bootstrap.
@@ -130,13 +173,13 @@ cd build2
@rem Execute in a separate cmd.exe to preserve the echo mode.
@rem
-cmd /C bootstrap-msvc.bat cl
+cmd /C bootstrap-msvc.bat %cxx%
@if errorlevel 1 goto error
build2\b-boot --version
@if errorlevel 1 goto error
-build2\b-boot config.cxx=cl config.bin.lib=static
+build2\b-boot config.cxx=%cxx% config.bin.lib=static
@if errorlevel 1 goto error
move /y build2\b.exe build2\b-boot.exe
@@ -150,7 +193,7 @@ build2\b-boot --version
cd ..
build2\build2\b-boot configure^
- config.cxx=cl^
+ config.cxx=%cxx%^
config.bin.suffix=-stage^
config.install.root=%idir%^
config.install.data_root=root\stage
@@ -186,7 +229,7 @@ cd %cdir%
bpkg-stage create^
cc^
- config.cxx=cl^
+ config.cxx=%cxx%^
"config.cc.coptions=/O2 /Oi"^
config.install.root=%idir%
@if errorlevel 1 goto error
diff --git a/build.sh b/build.sh
index 97e9403..93ad113 100755
--- a/build.sh
+++ b/build.sh
@@ -54,7 +54,7 @@ while test $# -ne 0; do
diag " --install-dir <dir> Alternative installation directory."
diag " --sudo <prog> Optional sudo program to use."
diag " --repo <loc> Alternative package repository location."
- diag " --trust <fp> Certificate fingerprint to trust."
+ diag " --trust <fp> Repository certificate fingerprint to trust."
diag " --timeout <sec> Network operations timeout in seconds."
diag " --make <arg> Bootstrap using GNU make instead of script."
diag