Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ビルド時間とアーティファクトサイズの軽減が狙いですが、主としてバッチのリファクタリングです。 #615

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,18 @@ build_script:

call tests\build-and-test.bat %PLATFORM% %CONFIGURATION%

after_build:
- cmd: set SAKURA_TEST=tests\build\%PLATFORM%\%CONFIGURATION%\tests1.exe

test:
assemblies:
only:
- '%SAKURA_TEST%'

test_script:
- cmd: |
"%SAKURA_TEST%" --gtest_list_tests
"%SAKURA_TEST%" | tests\test_result_filter_tell_AppVeyor.bat

artifacts:
- path: 'sakura-*$(platform)-$(configuration)*.zip'
83 changes: 55 additions & 28 deletions build-all.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
setlocal
set platform=%1
set configuration=%2

Expand Down Expand Up @@ -26,42 +27,68 @@ if "%configuration%" == "Release" (
@echo CONFIGURATION %CONFIGURATION%
@echo.

if "%platform%" == "MinGW" (
@echo call build-gnu.bat %PLATFORM% %CONFIGURATION%
call build-gnu.bat %PLATFORM% %CONFIGURATION% || (echo error build-gnu.bat && exit /b 1)
exit /b 0
rem plarform & config specialization

if "%CONFIGURATION%" == "Release" (
set BatchJobs=build-sln.bat^
build-chm.bat^
build-installer.bat^
zipArtifacts.bat
) else (
set BatchJobs=build-sln.bat^
externals\cppcheck\install-cppcheck.bat^
run-cppcheck.bat^
zipArtifacts.bat
)
if "%PLATFORM%" == "MinGW" (
set BatchJobs=build-gnu.bat
rem Skip all other batch files because they reject MinGW platform.
)

@echo ---- start build-sln.bat ----
call build-sln.bat %PLATFORM% %CONFIGURATION% || (echo error build-sln.bat && exit /b 1)
@echo ---- end build-sln.bat ----
@echo.
rem run

@echo ---- start build-chm.bat ----
call build-chm.bat || (echo error build-chm.bat && exit /b 1)
@echo ---- end build-chm.bat ----
@echo.
for %%B in (%BatchJobs%) do (
call :ExecBat "%~dp0%%~B" %PLATFORM% %CONFIGURATION% ^
|| (echo error %%~B & exit /b 1)
)
exit /b 0

@echo ---- start build-installer.bat ----
call build-installer.bat %PLATFORM% %CONFIGURATION% || (echo error build-installer.bat && exit /b 1)
@echo ---- end build-installer.bat ----
@echo.
rem ----------------------------------------------
rem sub-routines
rem ----------------------------------------------

@echo ---- start externals\cppcheck\install-cppcheck.bat ----
call externals\cppcheck\install-cppcheck.bat || (echo error externals\cppcheck\install-cppcheck.bat && exit /b 1)
@echo ---- end externals\cppcheck\install-cppcheck.bat ----
@echo.
:ExecBat
setlocal
set Batch=%~1
set Platform=%~2
set Config=%~3

@echo ---- start run-cppcheck.bat ----
call run-cppcheck.bat %PLATFORM% %CONFIGURATION% || (echo error run-cppcheck.bat && exit /b 1)
@echo ---- end run-cppcheck.bat ----
@echo.
call :StartWatch
echo ---- start %Batch% [%StartDate% %StartTime%] ----
echo.
cmd /C "call "%Batch%" %Platform% %Config%" ^
|| exit /b 1
call :StopWatch
echo ---- end %Batch% [%StopDate% %StopTime% / %Elapsed% seconds elapsed.] ----
echo.
exit /b 0

@echo ---- start zipArtifacts.bat ----
call zipArtifacts.bat %PLATFORM% %CONFIGURATION% || (echo error zipArtifacts.bat && exit /b 1)
@echo ---- end zipArtifacts.bat ----
@echo.
:StartWatch
set StartDate=%DATE%
set StartTime=%TIME: =0%
exit /b 0

:StopWatch
rem Be aware of space-padding hours and octal number literal
rem when calculating the Elapsed.

set StopDate=%DATE%
set StopTime=%TIME: =0%
set /A Elapsed=(1%StopTime:~0,2% * 3600 + 1%StopTime:~3,2% * 60 + 1%StopTime:~6,2%) ^
-(1%StartTime:~0,2% * 3600 + 1%StartTime:~3,2% * 60 + 1%StartTime:~6,2%)
if not "%StartDate%" == "%StopDate%" (
set /A Elapsed=%Elapsed% + 60 * 3600
)
exit /b 0

@rem ------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if (BUILD_SHARED_LIBS)
endif (BUILD_SHARED_LIBS)

# set Target Directories
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}$<0:Cancel_IntDir>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}$<0:Cancel_IntDir>)

