diff options
-rw-r--r-- | build-clang.bat.in | 76 | ||||
-rw-r--r-- | build-mingw.bat.in | 76 | ||||
-rw-r--r-- | build-msvc.bat.in | 66 | ||||
-rw-r--r-- | build.sh.in | 10 |
4 files changed, 169 insertions, 59 deletions
diff --git a/build-clang.bat.in b/build-clang.bat.in index bee0759..34e2726 100644 --- a/build-clang.bat.in +++ b/build-clang.bat.in @@ -16,6 +16,7 @@ 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 --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. @@ -27,6 +28,10 @@ echo install into C:\build2. It also expects to find the base utilities in the echo bin\ subdirectory of the installation directory ^(C:\build2\bin\ by echo default^). echo. +echo If --jobs^|-j is unspecified, then the bootstrap step is performed +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. @@ -36,6 +41,9 @@ echo additional make options, for example: echo. echo %0 --make mingw32-make --make -j8 echo. +echo If --jobs^|-j is specified, then its value is passed to make before +echo any additional options. +echo. echo The script by default installs the following standard build system echo modules: echo. @@ -84,9 +92,11 @@ set "bpkg=true" set "bdep=true" set "modules=%standard_modules%" set "idir=C:\build2" +set "jobs=" set "trust=" set "timeout=" set "make=" +set "make_options=" set "verbose=" :options @@ -136,6 +146,21 @@ if "_%~1_" == "_--install-dir_" ( 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=-j %~2" + shift + shift + goto options +) + if "_%~1_" == "_--trust_" ( if "_%~2_" == "__" ( echo error: certificate fingerprint expected after --trust @@ -174,7 +199,12 @@ if "_%~1_" == "_--make_" ( echo error: argument expected after --make goto error ) - set "make=%make% %~2" + + if "_%make%_" == "__" ( + set "make=%~2" + ) else ( + set "make_options=%make_options% %~2" + ) shift shift goto options @@ -204,6 +234,16 @@ if "_%1_" == "__" ( set "cxx=%1" ) +rem Merge jobs and make_options into make. +rem +if not "_%make%_" == "__" ( + if not "_%jobs%_" == "__" set "make=%make% %jobs%" + + rem Already has leading space. + rem + if not "_%make_options%_" == "__" set "make=!make!%make_options%" +) + 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 @@ -317,7 +357,7 @@ cmd /C bootstrap-clang.bat %cxx% build2\b-boot --version @if errorlevel 1 goto error -build2\b-boot %verbose% config.cxx=%cxx% config.cc.coptions=-m64 config.bin.lib=static build2\exe{b} +build2\b-boot %verbose% %jobs% config.cxx=%cxx% config.cc.coptions=-m64 config.bin.lib=static build2\exe{b} @if errorlevel 1 goto error move /y build2\b.exe build2\b-boot.exe @@ -351,7 +391,7 @@ build2\build2\b-boot %verbose% configure^ 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 @@ -392,10 +432,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b install: %projects:~1% +b %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b noop: %tests:~1% +b %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -422,7 +462,7 @@ build2\build2\b-boot %verbose% configure^ 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 @@ -458,22 +498,22 @@ bpkg-stage %verbose% create^ 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 -@if errorlevel 1 goto error - @set "packages=build2/%build2_ver% bpkg/%bpkg_ver%" @if "_%bdep%_" == "_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 @@ -510,10 +550,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 --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -522,14 +562,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 diff --git a/build-mingw.bat.in b/build-mingw.bat.in index 3289bd3..b9f5b0f 100644 --- a/build-mingw.bat.in +++ b/build-mingw.bat.in @@ -16,6 +16,7 @@ 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 --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,6 +27,10 @@ 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 If --jobs^|-j is unspecified, then the bootstrap step is performed +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. @@ -35,6 +40,9 @@ echo additional make options, for example: echo. echo %0 --make mingw32-make --make -j8 g++ echo. +echo If --jobs^|-j is specified, then its value is passed to make before +echo any additional options. +echo. echo The script by default installs the following standard build system echo modules: echo. @@ -83,9 +91,11 @@ set "bpkg=true" set "bdep=true" set "modules=%standard_modules%" set "idir=C:\build2" +set "jobs=" set "trust=" set "timeout=" set "make=" +set "make_options=" set "verbose=" :options @@ -135,6 +145,21 @@ if "_%~1_" == "_--install-dir_" ( 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=-j %~2" + shift + shift + goto options +) + if "_%~1_" == "_--trust_" ( if "_%~2_" == "__" ( echo error: certificate fingerprint expected after --trust @@ -173,7 +198,12 @@ if "_%~1_" == "_--make_" ( echo error: argument expected after --make goto error ) - set "make=%make% %~2" + + if "_%make%_" == "__" ( + set "make=%~2" + ) else ( + set "make_options=%make_options% %~2" + ) shift shift goto options @@ -213,6 +243,16 @@ if not "_%3_" == "__" ( set "trust=%3" ) +rem Merge jobs and make_options into make. +rem +if not "_%make%_" == "__" ( + if not "_%jobs%_" == "__" set "make=%make% %jobs%" + + rem Already has leading space. + rem + if not "_%make_options%_" == "__" set "make=!make!%make_options%" +) + 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 @@ -326,7 +366,7 @@ cmd /C bootstrap-mingw.bat %cxx% -static 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 @@ -360,7 +400,7 @@ build2\build2\b-boot %verbose% configure^ set "projects=%projects% bdep\" ) -build2\build2\b-boot %verbose% install: %projects% +build2\build2\b-boot %verbose% %jobs% install: %projects% @if errorlevel 1 goto error @rem The where command is not available on XP without the resource kit. @@ -403,10 +443,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b install: %projects:~1% +b %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b noop: %tests:~1% +b %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -432,7 +472,7 @@ build2\build2\b-boot %verbose% configure^ 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 @@ -468,22 +508,22 @@ bpkg-stage %verbose% create^ 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 -@if errorlevel 1 goto error - @set "packages=build2/%build2_ver% bpkg/%bpkg_ver%" @if "_%bdep%_" == "_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 @@ -520,10 +560,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 --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -532,14 +572,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 diff --git a/build-msvc.bat.in b/build-msvc.bat.in index bf00a6b..158b340 100644 --- a/build-msvc.bat.in +++ b/build-msvc.bat.in @@ -17,6 +17,7 @@ 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 --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,6 +27,9 @@ 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. @@ -77,6 +81,7 @@ set "bpkg=true" set "bdep=true" set "modules=%standard_modules%" set "idir=C:\build2" +set "jobs=" set "trust=" set "timeout=" set "verbose=" @@ -128,6 +133,21 @@ if "_%~1_" == "_--install-dir_" ( 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 @@ -220,6 +240,16 @@ 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%_" == "__" ( @@ -286,13 +316,13 @@ 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% %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 @@ -326,7 +356,7 @@ build2\build2\b-boot %verbose% configure^ 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 @@ -367,10 +397,10 @@ bdep --version @if "_%projects%_" == "__" goto mods_ile -b install: %projects:~1% +b %verbose% %jobs% install: %projects:~1% @if errorlevel 1 goto error -b noop: %tests:~1% +b %verbose% noop: %tests:~1% @if errorlevel 1 goto error :mods_ile @@ -396,7 +426,7 @@ build2\build2\b-boot %verbose% configure^ 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 @@ -432,22 +462,22 @@ bpkg-stage %verbose% create^ 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 -@if errorlevel 1 goto error - @set "packages=build2/%build2_ver% bpkg/%bpkg_ver%" @if "_%bdep%_" == "_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 @@ -484,10 +514,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 --all-pattern=libbuild2-* @if errorlevel 1 goto error :mods_ipe @@ -496,14 +526,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 diff --git a/build.sh.in b/build.sh.in index 0c48831..7368c77 100644 --- a/build.sh.in +++ b/build.sh.in @@ -482,8 +482,8 @@ $private done if test -n "$projects"; then - run b install: $projects - run b noop: $tests + run b $verbose $jobs install: $projects + run b $verbose noop: $tests fi diag @@ -563,14 +563,14 @@ for m in $module_list; do done if test -n "$packages"; then - run bpkg build --for install $packages - run bpkg install --all-pattern=libbuild2-* + run bpkg $verbose $jobs $bpkg_build_ops build --for install $packages + run bpkg $verbose $jobs install --all-pattern=libbuild2-* fi run cd "$owd" if test -n "$tests"; then - run b noop: $tests + run b $verbose noop: $tests fi # Clean up stage. |