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 8, 2018
1 parent 3de8e1f commit 3879f62
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
4 changes: 2 additions & 2 deletions sakura_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif
CC= $(PREFIX)gcc
CXX= $(PREFIX)g++
RC= $(RCPREFIX)windres
RM= cmd /c $(CURDIR)/../sakura/mingw32-del.bat
RM= "$(CURDIR)/../sakura/mingw32-del.bat"

DEFINES= \
-DWIN32 \
Expand Down 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
"$(CURDIR)/../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 1 (
@echo ERROR in create-project.bat %errorlevel%
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 1 (
@echo ERROR in build-project.bat %errorlevel%
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 1 (
@echo ERROR in run-tests.bat %errorlevel%
exit /b 1
Expand Down
35 changes: 29 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,30 @@ 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%"

call :setenv_%platform% %platform% %configuration%
cmake %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1

popd

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

exit /b

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

:setenv_Win32
:setenv_x64
set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%~1"
exit /b

: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
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 3879f62

Please sign in to comment.