Skip to content

Commit e3de87d

Browse files
committed
Script build-msvc.cmd --build-mode, --build-symbols, argument passing and alter installation flags sanitization to rely on last writer wins.
1 parent 233945b commit e3de87d

4 files changed

Lines changed: 88 additions & 51 deletions

File tree

builds/cmake/install-cmake.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ main()
105105
(--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";;
106106
(--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";;
107107
(--build-parallel=*) PARALLEL="${OPTION#*=}";;
108+
(--build-skip-tests) BUILD_SKIP_TESTS="yes";;
108109
(--prefix=*) PREFIX="${OPTION#*=}";;
109110
(--verbose) DISPLAY_VERBOSE="yes";;
110111
(--help|-h) DISPLAY_HELP="yes";;
@@ -323,8 +324,7 @@ main()
323324
msg_verbose "Exporting CFLAGS '${CFLAGS}'"
324325
else
325326
msg_verbose "CFLAGS initially '${CFLAGS}'"
326-
SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS")
327-
export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}"
327+
export CFLAGS="${CFLAGS} ${BUILD_FLAGS}"
328328
msg_verbose "CFLAGS modified to '${CFLAGS}'"
329329
fi
330330

@@ -333,8 +333,7 @@ main()
333333
msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'"
334334
else
335335
msg_verbose "CXXFLAGS initially '${CXXFLAGS}'"
336-
SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS")
337-
export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}"
336+
export CXXFLAGS="${CXXFLAGS} ${BUILD_FLAGS}"
338337
msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'"
339338
fi
340339
fi
@@ -494,7 +493,9 @@ main()
494493
local SAVE_CPPFLAGS="${CPPFLAGS}"
495494
export CPPFLAGS="${CPPFLAGS} ${libbitcoin_server_FLAGS[@]}"
496495
build_cmake "libbitcoin-server" "builds/cmake" "${PARALLEL}" "${libbitcoin_server_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}"
497-
test_make "libbitcoin-server" "test" "${PARALLEL}"
496+
if ! [[ "${BUILD_SKIP_TESTS}" == "yes" ]]; then
497+
test_make "libbitcoin-server" "test" "${PARALLEL}"
498+
fi
498499
install_make "libbitcoin-server"
499500
export CPPFLAGS="${SAVE_CPPFLAGS}"
500501

@@ -806,6 +807,7 @@ display_build_variables()
806807
msg "BUILD_LINK : ${BUILD_LINK}"
807808
msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}"
808809
msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}"
810+
msg "BUILD_SKIP_TESTS : ${BUILD_SKIP_TESTS}"
809811
msg "PARALLEL : ${PARALLEL}"
810812
msg "PREFIX : ${PREFIX}"
811813
msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}"
@@ -908,16 +910,6 @@ disable_exit_on_error()
908910
eval "${OPTS_DISABLE}"
909911
}
910912

