aboutsummaryrefslogtreecommitdiff
path: root/build-msvc.bat.in
diff options
context:
space:
mode:
Diffstat (limited to 'build-msvc.bat.in')
-rw-r--r--build-msvc.bat.in299
1 files changed, 222 insertions, 77 deletions
diff --git a/build-msvc.bat.in b/build-msvc.bat.in
index bf00a6b..b3035b4 100644
--- a/build-msvc.bat.in
+++ b/build-msvc.bat.in
@@ -8,15 +8,18 @@ goto start
:usage
echo.
-rem echo Usage: %0 [/?] [^<options^>] [^<cl-compiler^>]
-echo Usage: %0 [/?] [^<options^>]
+echo Usage: %0 [/?] [^<options^>] [--] [^<cl-compiler^>] [^<compile-options^>] [-- ^<link-options^>]
echo Options:
echo --local Don't build from packages, only from local source.
-echo --no-bpkg Don't install bpkg nor bdep (requires --local).
+echo --no-bpkg Don't install bpkg nor bdep ^(requires --local^).
echo --no-bdep Don't install bdep.
echo --no-modules Don't install standard build system modules.
echo --modules "<list>" Install only specified standard build system modules.
echo --install-dir ^<dir^> Alternative installation directory.
+echo --exe-prefix ^<pfx^> Toolchain executables name prefix.
+echo --exe-suffix ^<sfx^> Toolchain executables name suffix.
+echo --stage-suffix ^<sfx^> Staged executables name suffix ^('-stage' by default^).
+echo --jobs^|-j ^<num^> Number of jobs to perform in parallel.
echo --repo ^<loc^> Alternative package repository location.
echo --trust ^<fp^> Repository certificate fingerprint to trust.
echo --timeout ^<sec^> Network operations timeout in seconds.
@@ -26,8 +29,11 @@ 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 If --jobs^|-j is unspecified, then the number of available hardware
+echo threads is used.
+echo.
echo The --trust option recognizes two special values: 'yes' ^(trust everything^)
-echo and 'no' (trust nothing).
+echo and 'no' ^(trust nothing^).
echo.
echo The script by default installs the following standard build system
echo modules:
@@ -62,7 +68,8 @@ rem
rem NOTE: we currently print the list as a single line and will need to
rem somehow change that when it becomes too long.
rem
-set "standard_modules=kconfig"
+set "standard_modules=autoconf, kconfig"
+set "autoconf_ver=@AUTOCONF_VERSION@"
set "kconfig_ver=@KCONFIG_VERSION@"
rem The bpkg configuration directory.
@@ -73,10 +80,14 @@ set "cdir=build2-toolchain-%cver%"
rem Parse options.
rem
set "local="
-set "bpkg=true"
-set "bdep=true"
+set "bpkg_install=true"
+set "bdep_install=true"
set "modules=%standard_modules%"
set "idir=C:\build2"
+set "exe_prefix="
+set "exe_suffix="
+set "stage_suffix=-stage"
+set "jobs="
set "trust="
set "timeout="
set "verbose="
@@ -93,13 +104,13 @@ if "_%~1_" == "_--local_" (
)
if "_%~1_" == "_--no-bpkg_" (
- set "bpkg="
+ set "bpkg_install="
shift
goto options
)
if "_%~1_" == "_--no-bdep_" (
- set "bdep="
+ set "bdep_install="
shift
goto options
)
@@ -128,6 +139,54 @@ if "_%~1_" == "_--install-dir_" (
goto options
)
+if "_%~1_" == "_--exe-prefix_" (
+ if "_%~2_" == "__" (
+ echo error: executables name prefix expected after --exe-prefix
+ goto error
+ )
+ set "exe_prefix=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--exe-suffix_" (
+ if "_%~2_" == "__" (
+ echo error: executables name suffix expected after --exe-suffix
+ goto error
+ )
+ set "exe_suffix=%~2"
+ shift
+ shift
+ goto options
+)
+
+if "_%~1_" == "_--stage-suffix_" (
+ if "_%~2_" == "__" (
+ echo error: staged executables name suffix expected after --stage-suffix
+ goto error
+ )
+ set "stage_suffix=%~2"
+ shift
+ shift
+ goto options
+)
+
+set "jo="
+if "_%~1_" == "_-j_" set "jo=true"
+if "_%~1_" == "_--jobs_" set "jo=true"
+
+if "_%jo%_" == "_true_" (
+ if "_%~2_" == "__" (
+ echo error: number of jobs expected after --jobs^|-j
+ goto error
+ )
+ set "jobs=%~2"
+ shift
+ shift
+ goto options
+)
+
if "_%~1_" == "_--trust_" (
if "_%~2_" == "__" (
echo error: certificate fingerprint expected after --trust
@@ -174,38 +233,66 @@ if "_%~1_" == "_--verbose_" (
if "_%~1_" == "_--_" shift
-rem Validate options and arguments.
+rem Compiler.
rem
+if "_%1_" == "__" (
+ set "cxx=cl"
+) else (
+ set "cxx=%~1"
+ shift
+)
-rem @@ Temporarily retained for backwards compatibility.
+rem Compile and link options.
rem
+set "compile_ops="
+set "link_ops="
+
+:compile_options
if not "_%1_" == "__" (
- set "idir=%1"
+ if not "_%~1_" == "_--_" (
+ set "compile_ops=%compile_ops% %~1"
+ shift
+ goto compile_options
+ ) else (
+ shift
+ )
)
-if not "_%2_" == "__" (
- set "trust=%2"
+
+:link_options
+if not "_%1_" == "__" (
+ set "link_ops=%link_ops% %~1"
+ shift
+ goto link_options
)
-rem Compiler.
+
+if not "_%compile_ops%_" == "__" (
+ set coptions="config.cc.coptions=%compile_ops:~1%"
+) else (
+ set "coptions=config.cc.coptions=/O2"
+)
+
+if not "_%link_ops%_" == "__" (
+ set loptions="config.cc.loptions=%link_ops:~1%"
+) else (
+ set "loptions="
+)
+
+rem Validate options and arguments.
rem
-rem if "_%1_" == "__" (
- set "cxx=cl"
-rem ) else (
-rem set "cxx=%1"
-rem )
rem If --no-bpkg is specified, then we require --local to also be specified
rem since it won't be possible to build things from packages without bpkg.
rem Also imply --no-bdep in this case, since bdep is pretty much useless
rem without bpkg.
rem
-if "_%bpkg%_" == "__" (
+if "_%bpkg_install%_" == "__" (
if "_%local%_" == "__" (
echo error: --no-bpkg can only be used for local installation
echo info: additionally specify --local
goto error
)
- set "bdep="
+ set "bdep_install="
)
for %%m in (%modules%) do (
@@ -220,18 +307,22 @@ rem Convert a relative path to an absolute.
rem
for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD"
+rem Translate the number of jobs into the bootstrap script and build2/bpkg
+rem options.
+rem
+if not "_%jobs%_" == "__" (
+ set "ops=/MP%jobs%"
+ set "jobs=-j %jobs%"
+) else (
+ set "ops="
+)
+
rem Certificate to trust.
rem
if not "_%trust%_" == "__" (
- if "_%trust%_" == "_yes_" (
- set "trust=--trust-yes"
- ) else (
- if "_%trust%_" == "_no_" (
- set "trust=--trust-no"
- ) else (
- set "trust=--trust %trust%"
- )
- )
+ if "_%trust%_" == "_yes_" (set "trust=--trust-yes"
+ ) else (if "_%trust%_" == "_no_" (set "trust=--trust-no"
+ ) else (set "trust=--trust %trust%"))
)
rem Network timeout.
@@ -251,6 +342,51 @@ if not exist %idir%\bin\ (
goto error
)
+rem Derive the to be installed executables names based on
+rem --exe-{prefix,suffix}. Unless the installation is local, also derive the
+rem staged executables names based on --stage-suffix and verify that they
+rem don't clash with existing filesystem entries as well as the executables
+rem being installed.
+rem
+set "b=%exe_prefix%b%exe_suffix%"
+set "bpkg=%exe_prefix%bpkg%exe_suffix%"
+set "bdep=%exe_prefix%bdep%exe_suffix%"
+
+if "_%local%_" == "__" (
+ set "b_stage=b%stage_suffix%"
+ set "bpkg_stage=bpkg%stage_suffix%"
+
+ if exist %idir%\bin\!b_stage!.exe (
+ echo error: staged executable name '!b_stage!' clashes with existing %idir%\bin\!b_stage!.exe
+ echo info: specify alternative staged executables name suffix with --stage-suffix
+ goto error
+ )
+
+ if exist %idir%\bin\!bpkg_stage!.exe (
+ echo error: staged executable name '!bpkg_stage!' clashes with existing %idir%\bin\!bpkg_stage!.exe
+ echo info: specify alternative staged executables name suffix with --stage-suffix
+ goto error
+ )
+
+ if "_%stage_suffix%_" == "_%exe_suffix%_" (
+ if "_%exe_prefix%_" == "__" (
+ echo error: suffix '%exe_suffix%' is used for both final and staged executables
+ echo info: specify alternative staged executables name suffix with --stage-suffix
+ goto error
+ )
+ )
+)
+
+set "conf_exe_affixes="
+
+if not "_%exe_prefix%_" == "__" (
+ set "conf_exe_affixes=config.bin.exe.prefix=%exe_prefix%"
+)
+
+if not "_%exe_suffix%_" == "__" (
+ set "conf_exe_affixes=%conf_exe_affixes% config.bin.exe.suffix=%exe_suffix%"
+)
+
if exist build\config.build (
echo error: current directory already configured, start with clean source
goto error
@@ -282,17 +418,20 @@ set "BDEP_DEF_OPT=0"
@rem Bootstrap.
@rem
+@rem Note: disable all warnings since we cannot do anything more granular
+@rem during bootstrap stage 1.
+@rem
cd build2
@rem Execute in a separate cmd.exe to preserve the echo mode.
@rem
-cmd /C bootstrap-msvc.bat %cxx%
+cmd /C bootstrap-msvc.bat %cxx% /w %ops%
@if errorlevel 1 goto error
build2\b-boot --version
@if errorlevel 1 goto error
-build2\b-boot %verbose% config.cxx=%cxx% config.bin.lib=static build2\exe{b}
+build2\b-boot %verbose% %jobs% config.cxx=%cxx% config.bin.lib=static build2\exe{b}
@if errorlevel 1 goto error
move /y build2\b.exe build2\b-boot.exe
@@ -308,49 +447,52 @@ cd ..
@if "_%local%_" == "__" goto stage
build2\build2\b-boot %verbose% configure^
+ config.config.hermetic=true^
config.cxx=%cxx%^
- config.cc.coptions=/O2^
+ %coptions%^
+ %loptions%^
config.bin.lib=shared^
- config.install.root=%idir%
+ config.install.root=%idir%^
+ %conf_exe_affixes%
@if errorlevel 1 goto error
@rem Install toolchain.
@rem
@set "projects=build2\"
-@if "_%bpkg%_" == "_true_" (
+@if "_%bpkg_install%_" == "_true_" (
set "projects=%projects% bpkg\"
)
-@if "_%bdep%_" == "_true_" (
+@if "_%bdep_install%_" == "_true_" (
set "projects=%projects% bdep\"
)
-build2\build2\b-boot %verbose% install: %projects%
+build2\build2\b-boot %verbose% %jobs% install: %projects%
@if errorlevel 1 goto error
-where b
+where %b%
@if errorlevel 1 goto error
-b --version
+%b% --version
@if errorlevel 1 goto error
-@if "_%bpkg%_" == "__" goto bpkg_vle
+@if "_%bpkg_install%_" == "__" goto bpkg_vle
-where bpkg
+where %bpkg%
@if errorlevel 1 goto error
-bpkg --version
+%bpkg% --version
@if errorlevel 1 goto error
:bpkg_vle
-@if "_%bdep%_" == "__" goto bdep_vle
+@if "_%bdep_install%_" == "__" goto bdep_vle
-where bdep
+where %bdep%
@if errorlevel 1 goto error
-bdep --version
+%bdep% --version
@if errorlevel 1 goto error
:bdep_vle
@@ -367,10 +509,10 @@ bdep --version
@if "_%projects%_" == "__" goto mods_ile
-b install: %projects:~1%
+%b% %verbose% %jobs% install: ^^!config.install.scope=project %projects:~1%
@if errorlevel 1 goto error
-b noop: %tests:~1%
+%b% %verbose% noop: %tests:~1%
@if errorlevel 1 goto error
:mods_ile
@@ -391,24 +533,24 @@ goto end
build2\build2\b-boot %verbose% configure^
config.cxx=%cxx%^
config.bin.lib=shared^
- config.bin.suffix=-stage^
+ config.bin.suffix=%stage_suffix%^
config.install.root=%idir%^
config.install.data_root=root\stage
@if errorlevel 1 goto error
-build2\build2\b-boot %verbose% install: build2\ bpkg\
+build2\build2\b-boot %verbose% %jobs% install: build2\ bpkg\
@if errorlevel 1 goto error
-where b-stage
+where %b_stage%
@if errorlevel 1 goto error
-b-stage --version
+%b_stage% --version
@if errorlevel 1 goto error
-where bpkg-stage
+where %bpkg_stage%
@if errorlevel 1 goto error
-bpkg-stage --version
+%bpkg_stage% --version
@if errorlevel 1 goto error
@rem Build the entire toolchain from packages.
@@ -424,50 +566,53 @@ cd %cdir%
@rem
@set "cdir=%CD%"
-bpkg-stage %verbose% create^
+%bpkg_stage% %verbose% create^
cc^
+ config.config.hermetic=true^
config.cxx=%cxx%^
- config.cc.coptions=/O2^
+ %coptions%^
+ %loptions%^
config.bin.lib=shared^
- config.install.root=%idir%
-@if errorlevel 1 goto error
-
-bpkg-stage %verbose% add %BUILD2_REPO%
-@if errorlevel 1 goto error
-
-bpkg-stage %verbose% %timeout% %trust% fetch
+ config.install.root=%idir%^
+ %conf_exe_affixes%
@if errorlevel 1 goto error
@set "packages=build2/%build2_ver% bpkg/%bpkg_ver%"
-@if "_%bdep%_" == "_true_" (
+@if "_%bdep_install%_" == "_true_" (
set "packages=%packages% bdep/%bdep_ver%"
)
-bpkg-stage %verbose% %timeout% build --for install --yes --plan= %packages%
+%bpkg_stage% %verbose% add %BUILD2_REPO%
+@if errorlevel 1 goto error
+
+%bpkg_stage% %verbose% %timeout% %trust% fetch
+@if errorlevel 1 goto error
+
+%bpkg_stage% %verbose% %jobs% %timeout% build --for install --yes --plan= %packages%
@if errorlevel 1 goto error
-bpkg-stage %verbose% install --all
+%bpkg_stage% %verbose% %jobs% install --all
@if errorlevel 1 goto error
-where b
+where %b%
@if errorlevel 1 goto error
-b --version
+%b% --version
@if errorlevel 1 goto error
-where bpkg
+where %bpkg%
@if errorlevel 1 goto error
-bpkg --version
+%bpkg% --version
@if errorlevel 1 goto error
-@if "_%bdep%_" == "__" goto bdep_vpe
+@if "_%bdep_install%_" == "__" goto bdep_vpe
-where bdep
+where %bdep%
@if errorlevel 1 goto error
-bdep --version
+%bdep% --version
@if errorlevel 1 goto error
:bdep_vpe
@@ -484,10 +629,10 @@ bdep --version
@if "_%packages%_" == "__" goto mods_ipe
-bpkg build --for install %packages:~1%
+%bpkg% %verbose% %jobs% %timeout% build --for install %packages:~1%
@if errorlevel 1 goto error
-bpkg install --all-pattern=libbuild2-*
+%bpkg% %verbose% %jobs% install ^^!config.install.scope=project --all-pattern=libbuild2-*
@if errorlevel 1 goto error
:mods_ipe
@@ -496,14 +641,14 @@ cd %owd%
@if "_%tests%_" == "__" goto mods_lpe
-b noop: %tests:~1%
+%b% %verbose% noop: %tests:~1%
@if errorlevel 1 goto error
:mods_lpe
@rem Clean up stage.
@rem
-b %verbose% uninstall: build2\ bpkg\
+%b% %verbose% %jobs% uninstall: build2\ bpkg\
@if errorlevel 1 goto error
@echo off