diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-03-03 20:18:01 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-03-08 11:08:05 +0300 |
commit | 078db5116f34ccf006c1e610c7a7ebadbc6f7aca (patch) | |
tree | 6a0aad0e4c443fdb9c15b8db6a3182238bb050a0 | |
parent | 89684a3074b4bbfd402d1596f0c30eea18c50ed8 (diff) |
Add --exe-{prefix,suffix} and --stage-suffix to build batch files
-rw-r--r-- | BOOTSTRAP-UNIX.cli | 2 | ||||
-rw-r--r-- | BOOTSTRAP-WINDOWS-CLANG.cli | 6 | ||||
-rw-r--r-- | BOOTSTRAP-WINDOWS-MINGW.cli | 6 | ||||
-rw-r--r-- | BOOTSTRAP-WINDOWS-MSVC.cli | 6 | ||||
-rw-r--r-- | UPGRADE.cli | 9 | ||||
-rw-r--r-- | build-clang.bat.in | 186 | ||||
-rw-r--r-- | build-mingw.bat.in | 190 | ||||
-rw-r--r-- | build-msvc.bat.in | 186 |
8 files changed, 425 insertions, 166 deletions
diff --git a/BOOTSTRAP-UNIX.cli b/BOOTSTRAP-UNIX.cli index abffc6d..5ffa6b2 100644 --- a/BOOTSTRAP-UNIX.cli +++ b/BOOTSTRAP-UNIX.cli @@ -297,7 +297,7 @@ and that any further such installations won't interfere with \c{build2}. If, however, you are installing into a private location, such as \c{/opt/build2/}, then you can remove \c{config.install.private=build2}.| -\N|To add a custom suffix/prefix to the toolchain executables names, add +\N|To add a custom prefix/suffix to the toolchain executables names, add \c{config.bin.exe.prefix=...} and/or \c{config.bin.exe.suffix=...}.| Next, we add the package repository, build, and install: diff --git a/BOOTSTRAP-WINDOWS-CLANG.cli b/BOOTSTRAP-WINDOWS-CLANG.cli index 694fa91..35b0c57 100644 --- a/BOOTSTRAP-WINDOWS-CLANG.cli +++ b/BOOTSTRAP-WINDOWS-CLANG.cli @@ -154,7 +154,8 @@ pass the \c{--local} option.| To perform a local installation you will need to change the \c{configure} and \c{install} command lines above along these lines (see also a note on the -following step about only building shared libraries): +following step about only building shared libraries and toolchain executables +prefix/suffix): \ > build2\build2\b-boot configure ^ @@ -212,6 +213,9 @@ previous step and you may want/need to make similar adjustments. \N|The above configuration will only build shared libraries. If you would like to build both shared and static, remove \c{config.bin.lib=shared}.| +\N|To add a custom prefix/suffix to the toolchain executables names, add +\c{config.bin.exe.prefix=...} and/or \c{config.bin.exe.suffix=...}.| + Next, we add the package repository, build, and install: \ diff --git a/BOOTSTRAP-WINDOWS-MINGW.cli b/BOOTSTRAP-WINDOWS-MINGW.cli index 4ed9049..825c36e 100644 --- a/BOOTSTRAP-WINDOWS-MINGW.cli +++ b/BOOTSTRAP-WINDOWS-MINGW.cli @@ -156,7 +156,8 @@ pass the \c{--local} option.| To perform a local installation you will need to change the \c{configure} and \c{install} command lines above along these lines (see also a note on the -following step about only building shared libraries): +following step about only building shared libraries and toolchain executables +prefix/suffix): \ > build2\build2\b-boot configure ^ @@ -214,6 +215,9 @@ previous step and you may want/need to make similar adjustments. \N|The above configuration will only build shared libraries. If you would like to build both shared and static, remove \c{config.bin.lib=shared}.| +\N|To add a custom prefix/suffix to the toolchain executables names, add +\c{config.bin.exe.prefix=...} and/or \c{config.bin.exe.suffix=...}.| + Next, we add the package repository, build, and install: \ diff --git a/BOOTSTRAP-WINDOWS-MSVC.cli b/BOOTSTRAP-WINDOWS-MSVC.cli index dbe5ede..6ac26f0 100644 --- a/BOOTSTRAP-WINDOWS-MSVC.cli +++ b/BOOTSTRAP-WINDOWS-MSVC.cli @@ -128,7 +128,8 @@ pass the \c{--local} option.| To perform a local installation you will need to change the \c{configure} and \c{install} command lines above along these lines (see also a note on the -following step about only building shared libraries): +following step about only building shared libraries and toolchain executables +prefix/suffix): \ > build2\build2\b-boot configure ^ @@ -186,6 +187,9 @@ previous step and you may want/need to make similar adjustments. \N|The above configuration will only build shared libraries. If you would like to build both shared and static, remove \c{config.bin.lib=shared}.| +\N|To add a custom prefix/suffix to the toolchain executables names, add +\c{config.bin.exe.prefix=...} and/or \c{config.bin.exe.suffix=...}.| + Next, we add the package repository, build, and install: \ diff --git a/UPGRADE.cli b/UPGRADE.cli index 066153f..b51f538 100644 --- a/UPGRADE.cli +++ b/UPGRADE.cli @@ -133,6 +133,12 @@ $ bpkg install \ --all \ +\N|If during installation you have added a custom prefix/suffix to the +toolchain executables names with \c{config.bin.exe.prefix} and/or +\c{config.bin.exe.suffix}, add \c{config.bin.exe.prefix=[null]} and/or +\c{config.bin.exe.suffix=[null]} to suppress them in the executables being +staged.| + You can also specify the desired packages and/or versions explicitly, again, similar to the dirty upgrade.| @@ -169,7 +175,8 @@ $ bpkg-stage install --all Finally, we clean up by removing the staged toolchain (hint: use the command line history to find the corresponding \c{install} command and change it to -\c{uninstall}): +\c{uninstall}; see also a note at step 2 about toolchain executables +prefix/suffix): \ $ bpkg uninstall \ diff --git a/build-clang.bat.in b/build-clang.bat.in index 34e2726..5df2af7 100644 --- a/build-clang.bat.in +++ b/build-clang.bat.in @@ -11,11 +11,14 @@ echo. echo Usage: %0 [/?] [^<options^>] [^<clang++-compiler^>] 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. @@ -33,7 +36,7 @@ echo serially with the rest of the process using the number of available echo hardware threads. 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 --make option can be used to bootstrap using GNU make. The first echo --make value should specify the make executable optionally followed by @@ -88,10 +91,13 @@ 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=" @@ -111,13 +117,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 ) @@ -146,6 +152,39 @@ 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" @@ -249,14 +288,14 @@ 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 ( @@ -274,15 +313,9 @@ for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD" 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. @@ -302,6 +335,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 @@ -376,46 +454,47 @@ build2\build2\b-boot %verbose% configure^ config.cxx=%cxx%^ "config.cc.coptions=-m64 -O2"^ 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% %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 @@ -432,10 +511,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b %verbose% %jobs% install: %projects:~1% +%b% %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -457,7 +536,7 @@ build2\build2\b-boot %verbose% configure^ config.cxx=%cxx%^ config.cc.coptions=-m64^ 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 @@ -465,16 +544,16 @@ build2\build2\b-boot %verbose% configure^ 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. @@ -490,50 +569,51 @@ cd %cdir% @rem @set "cdir=%CD%" -bpkg-stage %verbose% create^ +%bpkg_stage% %verbose% create^ cc^ config.cxx=%cxx%^ "config.cc.coptions=-m64 -O2"^ config.bin.lib=shared^ - config.install.root=%idir% + 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% add %BUILD2_REPO% +%bpkg_stage% %verbose% add %BUILD2_REPO% @if errorlevel 1 goto error -bpkg-stage %verbose% %timeout% %trust% fetch +%bpkg_stage% %verbose% %timeout% %trust% fetch @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% +%bpkg_stage% %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% 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 @@ -550,10 +630,10 @@ bdep --version @if "_%packages%_" == "__" goto mods_ipe -bpkg %verbose% %jobs% %timeout% build --for install %packages:~1% +%bpkg% %verbose% %jobs% %timeout% build --for install %packages:~1% @if errorlevel 1 goto error -bpkg %verbose% %jobs% install --all-pattern=libbuild2-* +%bpkg% %verbose% %jobs% install --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -562,14 +642,14 @@ cd %owd% @if "_%tests%_" == "__" goto mods_lpe -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_lpe @rem Clean up stage. @rem -b %verbose% %jobs% uninstall: build2\ bpkg\ +%b% %verbose% %jobs% uninstall: build2\ bpkg\ @if errorlevel 1 goto error @echo off diff --git a/build-mingw.bat.in b/build-mingw.bat.in index 446bfc9..af2276f 100644 --- a/build-mingw.bat.in +++ b/build-mingw.bat.in @@ -11,11 +11,14 @@ echo. echo Usage: %0 [/?] [^<options^>] ^<c++-compiler^> 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. @@ -32,7 +35,7 @@ echo serially with the rest of the process using the number of available echo hardware threads. 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 --make option can be used to bootstrap using GNU make. The first echo --make value should specify the make executable optionally followed by @@ -73,8 +76,8 @@ set "bdep_ver=@BDEP_VERSION@" rem Standard modules comma-separated list and versions. rem -rem NOTE: we currently print the list as a single line and will need to somehow -rem change that when it becomes too long. +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 "kconfig_ver=@KCONFIG_VERSION@" @@ -87,10 +90,13 @@ 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=" @@ -110,13 +116,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 ) @@ -145,6 +151,39 @@ 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" @@ -258,14 +297,14 @@ 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 ( @@ -283,15 +322,9 @@ for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD" 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. @@ -311,6 +344,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 @@ -385,18 +463,19 @@ build2\build2\b-boot %verbose% configure^ config.cxx=%cxx%^ config.cc.coptions=-O2^ 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\" ) @@ -405,28 +484,28 @@ build2\build2\b-boot %verbose% %jobs% install: %projects% @rem The where command is not available on XP without the resource kit. @rem -where b +where %b% @rem @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% @rem @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% @rem @if errorlevel 1 goto error -bdep --version +%bdep% --version @if errorlevel 1 goto error :bdep_vle @@ -443,10 +522,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b %verbose% %jobs% install: %projects:~1% +%b% %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -467,7 +546,7 @@ 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 @@ -475,16 +554,16 @@ build2\build2\b-boot %verbose% configure^ build2\build2\b-boot %verbose% %jobs% install: build2\ bpkg\ @if errorlevel 1 goto error -where b-stage +where %b_stage% @rem @if errorlevel 1 goto error -b-stage --version +%b_stage% --version @if errorlevel 1 goto error -where bpkg-stage +where %bpkg_stage% @rem @if errorlevel 1 goto error -bpkg-stage --version +%bpkg_stage% --version @if errorlevel 1 goto error @rem Build the entire toolchain from packages. @@ -500,50 +579,51 @@ cd %cdir% @rem @set "cdir=%CD%" -bpkg-stage %verbose% create^ +%bpkg_stage% %verbose% create^ cc^ config.cxx=%cxx%^ config.cc.coptions=-O2^ config.bin.lib=shared^ - config.install.root=%idir% + 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% add %BUILD2_REPO% +%bpkg_stage% %verbose% add %BUILD2_REPO% @if errorlevel 1 goto error -bpkg-stage %verbose% %timeout% %trust% fetch +%bpkg_stage% %verbose% %timeout% %trust% fetch @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% +%bpkg_stage% %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% install --all +%bpkg_stage% %verbose% %jobs% install --all @if errorlevel 1 goto error -where b +where %b% @rem @if errorlevel 1 goto error -b --version +%b% --version @if errorlevel 1 goto error -where bpkg +where %bpkg% @rem @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% @rem @if errorlevel 1 goto error -bdep --version +%bdep% --version @if errorlevel 1 goto error :bdep_vpe @@ -560,10 +640,10 @@ bdep --version @if "_%packages%_" == "__" goto mods_ipe -bpkg %verbose% %jobs% %timeout% build --for install %packages:~1% +%bpkg% %verbose% %jobs% %timeout% build --for install %packages:~1% @if errorlevel 1 goto error -bpkg %verbose% %jobs% install --all-pattern=libbuild2-* +%bpkg% %verbose% %jobs% install --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -572,14 +652,14 @@ cd %owd% @if "_%tests%_" == "__" goto mods_lpe -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_lpe @rem Clean up stage. @rem -b %verbose% %jobs% uninstall: build2\ bpkg\ +%b% %verbose% %jobs% uninstall: build2\ bpkg\ @if errorlevel 1 goto error @echo off diff --git a/build-msvc.bat.in b/build-msvc.bat.in index 158b340..6fcad79 100644 --- a/build-msvc.bat.in +++ b/build-msvc.bat.in @@ -12,11 +12,14 @@ rem echo Usage: %0 [/?] [^<options^>] [^<cl-compiler^>] echo Usage: %0 [/?] [^<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. @@ -31,7 +34,7 @@ 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: @@ -77,10 +80,13 @@ 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=" @@ -98,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 ) @@ -133,6 +139,39 @@ 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" @@ -218,14 +257,14 @@ 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 ( @@ -253,15 +292,9 @@ if not "_%jobs%_" == "__" ( 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. @@ -281,6 +314,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 @@ -341,46 +419,47 @@ build2\build2\b-boot %verbose% configure^ config.cxx=%cxx%^ config.cc.coptions=/O2^ 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% %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 @@ -397,10 +476,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b %verbose% %jobs% install: %projects:~1% +%b% %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -421,7 +500,7 @@ 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 @@ -429,16 +508,16 @@ build2\build2\b-boot %verbose% configure^ 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. @@ -454,50 +533,51 @@ cd %cdir% @rem @set "cdir=%CD%" -bpkg-stage %verbose% create^ +%bpkg_stage% %verbose% create^ cc^ config.cxx=%cxx%^ config.cc.coptions=/O2^ config.bin.lib=shared^ - config.install.root=%idir% + 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% add %BUILD2_REPO% +%bpkg_stage% %verbose% add %BUILD2_REPO% @if errorlevel 1 goto error -bpkg-stage %verbose% %timeout% %trust% fetch +%bpkg_stage% %verbose% %timeout% %trust% fetch @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% +%bpkg_stage% %verbose% %jobs% %timeout% build --for install --yes --plan= %packages% @if errorlevel 1 goto error -bpkg-stage %verbose% %jobs% 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 @@ -514,10 +594,10 @@ bdep --version @if "_%packages%_" == "__" goto mods_ipe -bpkg %verbose% %jobs% %timeout% build --for install %packages:~1% +%bpkg% %verbose% %jobs% %timeout% build --for install %packages:~1% @if errorlevel 1 goto error -bpkg %verbose% %jobs% install --all-pattern=libbuild2-* +%bpkg% %verbose% %jobs% install --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -526,14 +606,14 @@ cd %owd% @if "_%tests%_" == "__" goto mods_lpe -b %verbose% noop: %tests:~1% +%b% %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_lpe @rem Clean up stage. @rem -b %verbose% %jobs% uninstall: build2\ bpkg\ +%b% %verbose% %jobs% uninstall: build2\ bpkg\ @if errorlevel 1 goto error @echo off |