911-
strip_optimization()
912-
{
913-
echo "$1" | sed -E '
914-
s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g
915-
s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g
916-
s/[[:space:]]+/ /g
917-
s/^ | $//g
918-
'
919-
}
920-
921913
create_directory()
922914
{
923915
local DIRECTORY="$1"

builds/cmake/install-presets.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ main()
9393
(--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";;
9494
(--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";;
9595
(--build-parallel=*) PARALLEL="${OPTION#*=}";;
96+
(--build-skip-tests) BUILD_SKIP_TESTS="yes";;
9697
(--verbose) DISPLAY_VERBOSE="yes";;
9798
(--help|-h) DISPLAY_HELP="yes";;
9899
(-DCMAKE_PREFIX_PATH=*) CMAKE_PREFIX_PATH="${OPTION#*=}";;
@@ -344,8 +345,7 @@ main()
344345
msg_verbose "Exporting CFLAGS '${CFLAGS}'"
345346
else
346347
msg_verbose "CFLAGS initially '${CFLAGS}'"
347-
SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS")
348-
export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}"
348+
export CFLAGS="${CFLAGS} ${BUILD_FLAGS}"
349349
msg_verbose "CFLAGS modified to '${CFLAGS}'"
350350
fi
351351

@@ -354,8 +354,7 @@ main()
354354
msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'"
355355
else
356356
msg_verbose "CXXFLAGS initially '${CXXFLAGS}'"
357-
SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS")
358-
export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}"
357+
export CXXFLAGS="${CXXFLAGS} ${BUILD_FLAGS}"
359358
msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'"
360359
fi
361360
fi
@@ -515,7 +514,9 @@ main()
515514
local SAVE_CPPFLAGS="${CPPFLAGS}"
516515
export CPPFLAGS="${CPPFLAGS} ${libbitcoin_server_FLAGS[@]}"
517516
build_preset "libbitcoin-server" "builds/cmake" "${PARALLEL}" "${libbitcoin_server_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}"
518-
test_make "libbitcoin-server" "test" "${PARALLEL}"
517+
if ! [[ "${BUILD_SKIP_TESTS}" == "yes" ]]; then
518+
test_make "libbitcoin-server" "test" "${PARALLEL}"
519+
fi
519520
install_make "libbitcoin-server"
520521
export CPPFLAGS="${SAVE_CPPFLAGS}"
521522

@@ -878,6 +879,7 @@ display_build_variables()
878879
msg "BUILD_LINK : ${BUILD_LINK}"
879880
msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}"
880881
msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}"
882+
msg "BUILD_SKIP_TESTS : ${BUILD_SKIP_TESTS}"
881883
msg "PARALLEL : ${PARALLEL}"
882884
msg "PREFIX : ${PREFIX}"
883885
msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}"
@@ -971,16 +973,6 @@ disable_exit_on_error()
971973
eval "${OPTS_DISABLE}"
972974
}
973975

974-
strip_optimization()
975-
{
976-
echo "$1" | sed -E '
977-
s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g
978-
s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g
979-
s/[[:space:]]+/ /g
980-
s/^ | $//g
981-
'
982-
}
983-
984976
create_directory()
985977
{
986978
local DIRECTORY="$1"

builds/gnu/install-gnu.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ main()
105105
(--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";;
106106
(--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";;
107107
(--build-parallel=*) PARALLEL="${OPTION#*=}";;
108+
(--build-skip-tests) BUILD_SKIP_TESTS="yes";;
108109
(--prefix=*) PREFIX="${OPTION#*=}";;
109110
(--verbose) DISPLAY_VERBOSE="yes";;
110111
(--help|-h) DISPLAY_HELP="yes";;
@@ -302,8 +303,7 @@ main()
302303
msg_verbose "Exporting CFLAGS '${CFLAGS}'"
303304
else
304305
msg_verbose "CFLAGS initially '${CFLAGS}'"
305-
SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS")
306-
export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}"
306+
export CFLAGS="${CFLAGS} ${BUILD_FLAGS}"
307307
msg_verbose "CFLAGS modified to '${CFLAGS}'"
308308
fi
309309

@@ -312,8 +312,7 @@ main()
312312
msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'"
313313
else
314314
msg_verbose "CXXFLAGS initially '${CXXFLAGS}'"
315-
SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS")
316-
export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}"
315+
export CXXFLAGS="${CXXFLAGS} ${BUILD_FLAGS}"
317316
msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'"
318317
fi
319318
fi
@@ -485,7 +484,9 @@ main()
485484
local SAVE_CPPFLAGS="${CPPFLAGS}"
486485
export CPPFLAGS="${CPPFLAGS} ${libbitcoin_server_FLAGS[@]}"
487486
build_gnu "libbitcoin-server" "." "${PARALLEL}" "${libbitcoin_server_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}"
488-
test_make "libbitcoin-server" "check" "${PARALLEL}"
487+
if ! [[ "${BUILD_SKIP_TESTS}" == "yes" ]]; then
488+
test_make "libbitcoin-server" "check" "${PARALLEL}"
489+
fi
489490
install_make "libbitcoin-server"
490491
export CPPFLAGS="${SAVE_CPPFLAGS}"
491492

@@ -802,6 +803,7 @@ display_build_variables()
802803
msg "BUILD_LINK : ${BUILD_LINK}"
803804
msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}"
804805
msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}"
806+
msg "BUILD_SKIP_TESTS : ${BUILD_SKIP_TESTS}"
805807
msg "PARALLEL : ${PARALLEL}"
806808
msg "PREFIX : ${PREFIX}"
807809
msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}"
@@ -900,16 +902,6 @@ disable_exit_on_error()
900902
eval "${OPTS_DISABLE}"
901903
}
902904