add_subdirectory(googletest)
add_subdirectory(unittests)
Expand Down
69 changes: 48 additions & 21 deletions tests/build-and-test.bat
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
@echo off
setlocal
set platform=%1
set configuration=%2
set ERROR_RESULT=0

@echo ---- start create-project.bat ----
call "%~dp0create-project.bat" %platform% %configuration%
if errorlevel 1 (
@echo ERROR in create-project.bat %errorlevel%
exit /b 1
)
@echo ---- end create-project.bat ----
if "%platform%" == "MinGW" set PATH=C:\msys64\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=%

@echo ---- start build-project.bat ----
call "%~dp0build-project.bat" %platform% %configuration%
if errorlevel 1 (
@echo ERROR in build-project.bat %errorlevel%
exit /b 1
for %%B in (
create-project.bat
build-project.bat
) do (
call :ExecBat "%~dp0%%~B" %PLATFORM% %CONFIGURATION% ^
|| (echo ERROR %%~B %ERRORLEVEL% & exit /b 1)
)
@echo ---- end build-project.bat ----

@echo ---- start run-tests.bat ----
call "%~dp0run-tests.bat" %platform% %configuration%
if errorlevel 1 (
@echo ERROR in run-tests.bat %errorlevel%
exit /b 1
)
@echo ---- end run-tests.bat ----
exit /b 0

rem ----------------------------------------------
rem sub-routines
rem ----------------------------------------------

:ExecBat
setlocal
set Batch=%~1
set Platform=%~2
set Config=%~3

call :StartWatch
echo ---- start %Batch% [%StartDate% %StartTime%] ----
echo.
cmd /C "call "%Batch%" %Platform% %Config%" ^
|| exit /b 1
call :StopWatch
echo ---- end %Batch% [%StopDate% %StopTime% / %Elapsed% seconds elapsed.] ----
echo.
exit /b 0

:StartWatch
set StartDate=%DATE%
set StartTime=%TIME: =0%
exit /b 0

:StopWatch
rem Be aware of space-padding hours and octal number literal
rem when calculating the Elapsed.

set StopDate=%DATE%
set StopTime=%TIME: =0%
set /A Elapsed=(1%StopTime:~0,2% * 3600 + 1%StopTime:~3,2% * 60 + 1%StopTime:~6,2%) ^
-(1%StartTime:~0,2% * 3600 + 1%StartTime:~3,2% * 60 + 1%StartTime:~6,2%)
if not "%StartDate%" == "%StopDate%" (
set /A Elapsed=%Elapsed% + 60 * 3600
)
exit /b 0
55 changes: 45 additions & 10 deletions tests/build-project.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
set platform=%1
set configuration=%2
set ERROR_RESULT=0

pushd %~dp0
if not exist googletest (
pushd "%~dp0"
if not exist "googletest\CMakeLists.txt" (
git submodule init
git submodule update
)
popd

set BUILDDIR=build\%platform%
cmake --build %BUILDDIR% --config %configuration% || set ERROR_RESULT=1
set BUILDDIR=%~dp0build\%platform%\%configuration%

popd
call :SetEnv_%platform% %platform% %configuration%
cmake --build "%BUILDDIR%" --config %configuration% --target tests1 ^
|| (echo ERROR & exit /b 1)

if "%ERROR_RESULT%" == "1" (
@echo ERROR
exit /b 1
)
exit /b 0

rem ----------------------------------------------
rem sub-routines
rem ----------------------------------------------

:SetEnv_Win32
:SetEnv_x64
set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%~1"
set CMAKE_BLD_OPT=--config "%~2"
exit /b 0

:SetEnv_MinGW
set CMAKE_GEN_OPT=-G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="%~2"
set CMAKE_BLD_OPT=
set PATH=C:\msys64\mingw64\bin;%PATH%
call :CMAKE_PATH_FIX
exit /b 0

:CMAKE_PATH_FIX
if not "%~1" == "sh.exe" (
call %0 "sh.exe" & exit /b
)
set SHDIR=%~dp$PATH:1
if "%SHDIR%" == "" (
exit /b 0
)
set SHDIR=%SHDIR:~0,-1%
set ORG=;%PATH%;
set MOD=!ORG:;%SHDIR%\;=;%!
set MOD=!MOD:;%SHDIR%;=;%!
set PATH=%MOD:~1,-1%
if not "%ORG%" == "%MOD%" (
call %0 "sh.exe" & exit /b
)
exit /b 0
74 changes: 44 additions & 30 deletions tests/create-project.bat
Original file line number Diff line number Diff line change
@@ -1,58 +1,72 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
set platform=%1
set configuration=%2
set ERROR_RESULT=0

@rem produces header files necessary in creating the project.
rem produces header files necessary in creating the project.

if "%platform%" == "MinGW" (
call :CMAKE_PATH_FIX
set BUILD_EDITOR_BAT=build-gnu.bat
) else (
set BUILD_EDITOR_BAT=build-sln.bat
)
pushd "%~dp0.."
@echo ---- start %BUILD_EDITOR_BAT% ----
call "%BUILD_EDITOR_BAT%" %platform% %configuration% || set ERROR_RESULT=1
cmd /C "pushd "%~dp0.." & call "%BUILD_EDITOR_BAT%" %platform% %configuration%" ^
|| (echo ERROR & exit /b 1)
@echo ---- end %BUILD_EDITOR_BAT% ----
popd
if "%ERROR_RESULT%" == "1" (
@echo ERROR
exit /b 1
)

pushd "%~dp0"

pushd "%~dp0"
if not exist "googletest\CMakeLists.txt" (
git submodule init
git submodule update
)
popd

set BUILDDIR=build\%platform%
set BUILDDIR=%~dp0build\%platform%\%configuration%
if exist "%BUILDDIR%" (
rmdir /s /q "%BUILDDIR%"
)
mkdir "%BUILDDIR%"

call :setenv_%platform% %platform% %configuration%
cmake %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1
call :SetEnv_%platform% %platform% %configuration%
cmake %CMAKE_GEN_OPT% -H"%~dp0." -B"%BUILDDIR%" ^
|| (echo ERROR & exit /b 1)

popd

if "%ERROR_RESULT%" == "1" (
@echo ERROR
exit /b 1
)
exit /b 0

exit /b
rem ----------------------------------------------
rem sub-routines
rem ----------------------------------------------

@rem ----------------------------------------------
@rem sub-routines
@rem ----------------------------------------------

:setenv_Win32
:setenv_x64
:SetEnv_Win32
:SetEnv_x64
set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%~1"
exit /b
set CMAKE_BLD_OPT=--config "%~2"
exit /b 0

:setenv_MinGW
:SetEnv_MinGW
set CMAKE_GEN_OPT=-G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="%~2"
set PATH=C:\msys64\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=%
exit /b
set CMAKE_BLD_OPT=
set PATH=C:\msys64\mingw64\bin;%PATH%
call :CMAKE_PATH_FIX
exit /b 0

:CMAKE_PATH_FIX
if not "%~1" == "sh.exe" (
call %0 "sh.exe" & exit /b
)
set SHDIR=%~dp$PATH:1
if "%SHDIR%" == "" (
exit /b 0
)
set SHDIR=%SHDIR:~0,-1%
set ORG=;%PATH%;
set MOD=!ORG:;%SHDIR%\;=;%!
set MOD=!MOD:;%SHDIR%;=;%!
set PATH=%MOD:~1,-1%
if not "%ORG%" == "%MOD%" (
call %0 "sh.exe" & exit /b
)
exit /b 0
Loading