diff options
-rw-r--r-- | bootstrap-mingw.bat | 99 | ||||
-rw-r--r-- | bootstrap-msvc.bat | 142 | ||||
-rwxr-xr-x | bootstrap.sh | 4 | ||||
-rw-r--r-- | buildfile | 3 |
4 files changed, 247 insertions, 1 deletions
diff --git a/bootstrap-mingw.bat b/bootstrap-mingw.bat new file mode 100644 index 0000000..9b0a5f7 --- /dev/null +++ b/bootstrap-mingw.bat @@ -0,0 +1,99 @@ +@echo off + +rem file : bootstrap-mingw.bat +rem copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +rem license : MIT; see accompanying LICENSE file + +setlocal +goto start + +:usage +echo. +echo Usage: %0 [/?] [cxx [cxx-option...]] +echo. +echo The batch file expects to find the libbutl\ or libbutl-*\ directory +echo either in the current directory (build2 root) or one level up. +echo. +echo Note that is any cxx-option arguments are specified, then they must +echo be preceded by the compiler executable (use g++ as the default). For +echo example: +echo. +echo %0 g++ -O3 +echo. +goto end + +:start + +if "_%1_" == "_/?_" goto usage + +rem See if there is libbutl or libbutl-* in the current directory and one +rem directory up. Note that globbing returns paths in alphabetic order. +rem +if exist libbutl\ ( + set "libbutl=libbutl" +) else ( + for /D %%d in (libbutl-*) do set "libbutl=%%d" +) + +if "_%libbutl%_" == "__" ( + if exist ..\libbutl\ ( + set "libbutl=..\libbutl" + ) else ( + for /D %%d in (..\libbutl-*) do set "libbutl=%%d" + ) +) + +if "_%libbutl%_" == "__" ( + echo error: unable to find libbutl, run %0 /? for details + goto error +) + +rem All the source directories. +rem +set "src=build2\*.cxx" +set "src=%src% build2\config\*.cxx" +set "src=%src% build2\dist\*.cxx" +set "src=%src% build2\bin\*.cxx" +set "src=%src% build2\c\*.cxx" +set "src=%src% build2\cc\*.cxx" +set "src=%src% build2\cxx\*.cxx" +set "src=%src% build2\cli\*.cxx" +set "src=%src% build2\test\*.cxx" +set "src=%src% build2\install\*.cxx" +set "src=%src% %libbutl%\butl\*.cxx" + +rem Get the compiler executable. +rem +if "_%1_" == "__" ( + set "cxx=g++" +) else ( + set "cxx=%1" +) + +rem Get the compile options. +rem +set "ops=-std=c++1y -static" +:ops_next +shift +if "_%1_" == "__" ( + goto ops_done +) else ( + set "ops=%ops% %1" + goto ops_next +) +:ops_done + +rem Compile. +rem +echo %cxx% -I%libbutl% -I. -DBUILD2_HOST_TRIPLET=\"i686-w64-mingw32\" %ops% -o build2\b-boot.exe %src% + %cxx% -I%libbutl% -I. -DBUILD2_HOST_TRIPLET=\"i686-w64-mingw32\" %ops% -o build2\b-boot.exe %src% +if errorlevel 1 goto error + +goto end + +:error +endlocal +exit /b 1 + +:end +endlocal diff --git a/bootstrap-msvc.bat b/bootstrap-msvc.bat new file mode 100644 index 0000000..459fe1a --- /dev/null +++ b/bootstrap-msvc.bat @@ -0,0 +1,142 @@ +@echo off + +rem file : bootstrap-msvc.bat +rem copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +rem license : MIT; see accompanying LICENSE file + +setlocal EnableDelayedExpansion +goto start + +:usage +echo. +echo Usage: %0 [/?] [cl-exe [cl-option...]] +echo. +echo Normally this batch file is executed from one of the Visual Studio +echo command prompts. It assume that the VC compiler can be executed as +echo just cl.exe and that all the relevant environment variables (INCLUDE, +echo LIB) are set. +echo. +echo The batch file expects to find the libbutl\ or libbutl-*\ directory +echo either in the current directory (build2 root) or one level up. +echo. +echo Note that is any cl-option arguments are specified, then they must be +echo preceded by the VC compiler executable (use cl.exe as the default). +echo For example: +echo. +echo %0 cl.exe /nologo +echo. +goto end + +rem Clean up .obj files from all the directories passed as arguments. +rem +:clean_obj + for %%d in (%*) do ( + if exist %%d\*.obj del %%d\*.obj + ) +goto :eof + +:start + +if "_%1_" == "_/?_" goto usage + +rem See if there is libbutl or libbutl-* in the current directory and one +rem directory up. Note that globbing returns paths in alphabetic order. +rem +if exist libbutl\ ( + set "libbutl=libbutl" +) else ( + for /D %%d in (libbutl-*) do set "libbutl=%%d" +) + +if "_%libbutl%_" == "__" ( + if exist ..\libbutl\ ( + set "libbutl=..\libbutl" + ) else ( + for /D %%d in (..\libbutl-*) do set "libbutl=%%d" + ) +) + +if "_%libbutl%_" == "__" ( + echo error: unable to find libbutl, run %0 /? for details + goto error +) + +rem All the source directories. +rem +set "src=build2" +set "src=%src% build2\config" +set "src=%src% build2\dist" +set "src=%src% build2\bin" +set "src=%src% build2\c" +set "src=%src% build2\cc" +set "src=%src% build2\cxx" +set "src=%src% build2\cli" +set "src=%src% build2\test" +set "src=%src% build2\install" +set "src=%src% %libbutl%\butl" + +rem Get the compiler executable. +rem +if "_%1_" == "__" ( + set "cxx=cl.exe" +) else ( + set "cxx=%1" +) + +rem Get the compile options. +rem +set "ops=/EHsc /MT /MP" +:ops_next +shift +if "_%1_" == "__" ( + goto ops_done +) else ( + set "ops=%ops% %1" + goto ops_next +) +:ops_done + +rem First clean up any stale .obj files we might have laying around. +rem +call :clean_obj %src% + +rem Compile. +rem +rem VC dumps .obj files in the current directory not caring if the names +rem clash. And boy do they clash. +rem +set "obj=" +set "cwd=%CD%" +for %%d in (%src%) do ( + echo. + echo compiling in %%d\ + echo. + cd %%d + echo %cxx% /I%cwd%\%libbutl% /I%cwd% /DBUILD2_HOST_TRIPLET=\"i686-microsoft-win32-msvc\" %ops% /c /TP *.cxx + %cxx% /I%cwd%\%libbutl% /I%cwd% /DBUILD2_HOST_TRIPLET=\"i686-microsoft-win32-msvc\" %ops% /c /TP *.cxx + if errorlevel 1 ( + cd %cwd% + goto error + ) + cd %cwd% + set "obj=!obj! %%d\*.obj" +) + +rem Link. +rem +echo. +echo %cxx% %ops% /Fe: build2\b-boot.exe %obj% shell32.lib + %cxx% %ops% /Fe: build2\b-boot.exe %obj% shell32.lib +if errorlevel 1 goto error + +rem Clean up .obj. +rem +call :clean_obj %src% +goto end + +:error +endlocal +exit /b 1 + +:end +endlocal diff --git a/bootstrap.sh b/bootstrap.sh index 24261b8..232f7e2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,9 @@ #!/bin/sh +# file : bootstrap.sh +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + usage="Usage: $0 [--help] [--cxx <compiler>] [--cxxflags <flags>] [<host>]" cxx=g++ @@ -6,7 +6,8 @@ d = build2/ tests/ doc/ ./: $d \ doc{INSTALL LICENSE NEWS README version} \ -file{INSTALL.cli config.guess config.sub bootstrap.sh manifest} +file{bootstrap.sh bootstrap-msvc.bat bootstrap-mingw.bat} \ +file{INSTALL.cli config.guess config.sub manifest} include $d |