903-
strip_optimization()
904-
{
905-
echo "$1" | sed -E '
906-
s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g
907-
s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g
908-
s/[[:space:]]+/ /g
909-
s/^ | $//g
910-
'
911-
}
912-
913905
create_directory()
914906
{
915907
local DIRECTORY="$1"

builds/msvc/build-msvc.cmd

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ REM --build-version version Build MSVC version.
1717
REM --build-src-dir path Location of sources.
1818
REM --build-full-repositories Sync full github repositories.
1919
REM --build-use-local-src Use existing sources in build-src-dir path.
20+
REM --build-mode mode Determines action on target.
21+
REM Default: Rebuild
22+
REM --build-symbols mode Determines treatment of symbols.
23+
REM Values: default, disabled, public-only
2024
REM --verbose Display verbose script output.
2125
REM --help, -h Display usage, overriding script execution.
2226
REM
@@ -134,6 +138,20 @@ if "!libbitcoin_server_TAG!" == "" (
134138
)
135139
)
136140

141+
if "!BUILD_SYMBOLS!" == "" (
142+
call :msg_verbose "BUILD_SYMBOLS not defined or empty, defaulting to 'default' behavior."
143+
) else if "!BUILD_SYMBOLS!" == "default" (
144+
call :msg_verbose "BUILD_SYMBOLS 'default'."
145+
) else if "!BUILD_SYMBOLS!" == "disabled" (
146+
call :msg_verbose "BUILD_SYMBOLS 'disabled'."
147+
) else if "!BUILD_SYMBOLS!" == "public-only" (
148+
call :msg_verbose "BUILD_SYMBOLS 'public-only'."
149+
) else (
150+
call :msg_error "BUILD_SYMBOLS value '!BUILD_SYMBOLS!' unrecognized."
151+
call :help
152+
exit /b 1
153+
)
154+
137155
call :msg_heading "Configuration"
138156
call :display_build_variables
139157

