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 4, 2018
1 parent df4ab03 commit 090319c
Show file tree
Hide file tree
Showing 4 changed files with 44 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% 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
26 changes: 20 additions & 6 deletions tests/create-project.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
setlocal ENABLEDELAYEDEXPANSION
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,8 +30,16 @@ 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%"

if "%platform%" == "MinGW" (
set CMAKE_GEN_OPT=-G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="%configuration%"
set PATH=C:\msys64\mingw64\bin;!PATH:C:\Program Files\Git\usr\bin;=!
) else (
set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%platform%"
)

cmake %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1

popd

Expand Down
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 090319c

Please sign in to comment.