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

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

Closed
wants to merge 6 commits into from
13 changes: 13 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,18 @@ build_script:
build-all.bat %PLATFORM% %CONFIGURATION%
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^
run-cppcheck.bat^
run-doxygen.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 run-cppcheck.bat ----
call run-cppcheck.bat %PLATFORM% %CONFIGURATION% || (echo error run-cppcheck.bat && exit /b 1)
@echo ---- end run-cppcheck.bat ----
@echo.
:ExecBat
setlocal
set Batch=%~1
set Platform=%~2
set Config=%~3

@echo ---- start run-doxygen.bat ----
call run-doxygen.bat %PLATFORM% %CONFIGURATION% || (echo error run-doxygen.bat && exit /b 1)
@echo ---- end run-doxygen.bat ----
@echo.
call :StartWatch
echo ---- start %Batch% [%StartDate% %StartTime%] ----
echo.
cmd /C "call "%Batch%" %Platform% %Config%" ^
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd /C "%Batch%" の代わりに call|"%Batch%" でもいけそうですがあまりに趣味的なのでやめておきます。

|| 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 literals
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% + 24 * 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
67 changes: 46 additions & 21 deletions tests/build-and-test.bat
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
@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
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 create-project.bat ----

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

@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 ----
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.] ----
Copy link
Contributor Author

@ds14050 ds14050 Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

わりと見かけると思うのですが、こういうメッセージで s を脱着するまではしないけれど、括弧を付けずにはいられない(second(s))几帳面さが日本語使いには理解しがたいものがあります。

マーク・ピーターセンさんの古典的名著『日本人の英語』を読むとそういう、(不)定冠詞を軽視した態度は厳に改めるべきものだと反省させられます。英語ネイティブはまず a や the を発話してから、具体的な名詞となる単語を頭の中で探すことがあるらしいですよ。そっちが核なんですね。

この echo メッセージも改めるべきなのかもしれません。

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 literals
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% + 24 * 3600
)
exit /b 0
58 changes: 48 additions & 10 deletions tests/build-project.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

遅延環境変数を利用したい CMAKE_PATH_FIX が呼び出し元の PATH 環境変数に影響を与えるためにこの場所で setlocal しましたが、endlocal & set PATH=%PATH% することにより setlocal を CMAKE_PATH_FIX 内部のみで完結させられます。

set platform=%1
set configuration=%2
set ERROR_RESULT=0

pushd %~dp0
if not exist googletest (
call :SetEnv_%platform% %platform% %configuration%
set BUILDDIR=%~dp0build\%platform%\%configuration%

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
cmake --build "%BUILDDIR%" %CMAKE_BLD_OPT% --target tests1 ^
|| (echo ERROR & exit /b 1)

popd
exit /b 0

if "%ERROR_RESULT%" == "1" (
@echo ERROR
exit /b 1
)
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

rem Remove path to sh.exe from PATH env.
rem see https://github.com/vim/vim/blob/4dbc2627641a6b950c30c31cbf7b7e6c36da1927/src/Make_cyg_ming.mak#L176-L202
rem via https://github.com/sakura-editor/sakura/pull/591#discussion_r230551589
: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
76 changes: 46 additions & 30 deletions tests/create-project.bat
Original file line number Diff line number Diff line change
@@ -1,58 +1,74 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
set platform=%1
set configuration=%2
set ERROR_RESULT=0

@rem produces header files necessary in creating the project.
call :SetEnv_%platform% %platform% %configuration%
set BUILDDIR=%~dp0build\%platform%\%configuration%

rem produces header files necessary in creating the project.

if "%platform%" == "MinGW" (
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"

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

set BUILDDIR=build\%platform%
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
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

rem Remove path to sh.exe from PATH env.
rem see https://github.com/vim/vim/blob/4dbc2627641a6b950c30c31cbf7b7e6c36da1927/src/Make_cyg_ming.mak#L176-L202
rem via https://github.com/sakura-editor/sakura/pull/591#discussion_r230551589
: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