diff --git a/.gitmodules b/.gitmodules index d41dd11d1a..706402b880 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "tests/googletest"] - path = tests/googletest - url = https://github.com/google/googletest.git +[submodule "tools/vcpkg"] + path = tools/vcpkg + url = https://github.com/Microsoft/vcpkg.git diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..0ab16c94e7 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,3 @@ + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..36a35f8107 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,3 @@ + + + diff --git a/HeaderMake/HeaderMake.vcxproj b/HeaderMake/HeaderMake.vcxproj deleted file mode 100644 index 347a89a0f6..0000000000 --- a/HeaderMake/HeaderMake.vcxproj +++ /dev/null @@ -1,96 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0F2918B0-23E3-42E8-A1A8-8739F726A23E} - HeaderMake - Win32Proj - - - - - Application - Unicode - true - - - Application - Unicode - - - - - - - - - - - - $(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - <_ProjectFileVersion>15.0.27130.2020 - - - true - - - false - - - - Disabled - WIN32;_CONSOLE;_DEBUG;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - Level3 - EditAndContinue - /source-charset:shift_jis %(AdditionalOptions) - true - - - $(OutDir)$(TargetName)$(TargetExt) - true - Console - MachineX86 - false - - - - - WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - Level3 - ProgramDatabase - /source-charset:shift_jis %(AdditionalOptions) - true - - - $(OutDir)$(TargetName)$(TargetExt) - false - Console - true - true - MachineX86 - - - - - - - - - \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index e85ebf3933..0e587e3f25 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,6 +30,7 @@ install: py.exe -m pip install openpyxl --user cup innosetup C:\ProgramData\chocolatey\tools\shimgen.exe --output=C:\ProgramData\chocolatey\bin\ISCC.exe --path="C:\Program Files (x86)\Inno Setup 6\ISCC.exe" + git submodule update --init # to run our custom scripts instead of automatic MSBuild build_script: diff --git a/build-gnu.bat b/build-gnu.bat index 3c4aa390ca..ba16ac5d78 100644 --- a/build-gnu.bat +++ b/build-gnu.bat @@ -30,7 +30,25 @@ path=C:\msys64\usr\bin;%path:C:\msys64\usr\bin;=% path=C:\msys64\mingw64\bin;%path:C:\msys64\mingw64\bin;=% :: find generic tools -if not defined CMD_NINJA call %~dp0tools\find-tools.bat +if not defined CMD_GIT call %~dp0tools\find-tools.bat + +:: Reset errorlevel +cmd /c exit /b 0 + +if not exist %~dp0tools\vcpkg\bootstrap-vcpkg.bat ( + "%CMD_GIT%" submodule update --init +) + +if errorlevel 1 ( + echo ERROR submodule update %errorlevel% + exit /b 1 +) + +if not exist %~dp0tools\vcpkg\vcpkg.exe ( + call %~dp0tools\vcpkg\bootstrap-vcpkg.bat +) + +path=%~dp0tools\vcpkg;%path% @rem create output directory, all executables will be placed here. set OUTDIR=%~dp0%platform%\%configuration% @@ -68,14 +86,6 @@ if errorlevel 1 ( ) popd -@rem build "googletest". -call %~dp0tests\googletest.build.cmd %~dp0build\%platform%\%configuration%\gtest_build\ %~dp0build\%platform%\%configuration%\googletest\ -if errorlevel 1 ( - echo error 2 errorlevel %errorlevel% - popd - exit /b 1 -) - @rem build "tests1". set TESTS1_MAKEFILE=%~dp0tests\unittests\Makefile set TESTS1_BUILD_DIR=%~dp0build\%platform%\%configuration%\tests1 diff --git a/build-sln.bat b/build-sln.bat index 42e42eae2a..8adbb38ea8 100644 --- a/build-sln.bat +++ b/build-sln.bat @@ -25,6 +25,19 @@ if not defined CMD_MSBUILD ( exit /b 1 ) +if not exist %~dp0tools\vcpkg\bootstrap-vcpkg.bat ( + "%CMD_GIT%" submodule update --init +) + +if errorlevel 1 ( + echo ERROR submodule update %errorlevel% + exit /b 1 +) + +if not exist %~dp0tools\vcpkg\vcpkg.exe ( + call %~dp0tools\vcpkg\bootstrap-vcpkg.bat +) + set SLN_FILE=sakura.sln @rem https://www.appveyor.com/docs/environment-variables/ diff --git a/ci/azure-pipelines/template.steps.install-mingw-w64-gcc.yml b/ci/azure-pipelines/template.steps.install-mingw-w64-gcc.yml index 60baa9127d..86e40658ea 100644 --- a/ci/azure-pipelines/template.steps.install-mingw-w64-gcc.yml +++ b/ci/azure-pipelines/template.steps.install-mingw-w64-gcc.yml @@ -5,5 +5,12 @@ # なし ############################################################################################################# steps: + - task: Cache@2 + inputs: + path: C:\msys64 + key: 'mingw | $(vmImage) | $(Build.SourceVersion)' + restoreKeys: | + mingw | $(vmImage) + mingw - script: C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-toolchain" displayName: Install MinGW-w64 build tools via Pacman diff --git a/ci/build-batchfiles.md b/ci/build-batchfiles.md index 8d51b2a535..ee6acb4f98 100644 --- a/ci/build-batchfiles.md +++ b/ci/build-batchfiles.md @@ -29,7 +29,6 @@ |[sakura\preBuild.bat](../sakura/preBuild.bat) | 特に何もしない | |[sakura\githash.bat](../sakura/githash.bat) | Git や CI の環境変数から githash.h を生成する | |[sakura\postBuild.bat](../sakura/postBuild.bat) | bregonig.dll と ctags.exe を展開しコピーする | -|[tests\googletest.build.cmd](../tests/googletest.build.cmd) | Google Test をビルドする | |[tests\compiletests.run.cmd](../tests/compiletests.run.cmd) | コンパイルテストを実行する | |[build-sonar-qube-finish.bat](../build-sonar-qube-finish.bat) | SonarQube の解析結果をアップロードする | |[parse-buildlog.bat](../parse-buildlog.bat) | ビルドログを解析する | @@ -51,6 +50,7 @@ SonarQube に関しては [こちら](../SonarQube.md) も参照してくださ - [tools\zip\unzip.bat](../tools/zip/unzip.bat) : ZIP ファイルを展開する - 7z.exe または [tools\zip\unzip.ps1](../tools/zip/unzip.ps1) - MSBuild.exe sakura.sln + - vcpkg.exe - [sakura\preBuild.bat](../sakura/preBuild.bat) - HeaderMake.exe : Funccode_define.h, Funccode_enum.h を生成する - [sakura\githash.bat](../sakura/githash.bat) @@ -58,9 +58,6 @@ SonarQube に関しては [こちら](../SonarQube.md) も参照してくださ - [sakura\postBuild.bat](../sakura/postBuild.bat) - [tools\zip\unzip.bat](../tools/zip/unzip.bat) - 7z.exe または [tools\zip\unzip.ps1](../tools/zip/unzip.ps1) - - [tests\googletest.build.cmd](../tests/googletest.build.cmd) - - git.exe - - cmake.exe - [tests\compiletests.run.cmd](../tests/compiletests.run.cmd) - cmake.exe - [build-sonar-qube-finish.bat](../build-sonar-qube-finish.bat) @@ -73,6 +70,7 @@ SonarQube に関しては [こちら](../SonarQube.md) も参照してくださ - mingw32-make.exe sakura_core - [sakura\githash.bat](../sakura/githash.bat) - git.exe + - vcpkg.exe - HeaderMake.exe - [build-chm.bat](../build-chm.bat) - [help\remove-comment.py](../help/remove-comment.py) : [sakura_core\sakura.hh](../sakura_core/sakura.hh) に記述された日本語を含む行コメントを削除する diff --git a/sakura.sln b/sakura.sln index 30f81c7aa7..ce8da5a1ae 100644 --- a/sakura.sln +++ b/sakura.sln @@ -4,12 +4,19 @@ VisualStudioVersion = 15.0.27130.2026 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sakura", "sakura\sakura.vcxproj", "{AF03508C-515E-4A0E-87BE-67ED1E254BD0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HeaderMake", "HeaderMake\HeaderMake.vcxproj", "{0F2918B0-23E3-42E8-A1A8-8739F726A23E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sakura_lang_en_US", "sakura_lang_en_US\sakura_lang_en_US.vcxproj", "{7A6D0F29-E560-4985-835B-5F92A08EB242}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests1", "tests\unittests\tests1.vcxproj", "{701E3407-EC27-49F7-ADC7-520CF2B4B438}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DD14BD9B-2E0F-4C53-8F16-EA9969FDEA45}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .vsconfig = .vsconfig + sakura_core\Funccode_x.hsrc = sakura_core\Funccode_x.hsrc + sakura\sakura.natvis = sakura\sakura.natvis + sonar-project.properties = sonar-project.properties + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -26,14 +33,6 @@ Global {AF03508C-515E-4A0E-87BE-67ED1E254BD0}.Release|Win32.Build.0 = Release|Win32 {AF03508C-515E-4A0E-87BE-67ED1E254BD0}.Release|x64.ActiveCfg = Release|x64 {AF03508C-515E-4A0E-87BE-67ED1E254BD0}.Release|x64.Build.0 = Release|x64 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Debug|Win32.ActiveCfg = Debug|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Debug|Win32.Build.0 = Debug|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Debug|x64.ActiveCfg = Debug|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Debug|x64.Build.0 = Debug|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Release|Win32.ActiveCfg = Release|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Release|Win32.Build.0 = Release|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Release|x64.ActiveCfg = Release|Win32 - {0F2918B0-23E3-42E8-A1A8-8739F726A23E}.Release|x64.Build.0 = Release|Win32 {7A6D0F29-E560-4985-835B-5F92A08EB242}.Debug|Win32.ActiveCfg = Debug|Win32 {7A6D0F29-E560-4985-835B-5F92A08EB242}.Debug|Win32.Build.0 = Debug|Win32 {7A6D0F29-E560-4985-835B-5F92A08EB242}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/sakura/funccode.targets b/sakura/funccode.targets index 1da83e8d6c..9408f4c9e0 100644 --- a/sakura/funccode.targets +++ b/sakura/funccode.targets @@ -1,15 +1,17 @@ - ..\Win32\$(Configuration)\HeaderMake.exe - ..\sakura_core\Funccode_define.h - ..\sakura_core\Funccode_enum.h + $(VcpkgRoot);$(ExecutablePath) + $(VcpkgInstalledDir)x64-windows\tools\header-make\HeaderMake.exe + $([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core\Funccode_define.h')) + $([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core\Funccode_enum.h')) - - - {0f2918b0-23e3-42e8-a1a8-8739f726a23e} - false - - + + + + diff --git a/sakura/sakura.vcxproj b/sakura/sakura.vcxproj index a5e5000ef1..d18648ba56 100644 --- a/sakura/sakura.vcxproj +++ b/sakura/sakura.vcxproj @@ -43,6 +43,15 @@ $(SolutionDir)build\$(Platform)\$(Configuration)\sakura_core\ $(SolutionDir)$(Platform)\$(Configuration)\ + + Debug + true + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\build\vcpkg_installed\')) + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\')) + x86-windows-static + x64-windows-static + true + <_ProjectFileVersion>15.0.27130.2020 @@ -54,7 +63,7 @@ - ..\sakura_core;%(AdditionalIncludeDirectories) + $(IntDir);$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\sakura_core'));%(AdditionalIncludeDirectories) _WIN32_WINNT=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) true true @@ -70,6 +79,7 @@ true + $(IntDir);$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\sakura_core'));%(AdditionalIncludeDirectories) 0x0411 diff --git a/sakura_core/Makefile b/sakura_core/Makefile index b4f31789e2..660c82affa 100644 --- a/sakura_core/Makefile +++ b/sakura_core/Makefile @@ -23,6 +23,12 @@ endif # If empty, they will be output to the default directories. OUTDIR = +VCPKG_INSTALLED_DIR = ../../../vcpkg_installed + +VCPKG_TARGET_TRIPLET = x64-mingw-static + +VCPKG_HOST_TRIPLET = x64-mingw-dynamic + ifeq ($(SHELL),sh.exe) # If cmd.exe is used as a shell. MKDIR = md @@ -78,13 +84,19 @@ CFLAGS= \ -fexec-charset=cp932 \ -MMD \ -I. \ + -I$(VCPKG_INSTALLED_DIR)/$(VCPKG_TARGET_TRIPLET)/include \ -I$(SRCDIR) \ $(DEFINES) $(MYCFLAGS) + CXXFLAGS= $(CFLAGS) \ -std=c++17 \ $(MYCXXFLAGS) -LIBS= \ + +LDFLAGS= \ -static \ + -municode \ + -L$(VCPKG_INSTALLED_DIR)/$(VCPKG_TARGET_TRIPLET)/lib +LIBS= \ -lwinspool \ -lole32 \ -loleaut32 \ @@ -98,8 +110,6 @@ LIBS= \ -lwindowscodecs \ -lmsimg32 \ -luxtheme \ - -mwindows \ - -municode \ $(MYLIBS) exe= $(or $(OUTDIR),.)/sakura.exe @@ -122,15 +132,14 @@ GENERATED_FILES= \ Funccode_enum.h \ githash.h \ -HEADERMAKETOOLDIR= $(SRCDIR)/../HeaderMake -HEADERMAKE= $(or $(OUTDIR),$(HEADERMAKETOOLDIR))/HeaderMake.exe +HEADERMAKE = $(VCPKG_INSTALLED_DIR)/$(VCPKG_HOST_TRIPLET)/tools/header-make/HeaderMake.exe all: $(exe) \ $(bregonig) \ $(ctags) $(exe): $(OBJS) sakura_rc.o - $(CXX) -o $@ $(OBJS) sakura_rc.o $(LIBS) + $(CXX) -o $@ -mwindows $(LDFLAGS) $(OBJS) sakura_rc.o $(LIBS) $(bregonig): ../installer/externals/bregonig/bron420.zip $(P7Z) e $< -o$(@D) -y x64/$(@F) @@ -158,8 +167,8 @@ endif $(OBJS): StdAfx.h.gch -$(HEADERMAKE): $(HEADERMAKETOOLDIR)/HeaderMake.cpp - $(CXX) $(CXXFLAGS:-MMD=) $< -o $@ -static-libgcc +$(HEADERMAKE): ../HeaderMake/HeaderMake.cpp + vcpkg install --x-wait-for-lock --triplet $(VCPKG_TARGET_TRIPLET) --host-triplet $(VCPKG_HOST_TRIPLET) "--x-manifest-root=$(SRCDIR)/../" "--x-install-root=$(VCPKG_INSTALLED_DIR)" sakura_rc.o: sakura_rc.rc.utf8 sakura_rc.rc2.utf8 githash.h Funccode_define.h $(RC) -c utf-8 --language=0411 $(DEFINES) -I. -I$(SRCDIR) $< -o $@ diff --git a/sakura_lang_en_US/sakura_lang_en_US.vcxproj b/sakura_lang_en_US/sakura_lang_en_US.vcxproj index f1c8e52d26..ebb9094b68 100644 --- a/sakura_lang_en_US/sakura_lang_en_US.vcxproj +++ b/sakura_lang_en_US/sakura_lang_en_US.vcxproj @@ -39,6 +39,15 @@ $(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Platform)\$(Configuration)\ + + Debug + true + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\')) + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\build\vcpkg_installed\')) + x86-windows-static + x64-windows-static + true + <_ProjectFileVersion>15.0.27130.2020 @@ -52,7 +61,7 @@ - ..\sakura_core;$(OutDir);%(AdditionalIncludeDirectories) + $([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core'));$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\sakura_core'));%(AdditionalIncludeDirectories) 0x0409 diff --git a/tests/googletest b/tests/googletest deleted file mode 160000 index 0b7798b2fb..0000000000 --- a/tests/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0b7798b2fba340969a0cf83698e5c0a2e25b7dbc diff --git a/tests/googletest.build.cmd b/tests/googletest.build.cmd deleted file mode 100644 index ceeecc6248..0000000000 --- a/tests/googletest.build.cmd +++ /dev/null @@ -1,89 +0,0 @@ -setlocal -set BUILD_DIR=%~dp1 -set GOOGLETEST_INSTALL_PATH=%~dp2 - -set SOURCE_DIR=%~dp0googletest - -:: find generic tools -if not defined CMD_NINJA call %~dp0..\tools\find-tools.bat - -if not exist "%CMD_CMAKE%" ( - echo "no cmake found." - exit /b 1 -) - -if not exist "%CMD_NINJA%" ( - echo "no ninja found." - exit /b 1 -) - -pushd "%SOURCE_DIR%" || exit /b 1 -if not exist CMakeLists.txt ( - if not exist "%CMD_GIT%" ( - echo "no git found." - exit /b 1 - ) - "%CMD_GIT%" submodule update --init || exit /b 1 -) -popd - -mkdir %BUILD_DIR% > NUL 2>&1 -pushd %BUILD_DIR% - -call :run_cmake_install - -endlocal && exit /b 0 - -:run_cmake_install -call :run_cmake_configure -"%CMD_CMAKE%" --build . --config %CONFIGURATION% --target install || endlocal && exit /b 1 -goto :EOF - -:run_cmake_configure -if "%PLATFORM%" == "Win32" ( - call :find_cl_compilers -) -if "%PLATFORM%" == "x64" ( - call :find_cl_compilers -) -if "%PLATFORM%" == "MinGW" ( - call :find_gcc_compilers -) - -:: install lib64 for x64-platform. -if "%PLATFORM%" == "x64" ( - set GENERATOR_OPTS=-DCMAKE_INSTALL_LIBDIR=lib64 %GENERATOR_OPTS% -) - -:: run cmake configuration. -"%CMD_CMAKE%" -G Ninja ^ - "-DCMAKE_MAKE_PROGRAM=%CMD_NINJA%" ^ - "-DCMAKE_C_COMPILER=%C_COMPILER%" ^ - "-DCMAKE_CXX_COMPILER=%CXX_COMPILER%" ^ - -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ - -DCMAKE_INSTALL_PREFIX=%GOOGLETEST_INSTALL_PATH% ^ - %GENERATOR_OPTS% ^ - -DBUILD_GMOCK=ON ^ - -Dgtest_build_tests=OFF ^ - -Dgtest_build_samples=OFF ^ - %SOURCE_DIR% ^ - || endlocal && exit /b 1 -goto :EOF - -:find_cl_compilers -call :find_cl -set C_COMPILER=%CMD_CL:\=/% -set CXX_COMPILER=%CMD_CL:\=/% -goto :EOF - -:find_cl -for /f "usebackq delims=" %%a in (`where cl.exe`) do ( - set "CMD_CL=%%a" - goto :EOF -) -goto :EOF - -:find_gcc_compilers -set C_COMPILER=C:/msys64/mingw64/bin/gcc.exe -set CXX_COMPILER=C:/msys64/mingw64/bin/g++.exe -goto :EOF diff --git a/tests/googletest.targets b/tests/googletest.targets deleted file mode 100644 index 61cef7edaa..0000000000 --- a/tests/googletest.targets +++ /dev/null @@ -1,45 +0,0 @@ - - - $(MSBuildThisFileDirectory)googletest - $(SolutionDir)build\$(Platform)\$(Configuration)\gtest_build\ - $(SolutionDir)build\$(Platform)\$(Configuration)\googletest\ - $(GoogleTestInstallDir)include;$(IncludePath) - $(GoogleTestInstallDir)lib - $(GoogleTestInstallDir)lib64 - $(GoogleTestLibInstallDir);$(LibraryPath) - gtest.lib - $(GoogleTestLibInstallDir)\$(GTestLibName) - gmock.lib - $(GoogleTestLibInstallDir)\$(GMockLibName) - - - - _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;%(PreprocessorDefinitions) - - - - - $(GTestLibName);%(AdditionalDependencies) - $(GMockLibName);%(AdditionalDependencies) - - - - - - - - - - - $([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1')) - - - - - - - - - - - \ No newline at end of file diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index 045acc7cb6..ac5dca4a54 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -27,12 +27,16 @@ endif # The directory where "sakura_core" is built. SAKURA_CORE = ../sakura_core -GOOGLETEST_INSTALL_DIR = ../googletest - # The directory where the .exe files will be output. # If empty, they will be output to the default directories. OUTDIR = +VCPKG_INSTALLED_DIR = ../../../vcpkg_installed + +VCPKG_TARGET_TRIPLET = x64-mingw-static + +VCPKG_HOST_TRIPLET = x64-mingw-dynamic + ifeq ($(SHELL),sh.exe) # If cmd.exe is used as a shell. MKDIR = md @@ -87,7 +91,7 @@ CFLAGS= \ -finput-charset=utf-8 \ -fexec-charset=cp932 \ -MMD \ - -isystem $(GOOGLETEST_INSTALL_DIR)/include \ + -isystem $(VCPKG_INSTALLED_DIR)/$(VCPKG_TARGET_TRIPLET)/include \ -I$(SAKURA_CORE) \ -I$(SRCDIR)/../../sakura_core \ -I. \ @@ -98,8 +102,17 @@ CXXFLAGS= $(CFLAGS) \ -std=c++17 \ $(MYCXXFLAGS) -LIBS= \ +LDFLAGS= \ -static \ + -municode \ + +ifeq (,$(findstring -D_DEBUG,$(DEFINES))) +LDFLAGS += -L$(VCPKG_INSTALLED_DIR)/$(VCPKG_TARGET_TRIPLET)/debug/lib +else +LDFLAGS += -L$(VCPKG_INSTALLED_DIR)/$(VCPKG_TARGET_TRIPLET)/lib +endif + +LIBS= \ -lwinspool \ -lole32 \ -loleaut32 \ @@ -117,9 +130,9 @@ LIBS= \ -lkernel32 \ -lgdi32 \ -lcomdlg32 \ - -L$(GOOGLETEST_INSTALL_DIR)/lib \ -lgtest \ -lgmock \ + -municode \ $(MYLIBS) exe= $(or $(OUTDIR),.)/tests1.exe @@ -140,9 +153,12 @@ SAKURA_OBJS = $(SAKURA_SRCS:$(SRCDIR)/../../sakura_core/%.cpp=$(SAKURA_CORE)/%.o all: $(exe) $(exe): $(OBJS) $(SAKURA_OBJS) - $(CXX) -o $@ $(OBJS) $(SAKURA_OBJS) $(LIBS) + $(CXX) -o $@ -mconsole $(LDFLAGS) $(OBJS) $(SAKURA_OBJS) $(LIBS) + +pch.h.gch: pch.h + $(CXX) $(CXXFLAGS) -o $@ -c $< -.cpp.o: +.cpp.o: pch.h.gch $(CXX) $(CXXFLAGS) -o $@ -c $< $(OBJS): @@ -154,7 +170,7 @@ tests1_rc.rc.utf8: tests1_rc.rc $(ICONV) -f utf-16 -t utf-8 $(SRCDIR)/$(subst .utf8,,$(@F)) | $(SED) -e 1i'#pragma code_page(65001)' > $@ clean: - -$(RM) $(subst /,$(DIRSEP),$(exe) $(OBJS)) + -$(RM) $(subst /,$(DIRSEP),$(exe) $(OBJS) pch.h.gch) -$(RM) $(subst /,$(DIRSEP),$(DEPS)) .SUFFIXES: .cpp .o diff --git a/tests/unittests/code-main.cpp b/tests/unittests/code-main.cpp index 60010aec78..b19c04bdf3 100644 --- a/tests/unittests/code-main.cpp +++ b/tests/unittests/code-main.cpp @@ -102,13 +102,13 @@ static void InvokeWinMainIfNeeded(std::wstring_view commandLine) /*! * テストモジュールのエントリポイント */ -int main(int argc, char **argv) { +int wmain(int argc, wchar_t **argv) { // コマンドラインに -PROF 指定がある場合、wWinMainを起動して終了する。 InvokeWinMainIfNeeded(::GetCommandLineW()); // WinMainを起動しない場合、標準のgmock_main同様の処理を実行する。 // InitGoogleMock は Google Test の初期化も行うため、InitGoogleTest を別に呼ぶ必要はない。 - printf("Running main() from %s\n", __FILE__); + wprintf(L"Running main() from %hs\n", __FILE__); testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tests/unittests/tests1.vcxproj b/tests/unittests/tests1.vcxproj index 62dd362b0f..f10e345220 100644 --- a/tests/unittests/tests1.vcxproj +++ b/tests/unittests/tests1.vcxproj @@ -39,10 +39,23 @@ $(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Platform)\$(Configuration)\ - + + Debug + true + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\..\build\vcpkg_installed\')) + $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\..\')) + x86-windows-static + x64-windows-static + true + + + + _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;%(PreprocessorDefinitions) + + - $(SolutionDir)sakura_core;%(AdditionalIncludeDirectories) + $([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core'));$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\..\sakura_core'));%(AdditionalIncludeDirectories) _CONSOLE;%(PreprocessorDefinitions) Use pch.h @@ -51,8 +64,11 @@ /source-charset:utf-8 /execution-charset:shift_jis %(AdditionalOptions) - $(IntDir);%(AdditionalIncludeDirectories) + $(IntDir);$([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core'));%(AdditionalIncludeDirectories) + + true + Console comctl32.lib;Imm32.lib;mpr.lib;imagehlp.lib;Shlwapi.lib;Dwmapi.lib;%(AdditionalDependencies) diff --git a/tools/vcpkg b/tools/vcpkg new file mode 160000 index 0000000000..782ccc18d8 --- /dev/null +++ b/tools/vcpkg @@ -0,0 +1 @@ +Subproject commit 782ccc18d8b819cdef6794a6c03eb3d9f7cd04aa diff --git a/tools/vcpkg-local-registry/ports/header-make/CMakeLists.txt b/tools/vcpkg-local-registry/ports/header-make/CMakeLists.txt new file mode 100644 index 0000000000..31554d7865 --- /dev/null +++ b/tools/vcpkg-local-registry/ports/header-make/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.7) + +# define a project +project (HeaderMake) + +# add test executable +add_executable(${PROJECT_NAME} HeaderMake.cpp) + +# add definitions +target_compile_definitions(${PROJECT_NAME} PUBLIC _CONSOLE UNICODE _UNICODE) + +# add install target +install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}-targets + RUNTIME DESTINATION bin +) diff --git a/tools/vcpkg-local-registry/ports/header-make/portfile.cmake b/tools/vcpkg-local-registry/ports/header-make/portfile.cmake new file mode 100644 index 0000000000..95e319d9f7 --- /dev/null +++ b/tools/vcpkg-local-registry/ports/header-make/portfile.cmake @@ -0,0 +1,25 @@ +# includeフォルダーが空でも警告が出ないモードを指定。 +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) + +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src) + +file(COPY "${VCPKG_ROOT_DIR}/../../HeaderMake/HeaderMake.cpp" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg.json" DESTINATION "${SOURCE_PATH}") + +# CMakeコンフィグを実行。 +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +# 一旦インストールする。 +vcpkg_cmake_install() + +# /binに出力されたexeをツールフォルダにコピー。 +vcpkg_copy_tools(TOOL_NAMES HeaderMake) + +# ツールインストールに不要なフォルダーを削除。 +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug") + +# 著作権ファイルはトップフォルダーのものを流用する。 +vcpkg_install_copyright(FILE_LIST "${VCPKG_ROOT_DIR}/../../LICENSE") diff --git a/tools/vcpkg-local-registry/ports/header-make/vcpkg.json b/tools/vcpkg-local-registry/ports/header-make/vcpkg.json new file mode 100644 index 0000000000..be7ae02703 --- /dev/null +++ b/tools/vcpkg-local-registry/ports/header-make/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "header-make", + "version": "0.0.1", + "homepage": "https://github.com/sakura-editor/sakura", + "description": "HeaderMake.exe", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/tools/vcpkg-local-registry/versions/baseline.json b/tools/vcpkg-local-registry/versions/baseline.json new file mode 100644 index 0000000000..b466a37876 --- /dev/null +++ b/tools/vcpkg-local-registry/versions/baseline.json @@ -0,0 +1,8 @@ +{ + "2025-03-15": { + "header-make": { + "baseline": "0.0.1", + "port-version": 0 + } + } +} diff --git a/tools/vcpkg-local-registry/versions/h-/header-make.json b/tools/vcpkg-local-registry/versions/h-/header-make.json new file mode 100644 index 0000000000..b6125b0c12 --- /dev/null +++ b/tools/vcpkg-local-registry/versions/h-/header-make.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "version": "0.0.1", + "port-version": 0, + "path": "$/ports/header-make" + } + ] +} \ No newline at end of file diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000000..274db6c90d --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,20 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "d5ec528843d29e3a52d745a64b469f810b2cedbf", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "baseline": "2025-03-15", + "kind": "filesystem", + "packages": ["header-make"], + "path": "tools/vcpkg-local-registry" + }, + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..bbcfde25e6 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,12 @@ +{ + "dependencies": [ + { + "name": "header-make", + "host": true + }, + { + "name": "gtest", + "platform": "static" + } + ] +}