-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
setlocal | ||
set BUILD_BASE_DIR=%~dp1 | ||
set SOURCE_DIR=%~dp0compiletests | ||
|
||
:: find generic tools | ||
if not defined CMD_VSWHERE call %~dp0..\tools\find-tools.bat | ||
|
||
set /a NUM_VSVERSION_NEXT=NUM_VSVERSION + 1 | ||
|
||
if not exist "%CMD_CMAKE%" ( | ||
echo "no cmake found." | ||
exit /b 1 | ||
) | ||
|
||
if not exist "%CMD_NINJA%" ( | ||
set GENERATOR="%CMAKE_G_PARAM%" | ||
set GENERATOR_OPTS=-A %PLATFORM% "-DCMAKE_CONFIGURATION_TYPES=Debug;Release" | ||
set "MAKE_PROGRAM=%CMD_MSBUILD%" | ||
set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%" | ||
) else ( | ||
set GENERATOR=Ninja | ||
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION% | ||
set "MAKE_PROGRAM=%CMD_NINJA%" | ||
set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%\%configuration%" | ||
) | ||
|
||
mkdir %BUILD_DIR% > NUL 2>&1 | ||
pushd %BUILD_DIR% | ||
|
||
call :run_cmake_configure || endlocal && exit /b 1 | ||
|
||
endlocal && exit /b 0 | ||
|
||
:run_cmake_configure | ||
call :find_cl_compiler | ||
|
||
:: replace back-slash to slash in the path. | ||
set CL_COMPILER=%CMD_CL:\=/% | ||
|
||
:: run cmake configuration. | ||
"%CMD_CMAKE%" -G %GENERATOR% ^ | ||
"-DCMAKE_MAKE_PROGRAM=%MAKE_PROGRAM%" ^ | ||
"-DCMAKE_C_COMPILER=%CL_COMPILER%" ^ | ||
"-DCMAKE_CXX_COMPILER=%CL_COMPILER%" ^ | ||
%GENERATOR_OPTS% ^ | ||
%SOURCE_DIR% ^ | ||
|| endlocal && exit /b 1 | ||
goto :EOF | ||
|
||
:find_cl_compiler | ||
for /f "usebackq delims=" %%a in (`where cl.exe`) do ( | ||
set "CMD_CL=%%a" | ||
goto :EOF | ||
) | ||
goto :EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!-- This target depends on googletest.targets --> | ||
<Target Name="RunCompileTests" DependsOnTargets="MakeGoogleTestBuildDir;BuildGoogleTest" BeforeTargets="ClCompile"> | ||
<PropertyGroup> | ||
<VsVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))</VsVersion> | ||
</PropertyGroup> | ||
<SetEnv name="platform" value="$(Platform)" prefix="false" /> | ||
<SetEnv name="configuration" value="$(Configuration)" prefix="false" /> | ||
<SetEnv name="NUM_VSVERSION" value="$(VsVersion)" prefix="false" /> | ||
<Exec Command="$(MSBuildThisFileDirectory)compiletests.run.cmd "$(GoogleTestBuildDir)"" ConsoleToMSBuild="true" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
enable_language(CXX) | ||
|
||
set( SAKURA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../sakura_core) | ||
set( SAKURA_DEFINITIONS -D_DEBUG -D_UNICODE -DUNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7) | ||
|
||
# コンパイルテスト実行関数 | ||
function( compile_test TEST_TEMPLATE TEST_BODY TEST_DESCRIPTION TEST_NAME ) | ||
message( STATUS "Checking ${TEST_NAME}" ) | ||
|
||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEST_TEMPLATE} | ||
${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cpp | ||
NEWLINE_STYLE WIN32 | ||
) | ||
|
||
try_compile(FAILED_TO_TEST ${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cpp | ||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${SAKURA_SOURCE_DIR}" | ||
COMPILE_DEFINITIONS ${SAKURA_DEFINITIONS} | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
CXX_EXTENSIONS OFF | ||
) | ||
|
||
if (NOT FAILED_TO_TEST) | ||
message( STATUS "Checking ${TEST_NAME} - done" ) | ||
else() | ||
message( FATAL_ERROR "Checking ${TEST_NAME} - Failed." ) | ||
endif (NOT FAILED_TO_TEST) | ||
endfunction( compile_test ) | ||
|
||
# コンパイルテストの定義 | ||
compile_test( clayoutint_test.cpp.in "a += b;" "CLayoutInt に CLogicIntを加算代入することはできない" clayoutint_can_not_be_additive_assigned_from_clogicint ) | ||
compile_test( clayoutint_test.cpp.in "a -= b;" "CLayoutInt に CLogicIntを減算代入することはできない" clayoutint_can_not_be_subtractive_assigned_from_clogicint ) | ||
compile_test( clayoutint_test.cpp.in "a = a + b;" "CLayoutInt と CLogicIntを加算することはできない" clayoutint_can_not_be_added_by_clogicint ) | ||
compile_test( clayoutint_test.cpp.in "a = a - b;" "CLayoutInt から CLogicIntを減算することはできない" clayoutint_can_not_be_subtracted_by_clogicint ) | ||
compile_test( clayoutint_test.cpp.in "a = b;" "CLayoutInt に CLogicIntを代入することはできない" clayoutint_can_not_be_assigned_from_clogicint ) | ||
compile_test( clayoutint_test.cpp.in "a < b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_less_than ) | ||
compile_test( clayoutint_test.cpp.in "a <= b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_less_or_equal ) | ||
compile_test( clayoutint_test.cpp.in "a > b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_greater_than ) | ||
compile_test( clayoutint_test.cpp.in "a >= b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_greater_or_equal ) | ||
compile_test( clayoutint_test.cpp.in "a == b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_equal ) | ||
compile_test( clayoutint_test.cpp.in "a != b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_not_equal ) | ||
compile_test( clayoutint_test.cpp.in "int c = a;" "CLayoutInt は キャストなしでint型に代入することはできない" clayoutint_can_not_be_assigned_to_int ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*! @file */ | ||
/* | ||
Copyright (C) 2018-2020 Sakura Editor Organization | ||
|
||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
arising from the use of this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, | ||
including commercial applications, and to alter it and redistribute it | ||
freely, subject to the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; | ||
you must not claim that you wrote the original software. | ||
If you use this software in a product, an acknowledgment | ||
in the product documentation would be appreciated but is | ||
not required. | ||
|
||
2. Altered source versions must be plainly marked as such, | ||
and must not be misrepresented as being the original software. | ||
|
||
3. This notice may not be removed or altered from any source | ||
distribution. | ||
*/ | ||
#ifndef NOMINMAX | ||
#define NOMINMAX | ||
#endif /* #ifndef NOMINMAX */ | ||
|
||
#include <tchar.h> | ||
#include <Windows.h> | ||
|
||
#ifndef USE_STRICT_INT | ||
#define USE_STRICT_INT | ||
#endif /* #ifndef USE_STRICT_INT */ | ||
|
||
#include "basis/SakuraBasis.h" | ||
|
||
/*! | ||
* @brief テンプレートのテスト | ||
* このファイルはビルドエラーになる | ||
*/ | ||
void main() | ||
{ | ||
CLayoutInt a( 1 ); | ||
CLogicInt b( 2 ); | ||
|
||
//${TEST_DESCRIPTION} | ||
${TEST_BODY} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters