Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.iobj
*.ipdb
*.pyc
**/packages
**/TestResults
.sonarqube
/*.patch
/.vs
Expand Down
10 changes: 10 additions & 0 deletions sakura.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sakura_lang_en_US", "sakura
{AF03508C-515E-4A0E-87BE-67ED1E254BD0} = {AF03508C-515E-4A0E-87BE-67ED1E254BD0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests1", "tests\unittests\tests1.vcxproj", "{701E3407-EC27-49F7-ADC7-520CF2B4B438}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -53,6 +55,14 @@ Global
{7A6D0F29-E560-4985-835B-5F92A08EB242}.Release|Win32.Build.0 = Release|Win32
{7A6D0F29-E560-4985-835B-5F92A08EB242}.Release|x64.ActiveCfg = Release|x64
{7A6D0F29-E560-4985-835B-5F92A08EB242}.Release|x64.Build.0 = Release|x64
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Debug|Win32.ActiveCfg = Debug|Win32
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Debug|Win32.Build.0 = Debug|Win32
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Debug|x64.ActiveCfg = Debug|x64
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Debug|x64.Build.0 = Debug|x64
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Release|Win32.ActiveCfg = Release|Win32
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Release|Win32.Build.0 = Release|Win32
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Release|x64.ActiveCfg = Release|x64
{701E3407-EC27-49F7-ADC7-520CF2B4B438}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
57 changes: 57 additions & 0 deletions tests/googletest.build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@rem echo off
setlocal
set SOURCE_DIR=%1
set CONFIGURATION=%2
set VCVARSALL_PATH=%3
set VCVARS_ARCH=%4

if not defined CMD_GIT call %~dp0..\tools\find-tools.bat
if not defined CMD_GIT (
echo git.exe was not found.
endlocal && exit /b 1
)

if not exist "%~dp0googletest\CMakeLists.txt" (
"%CMD_GIT%" submodule init %~dp0googletest || endlocal && exit /b 1
"%CMD_GIT%" submodule update %~dp0googletest || endlocal && exit /b 1
)

set GENERATOR=

@rem call vcvasall.bat when we run in the Visual Studio IDE.
if defined VCVARSALL_PATH (
call %VCVARSALL_PATH% %VCVARS_ARCH% || endlocal && exit /b 1
)

where ninja.exe > NUL 2>&1
if not errorlevel 1 (
set GENERATOR=-G "Ninja"
)

@rem find cl.exe in the PATH
call :find_cl_exe

if not defined CMD_CL (
echo cl.exe was not found.
endlocal && exit /b 1
)
set CMD_CL=%CMD_CL:\=/%

cmake %GENERATOR% -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
"-DCMAKE_C_COMPILER=%CMD_CL%" ^
"-DCMAKE_CXX_COMPILER=%CMD_CL%" ^
-DBUILD_GMOCK=OFF ^
-Dgtest_build_tests=OFF ^
-Dgtest_build_samples=OFF ^
%SOURCE_DIR% ^
|| endlocal && exit /b 1

cmake --build . || endlocal && exit /b 1

endlocal && exit /b 0

:find_cl_exe
for /f "usebackq delims=" %%a in (`where cl.exe`) do (
set CMD_CL=%%a
goto :EOF
)
53 changes: 53 additions & 0 deletions tests/googletest.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="GoogleTest">
<GoogleTestSourceDir>$(MSBuildThisFileDirectory)googletest\</GoogleTestSourceDir>
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest\</GoogleTestBuildDir>
<IncludePath>$(GoogleTestSourceDir)googletest\include;$(IncludePath)</IncludePath>
<LibraryPath>$(GoogleTestBuildDir)\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Label="GoogleTest.Requirements">
<ClCompile>
<PreprocessorDefinitions>_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Debug'">
<Link>
<AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Release'">
<Link>
<AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Debug'">
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtestd.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_maind.pdb" />
</ItemGroup>
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Release'">
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_main.pdb" />
</ItemGroup>
<Target Name="BuildGoogleTest" BeforeTargets="ClCompile">
<PropertyGroup>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x86'">x86</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x64'">x86_amd64</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x86'">amd64_x86</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x64'">amd64</VcVarsArchitecture>
</PropertyGroup>
<MakeDir Condition="!Exists('$(GoogleTestBuildDir)')" Directories="$(GoogleTestBuildDir)" />
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) $(Configuration) &quot;$(VCInstallDir)Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
</Target>
<Target Name="AppendCleanTargets" BeforeTargets="CoreClean">
<!-- Add files to @Clean just before running CoreClean. -->
<ItemGroup>
<Clean Include="$(OutDir)gtestd.pdb" />
<Clean Include="$(OutDir)gtest_maind.pdb" />
<Clean Include="$(OutDir)gtest.pdb" />
<Clean Include="$(OutDir)gtest_main.pdb" />
</ItemGroup>
<RemoveDir Directories="$(GoogleTestBuildDir)" />
</Target>
</Project>
124 changes: 124 additions & 0 deletions tests/unittests/tests1.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{701e3407-ec27-49f7-adc7-520cf2b4b438}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(ProjectDir)..\..\vcx-props\vcxcompat.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros">
<OutDir>(ProjectDir)..\..\..\build\$(Platform)\$(Configuration)\unittests\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(ProjectDir)..\googletest.targets" />
<ItemDefinitionGroup Label="tests1.common">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)sakura_core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/source-charset:utf-8 /execution-charset:shift_jis %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>comctl32.lib;Imm32.lib;mpr.lib;imagehlp.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<LargeAddressAware>true</LargeAddressAware>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<ClCompile>
<PreprocessorDefinitions>X64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ItemDefinitionGroup>
<ItemGroup>
<Link Include="$(SolutionDir)sakura\$(Platform)\$(Configuration)\*.obj" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="test-cmemory.cpp" />
<ClCompile Include="test-cnative.cpp" />
<ClCompile Include="test-int2dec.cpp" />
<ClCompile Include="test-is_mailaddress.cpp" />
<ClCompile Include="test-mydevmode.cpp" />
<ClCompile Include="test-parameterized.cpp" />
<ClCompile Include="test-sample-disabled.cpp" />
<ClCompile Include="test-sample.cpp" />
<ClCompile Include="test-StdControl.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(ProjectDir)..\..\sakura\sakura.vcxproj">
<Project>{af03508c-515e-4a0e-87be-67ed1e254bd0}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
48 changes: 48 additions & 0 deletions tests/unittests/tests1.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Test Files">
<UniqueIdentifier>{690c7184-b796-460a-8fed-595dfa1930f4}</UniqueIdentifier>
</Filter>
<Filter Include="Deprecated Codes">
<UniqueIdentifier>{594146a8-ae7c-401b-a064-af37dac4216e}</UniqueIdentifier>
</Filter>
<Filter Include="Other Files">
<UniqueIdentifier>{0eefa0df-ca7f-489c-9844-9a182e1dba18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt">
<Filter>Other Files</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<ClCompile Include="test-cmemory.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-cnative.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-int2dec.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-is_mailaddress.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-mydevmode.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-parameterized.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-sample.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-sample-disabled.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="test-StdControl.cpp">
<Filter>Test Files</Filter>
</ClCompile>
</ItemGroup>
</Project>