Skip to content

vcpkg導入検討(その2) #2024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)tools\vcpkg\scripts\buildsystems\msbuild\vcpkg.props" />
</Project>
3 changes: 3 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)tools\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets" />
</Project>
96 changes: 0 additions & 96 deletions HeaderMake/HeaderMake.vcxproj

This file was deleted.

1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 19 additions & 9 deletions build-gnu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions build-sln.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
7 changes: 7 additions & 0 deletions ci/azure-pipelines/template.steps.install-mingw-w64-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions ci/build-batchfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | ビルドログを解析する |
Expand All @@ -51,16 +50,14 @@ 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)
- git.exe
- [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)
Expand All @@ -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) に記述された日本語を含む行コメントを削除する
Expand Down
19 changes: 9 additions & 10 deletions sakura.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 11 additions & 9 deletions sakura/funccode.targets
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="FuncCode">
<HeaderMake>..\Win32\$(Configuration)\HeaderMake.exe</HeaderMake>
<FuncCodeDefine>..\sakura_core\Funccode_define.h</FuncCodeDefine>
<FuncCodeEnum>..\sakura_core\Funccode_enum.h</FuncCodeEnum>
<ExecutablePath Condition="'$(VcpkgRoot)'!=''">$(VcpkgRoot);$(ExecutablePath)</ExecutablePath>
<HeaderMake>$(VcpkgInstalledDir)x64-windows\tools\header-make\HeaderMake.exe</HeaderMake>
<FuncCodeDefine>$([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core\Funccode_define.h'))</FuncCodeDefine>
<FuncCodeEnum>$([MSBuild]::NormalizePath('$(IntDir)', '..\sakura_core\Funccode_enum.h'))</FuncCodeEnum>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HeaderMake\HeaderMake.vcxproj">
<Project>{0f2918b0-23e3-42e8-a1a8-8739f726a23e}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Target Name="InstallHeaderMake"
Condition="!Exists('$(HeaderMake)')"
AfterTargets="GenerateGitHash"
BeforeTargets="FuncCodeDefine;FuncCodeEnum">
<Exec Command="chcp 65001 &gt;NUL &amp;&amp; bootstrap-vcpkg.bat" Condition="!Exists('$(VcpkgRoot)\vcpkg.exe')" StdOutEncoding="UTF-8" StdErrEncoding="UTF-8" WorkingDirectory="$(VcpkgRoot)" />
<Exec Command="chcp 65001 &gt;NUL &amp;&amp; vcpkg.exe install --x-wait-for-lock --triplet &quot;$(VcpkgTriplet)&quot; &quot;--x-manifest-root=$(VcpkgManifestDirectory.TrimEnd('\'))&quot; &quot;--x-install-root=$(VcpkgInstalledDir.TrimEnd('\'))&quot;" StdOutEncoding="UTF-8" StdErrEncoding="UTF-8" WorkingDirectory="$(MSBuildThisFileDirectory).." />
</Target>
<Target Name="_WriteFuncCodeDefineRcTlogs"
Condition="'@(FuncCodeRes)' != '' and '@(SelectedFiles)' == ''">
<ItemGroup>
Expand Down
12 changes: 11 additions & 1 deletion sakura/sakura.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<IntDir>$(SolutionDir)build\$(Platform)\$(Configuration)\sakura_core\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
<VcpkgConfiguration Condition="'$(Configuration)'=='Debug'">Debug</VcpkgConfiguration>
<VcpkgEnableManifest>true</VcpkgEnableManifest>
<VcpkgInstalledDir>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\build\vcpkg_installed\'))</VcpkgInstalledDir>
<VcpkgManifestDirectory>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\'))</VcpkgManifestDirectory>
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
<VcpkgUseStatic>true</VcpkgUseStatic>
</PropertyGroup>
<PropertyGroup>
<_ProjectFileVersion>15.0.27130.2020</_ProjectFileVersion>
</PropertyGroup>
Expand All @@ -54,7 +63,7 @@
</PropertyGroup>
<ItemDefinitionGroup Label="sakura.common">
<ClCompile>
<AdditionalIncludeDirectories>..\sakura_core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(IntDir);$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\sakura_core'));%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
Expand All @@ -70,6 +79,7 @@
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(IntDir);$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\sakura_core'));%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Culture>0x0411</Culture>
</ResourceCompile>
<Manifest>
Expand Down
25 changes: 17 additions & 8 deletions sakura_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -98,8 +110,6 @@ LIBS= \
-lwindowscodecs \
-lmsimg32 \
-luxtheme \
-mwindows \
-municode \
$(MYLIBS)

exe= $(or $(OUTDIR),.)/sakura.exe
Expand All @@ -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)
Expand Down Expand Up @@ -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 $@
Expand Down
Loading