Skip to content

Commit

Permalink
Build and run tests on MinGW environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ds14050 committed Nov 2, 2018
1 parent df4ab03 commit 1738af5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
2 changes: 1 addition & 1 deletion sakura_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Funccode_enum.h: $(HEADERMAKE) Funccode_x.hsrc
$(HEADERMAKE) -in=../sakura_core/Funccode_x.hsrc -out=../sakura_core/Funccode_enum.h -mode=enum -enum=EFunctionCode

githash:
cmd /c $(CURDIR)/../sakura/githash.bat ..\\sakura_core
cmd /c ..\sakura\githash.bat ..\sakura_core

stdafx: Funccode_enum.h StdAfx.h
$(CXX) $(CXXFLAGS) -c StdAfx.h
Expand Down
11 changes: 3 additions & 8 deletions tests/build-and-test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@ set platform=%1
set configuration=%2
set ERROR_RESULT=0

if "%platform%" == "MinGW" (
@echo test for MinGW will be skipped. ^(platform: %platform%, configuration: %configuration%^)
exit /b 0
)

@echo ---- start create-project.bat ----
call %~dp0create-project.bat %platform% %configuration%
call "%~dp0create-project.bat" %platform% %configuration%
if %ERRORLEVEL% neq 0 (
@echo ERROR in create-project.bat
exit /b 1
)
@echo ---- end create-project.bat ----

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

@echo ---- start run-tests.bat ----
call %~dp0run-tests.bat %platform% %configuration%
call "%~dp0run-tests.bat" %platform% %configuration%
if %ERRORLEVEL% neq 0 (
@echo ERROR in run-tests.bat
exit /b 1
Expand Down
38 changes: 32 additions & 6 deletions tests/create-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ set platform=%1
set configuration=%2
set ERROR_RESULT=0

@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.."
rem produces header files necessary in creating the project.
@echo ---- start build-sln.bat ----
call build-sln.bat %platform% %configuration% || set ERROR_RESULT=1
@echo ---- end build-sln.bat ----
@echo ---- start %BUILD_EDITOR_BAT% ----
call "%BUILD_EDITOR_BAT%" %platform% %configuration% || set ERROR_RESULT=1
@echo ---- end %BUILD_EDITOR_BAT% ----
popd
if "%ERROR_RESULT%" == "1" (
@echo ERROR
Expand All @@ -24,12 +29,33 @@ set BUILDDIR=build\%platform%
if exist "%BUILDDIR%" (
rmdir /s /q "%BUILDDIR%"
)
mkdir %BUILDDIR%
cmake -DCMAKE_GENERATOR_PLATFORM=%platform% -B%BUILDDIR% -H. || set ERROR_RESULT=1
mkdir "%BUILDDIR%"

pushd "%BUILDDIR%"
call :SETENV_"%Platform%" "%Platform%" "%Config%"
cmake %CMAKE_GEN_OPT% "%~dp0"
popd

popd

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

exit /b


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

:SETENV_"Win32" %1=Platform %2=Config
:SETENV_"x64" %1=Platform %2=Config
set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%~1"
exit /B

:SETENV_"MinGW" %1=Platform %2=Config
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
27 changes: 19 additions & 8 deletions tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@ if (BUILD_SHARED_LIBS)
endif (BUILD_SHARED_LIBS)

# link libraries
target_link_libraries(${project_name} gtest)
target_link_libraries(${project_name} gtest_main)
target_link_libraries(${project_name} PRIVATE gtest)
target_link_libraries(${project_name} PRIVATE gtest_main)

# Hacks to reuse compiled editor objects.
target_compile_definitions(${project_name} PUBLIC WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN7)
target_compile_options (${project_name} PUBLIC $<$<CONFIG:Release>:/GL> /MT$<$<CONFIG:Debug>:d> /GF /FD /EHsc /Zi /TP /source-charset:utf-8 /execution-charset:shift_jis)
target_link_libraries (${project_name} $<$<CONFIG:Release>:-LTCG> comctl32.lib Imm32.lib mpr.lib imagehlp.lib Shlwapi.lib "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>/*.obj")
set_target_properties (${project_name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>"
)
target_compile_definitions(${project_name} PRIVATE WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN7)
if (MSVC)
target_compile_options (${project_name} PRIVATE $<$<CONFIG:Release>:/GL> /MT$<$<CONFIG:Debug>:d> /GF /FD /EHsc /Zi /TP /source-charset:utf-8 /execution-charset:shift_jis)
target_link_libraries (${project_name} PRIVATE $<$<CONFIG:Release>:-LTCG> "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>/*.obj")
set_target_properties (${project_name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>"
)
elseif (MINGW)
target_compile_options (${project_name} PRIVATE -finput-charset=utf-8 -fexec-charset=cp932)
file (GLOB_RECURSE ALL_O
"${CMAKE_CURRENT_LIST_DIR}/../../sakura_core/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/../../sakura_core/*.rc"
)
list (TRANSFORM ALL_O REPLACE "\\.(cpp|rc)$" ".o")
target_link_libraries (${project_name} PRIVATE ${ALL_O})
endif ()
target_link_libraries (${project_name} PRIVATE winspool ole32 oleaut32 uuid comctl32 imm32 mpr imagehlp shlwapi winmm)

0 comments on commit 1738af5

Please sign in to comment.