mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
迁移到 Conan v2 (#731)
* chore: 迁移到 Conan v2 * docs: 更新文档 * chore: 更新 Conan 缓存路径 * chore: 所有 Conan 依赖都是最新的则显示消息
This commit is contained in:
parent
8196a98f6e
commit
ae9895a488
13 changed files with 32 additions and 37 deletions
3
.conan/.gitignore
vendored
3
.conan/.gitignore
vendored
|
|
@ -1,3 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
||||
!Directory.Build.props
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- HybridCRT -->
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\HybridCRT.props" />
|
||||
</Project>
|
||||
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
|
@ -24,12 +24,12 @@ jobs:
|
|||
python-version: '3.11'
|
||||
|
||||
- name: Setup Conan
|
||||
run: pip install conan<2.0
|
||||
run: pip install conan
|
||||
|
||||
- name: Load Conan cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ./.conan/data
|
||||
path: ~/.conan2/p
|
||||
key: ${{ runner.os }}-conan-${{ hashFiles('src/**/conanfile.txt') }}
|
||||
|
||||
- name: Build
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,6 +3,7 @@
|
|||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
.conan/
|
||||
my_*/
|
||||
|
||||
# User-specific files
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ In order to compile Magpie, you need to first install:
|
|||
4. [Conan](https://conan.io/) v1
|
||||
|
||||
```bash
|
||||
pip install conan<2.0
|
||||
pip install conan
|
||||
```
|
||||
To execute in cmd, double quotes should be added around `conan<2.0`.
|
||||
|
||||
Make sure that the above dependencies have been added to the system path, and use the following commands to check:
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@
|
|||
4. [Conan](https://conan.io/) v1
|
||||
|
||||
```bash
|
||||
pip install conan<2.0
|
||||
pip install conan
|
||||
```
|
||||
在 cmd 中执行应在`conan<2.0`两侧加双引号。
|
||||
|
||||
确保上述依赖均已被添加入系统路径,使用以下命令检查:
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ rapidjson/cci.20220822
|
|||
kuba-zip/0.2.6
|
||||
|
||||
[generators]
|
||||
visual_studio
|
||||
MSBuildDeps
|
||||
|
||||
[options]
|
||||
fmt:header_only=True
|
||||
spdlog:header_only=True
|
||||
spdlog:no_exceptions=True
|
||||
spdlog/*:no_exceptions=True
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ yas/7.1.0
|
|||
imgui/1.89.9
|
||||
|
||||
[generators]
|
||||
visual_studio
|
||||
MSBuildDeps
|
||||
|
||||
[options]
|
||||
fmt:header_only=True
|
||||
spdlog:header_only=True
|
||||
spdlog:no_exceptions=True
|
||||
spdlog/*:no_exceptions=True
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ spdlog/1.12.0
|
|||
parallel-hashmap/1.37
|
||||
|
||||
[generators]
|
||||
visual_studio
|
||||
MSBuildDeps
|
||||
|
||||
[options]
|
||||
fmt:header_only=True
|
||||
spdlog:header_only=True
|
||||
spdlog:no_exceptions=True
|
||||
spdlog/*:no_exceptions=True
|
||||
|
|
|
|||
|
|
@ -58,6 +58,6 @@
|
|||
|
||||
<!-- Conan 依赖 -->
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="..\.conan\$(Platform)\$(Configuration)\$(MSBuildProjectName)\conanbuildinfo.props" Condition="Exists('..\.conan\$(Platform)\$(Configuration)\$(MSBuildProjectName)\conanbuildinfo.props') And Exists('$(MSBuildProjectDirectory)\conanfile.txt')" />
|
||||
<Import Project="..\.conan\$(MSBuildProjectName)\conandeps.props" Condition="Exists('..\.conan\$(MSBuildProjectName)\conandeps.props') And Exists('$(MSBuildProjectDirectory)\conanfile.txt')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -42,14 +42,17 @@
|
|||
<ItemGroup>
|
||||
<None Include="build_conan_deps.py" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="conanprofile.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Target Name="BuildConanDeps" BeforeTargets="Build">
|
||||
<Exec Command="python build_conan_deps.py $(Platform) $(Configuration)" />
|
||||
</Target>
|
||||
<!-- 清理 Conan 生成的 props 文件,不清理数据 -->
|
||||
<!-- 清理 Conan 生成的 props 文件 -->
|
||||
<Target Name="CleanConanProps" BeforeTargets="Clean">
|
||||
<PropertyGroup>
|
||||
<PropsDir>..\\..\\.conan\\$(Platform)\\$(Configuration)</PropsDir>
|
||||
<PropsDir>..\\..\\.conan</PropsDir>
|
||||
</PropertyGroup>
|
||||
<Exec Command="rmdir /s /q $(PropsDir)" Condition="Exists('$(PropsDir)')" />
|
||||
</Target>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ configuration = sys.argv[2]
|
|||
if not platform in ["x64", "ARM64"] or not configuration in ["Debug", "Release"]:
|
||||
raise Exception("非法参数")
|
||||
|
||||
subprocess.run(f"conan config set storage.path={os.getcwd()}\\..\\..\\.conan\\data")
|
||||
# 记录是否有项目的依赖需要编译
|
||||
anyProjectToBuild = False
|
||||
|
||||
# 遍历存在 conanfile.txt 的项目
|
||||
for project in os.listdir(".."):
|
||||
|
|
@ -23,7 +24,7 @@ for project in os.listdir(".."):
|
|||
except:
|
||||
continue
|
||||
|
||||
hashFilePath = f"..\\..\\.conan\\{platform}\\{configuration}\\{project}\\hash.txt"
|
||||
hashFilePath = f"..\\..\\.conan\\{project}\\{platform}_{configuration}_hash.txt"
|
||||
try:
|
||||
with open(hashFilePath, "r") as hashFile:
|
||||
if hashFile.read(len(hash)) == hash:
|
||||
|
|
@ -32,19 +33,17 @@ for project in os.listdir(".."):
|
|||
except:
|
||||
pass
|
||||
|
||||
anyProjectToBuild = True
|
||||
|
||||
# 编译依赖
|
||||
if platform == "x64":
|
||||
build_type = "x86_64"
|
||||
else:
|
||||
build_type = "armv8"
|
||||
|
||||
if configuration == "Debug":
|
||||
runtime = "MTd"
|
||||
else:
|
||||
runtime = "MT"
|
||||
|
||||
# HybridCRT 要求静态链接 CRT
|
||||
p = subprocess.run(
|
||||
f"conan install {conanfilePath} --install-folder ..\\..\\.conan\\{platform}\\{configuration}\\{project} --build=outdated -s build_type={configuration} -s arch={build_type} -s compiler.version=17 -s compiler.runtime={runtime} --update"
|
||||
f"conan install {conanfilePath} -pr:b=conanprofile.txt -pr:h=conanprofile.txt --output-folder ..\\..\\.conan\\{project} --build=missing -s build_type={configuration} -s arch={build_type} --update"
|
||||
)
|
||||
if p.returncode != 0:
|
||||
raise Exception("conan install 失败")
|
||||
|
|
@ -52,3 +51,6 @@ for project in os.listdir(".."):
|
|||
# 更新哈希文件
|
||||
with open(hashFilePath, "w") as hashFile:
|
||||
print(hash, file=hashFile)
|
||||
|
||||
if not anyProjectToBuild:
|
||||
print("Conan 依赖已是最新", flush=True)
|
||||
|
|
|
|||
5
src/_ConanDeps/conanprofile.txt
Normal file
5
src/_ConanDeps/conanprofile.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[settings]
|
||||
compiler=msvc
|
||||
compiler.runtime=static
|
||||
compiler.version=193
|
||||
os=Windows
|
||||
Loading…
Add table
Add a link
Reference in a new issue