@@ -190,10 +208,20 @@ if "!libbitcoin_server_TAG!" == "" (
190208
if %ERRORLEVEL% neq 0 (
191209
exit /b %ERRORLEVEL%
192210
)
193-
call :build_msbuild "libbitcoin-server" "builds\msvc\%proj_version%"
211+
call :build_msbuild "libbitcoin-server" "builds\msvc\%proj_version%" "libbitcoin-server"
212+
if %ERRORLEVEL% neq 0 (
213+
exit /b %ERRORLEVEL%
214+
)
215+
call :build_msbuild "libbitcoin-server" "builds\msvc\%proj_version%" "bs"
216+
if %ERRORLEVEL% neq 0 (
217+
exit /b %ERRORLEVEL%
218+
)
219+
if not "!BUILD_SKIP_TESTS!" == "yes" (
220+
call :build_msbuild "libbitcoin-server" "builds\msvc\%proj_version%" "libbitcoin-server-test"
194221
if %ERRORLEVEL% neq 0 (
195222
exit /b %ERRORLEVEL%
196223
)
224+
)
197225

198226
call :pop_directory
199227
if %ERRORLEVEL% neq 0 (
@@ -222,10 +250,18 @@ if "!libbitcoin_server_TAG!" == "" (
222250
) else if "%~1" == "--build-version" (
223251
set "BUILD_VERSION=%~2"
224252
shift
253+
) else if "%!1" == "--build-mode" (
254+
set "BUILD_MODE=%~2"
255+
shift
256+
) else if "%!1" == "--build-symbols" (
257+
set "BUILD_SYMBOLS=%~2"
258+
shift
225259
) else if "%~1" == "--build-full-repositories" (
226260
set "BUILD_FULL_REPOSITORIES=yes"
227261
) else if "%~1" == "--build-use-local-src" (
228262
set "BUILD_USE_LOCAL_SRC=yes"
263+
) else if "%~1" == "--build-skip-tests" (
264+
set "BUILD_SKIP_TESTS=yes"
229265
) else if "%~1" == "--verbose" (
230266
set "DISPLAY_VERBOSE=yes"
231267
) else if "%~1" == "-v" (
@@ -234,6 +270,12 @@ if "!libbitcoin_server_TAG!" == "" (
234270
set "SHOW_HELP=yes"
235271
) else if "%~1" == "-h" (
236272
set "SHOW_HELP=yes"
273+
) else (
274+
if "!UNHANDLED_ARGS!" == "" (
275+
set "UNHANDLED_ARGS=%1"
276+
) else (
277+
set "UNHANDLED_ARGS=!UNHANDLED_ARGS! %1"
278+
)
237279
)
238280

239281
shift
@@ -289,10 +331,23 @@ if "!libbitcoin_server_TAG!" == "" (
289331
set "RELATIVE_PATH=%~2"
290332
set "TARGET=%~3"
291333

292-
if "%TARGET%" == "" (
293-
set "TARGET_ARG="
334+
if not "%TARGET%" == "" (
335+
if not "!BUILD_MODE!" == "" (
336+
set "TARGET_ARG=/target:%TARGET%:!BUILD_MODE!"
337+
) else (
338+
set "TARGET_ARG=/target:%TARGET%"
339+
)
294340
) else (
295-
set "TARGET_ARG=/target:%TARGET%:Rebuild"
341+
if not "!BUILD_MODE!" == "" (
342+
set "TARGET_ARG=/target:!BUILD_MODE!"
343+
)
344+
)
345+
346+
set "SYMBOLS_ARG="
347+
if "!BUILD_SYMBOLS!" == "disabled" (
348+
set "SYMBOLS_ARG=/p:LinkerOptions=/PDBSTRIPPED "
349+
) else if "!BUILD_SYMBOLS!" == "public-only" (
350+
set "SYMBOLS_ARG=/p:DebugSymbols=false "
296351
)
297352

298353
call :push_directory "!BUILD_SRC_DIR!\%PROJECT%\%RELATIVE_PATH%\!BUILD_VERSION!"
@@ -305,10 +360,10 @@ if "!libbitcoin_server_TAG!" == "" (
305360
exit /b %ERRORLEVEL%
306361
)
307362

308-
!MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! /p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false
363+
!MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! !SYMBOLS_ARG!/p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false !UNHANDLED_ARGS!
309364

310365
if %ERRORLEVEL% neq 0 (
311-
call :msg_error "!MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! /p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false"
366+
call :msg_error "!MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! !SYMBOLS_ARG!/p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false !UNHANDLED_ARGS!"
312367
call :pop_directory
313368
exit /b 1
314369
)
@@ -335,6 +390,8 @@ if "!libbitcoin_server_TAG!" == "" (
335390
call :msg "BUILD_SRC_DIR : !BUILD_SRC_DIR!"
336391
call :msg "BUILD_FULL_REPOSITORIES : !BUILD_FULL_REPOSITORIES!"
337392
call :msg "BUILD_USE_LOCAL_SRC : !BUILD_USE_LOCAL_SRC!"
393+
call :msg "BUILD_MODE : !BUILD_MODE!"
394+
call :msg "BUILD_SYMBOLS : !BUILD_SYMBOLS!"
338395
call :msg "DISPLAY_VERBOSE : !DISPLAY_VERBOSE!"
339396
call :msg "SHOW_HELP : !SHOW_HELP!"
340397
exit /b %ERRORLEVEL%
@@ -368,6 +425,10 @@ if "!libbitcoin_server_TAG!" == "" (
368425
call :msg "--build-src-dir path Location of sources."
369426
call :msg "--build-full-repositories Sync full github repositories."
370427
call :msg "--build-use-local-src Use existing sources in build-src-dir path."
428+
call :msg "--build-mode mode Determines action on target."
429+
call :msg " Default: Rebuild"
430+
call :msg "--build-symbols mode Determines treatment of symbols."
431+
call :msg " Values: default, disabled, public-only"
371432
call :msg "--verbose Display verbose script output."
372433
call :msg "--help, -h Display usage, overriding script execution."
373434
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)