From aa772141179df245aed1582db0022d7ef7b775a0 Mon Sep 17 00:00:00 2001 From: mingkuang Date: Sat, 6 May 2023 01:02:26 +0800 Subject: [PATCH] =?UTF-8?q?Fea=20#6=EF=BC=8C=E6=B7=BB=E5=8A=A0MacOS?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 10 +- Build.proj | 40 +- README.md | 770 +++++++++++++++++- .../HelloWorldApplication.vcxproj | 82 ++ .../main.cpp | 0 .../HelloWorldApplication.vcxproj | 13 +- Samples/HelloWorld----ObjectC++/main.mm | 11 + Samples/MSBuildCppCrossToolsetSamples.sln | 51 -- Samples/ReadMe.md | 42 +- .../Application Type/OSX/1.0/Default.props | 35 + .../OSX/1.0/Linux.Common.props | 33 + .../OSX/1.0/Linux.Common.targets | 140 ++++ .../OSX/1.0/Linux.Cross.Common.props | 151 ++++ .../OSX/1.0/Linux.Cross.Common.targets | 35 + .../OSX/1.0/Linux.Makefile.targets | 528 ++++++++++++ .../Application Type/OSX/1.0/Linux.STL.props | 38 + .../Application Type/OSX/1.0/Linux.WSL.props | 253 ++++++ .../OSX/1.0/Linux.WSL.targets | 541 ++++++++++++ .../v170/Application Type/OSX/1.0/Linux.props | 256 ++++++ .../Application Type/OSX/1.0/Linux.targets | 713 ++++++++++++++++ .../Platforms/ARM64/Platform.Default.props | 28 + .../OSX/1.0/Platforms/ARM64/Platform.props | 23 + .../OSX/1.0/Platforms/ARM64/Platform.targets | 18 + .../1.0/Platforms/x64/Platform.Default.props | 29 + .../OSX/1.0/Platforms/x64/Platform.props | 23 + .../OSX/1.0/Platforms/x64/Platform.targets | 18 + .../1.0/Platforms/x86/Platform.Default.props | 29 + .../OSX/1.0/Platforms/x86/Platform.props | 23 + .../OSX/1.0/Platforms/x86/Platform.targets | 18 + .../v170/Application Type/OSX/Default.props | 26 + YY.Build.Cross.Tasks/OSX/Compile.cs | 151 ++++ YY.Build.Cross.Tasks/OSX/Ld.cs | 102 +++ .../YY_Cross_Clang_1_0/Toolset.props | 48 ++ .../YY_Cross_Clang_1_0/Toolset.targets | 38 + .../Platforms/YY_Cross_GCC_1_0/Toolset.props | 48 ++ .../YY_Cross_GCC_1_0/Toolset.targets | 39 + .../Targets/OSX/YY.OSX.Cross.props | 230 ++++++ .../Targets/OSX/YY.OSX.Cross.targets | 327 ++++++++ .../YY.Build.Cross.Tasks.projitems | 6 + 39 files changed, 4873 insertions(+), 93 deletions(-) create mode 100644 Samples/HelloWorld----C++/HelloWorldApplication.vcxproj rename Samples/{HelloWorldApplication => HelloWorld----C++}/main.cpp (100%) rename Samples/{HelloWorldApplication => HelloWorld----ObjectC++}/HelloWorldApplication.vcxproj (91%) create mode 100644 Samples/HelloWorld----ObjectC++/main.mm delete mode 100644 Samples/MSBuildCppCrossToolsetSamples.sln create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Default.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.Common.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.Common.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.Makefile.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.STL.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Linux.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.Default.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.Default.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.targets create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.Default.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.props create mode 100644 VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.targets create mode 100644 VCTargets/v170/Application Type/OSX/Default.props create mode 100644 YY.Build.Cross.Tasks/OSX/Compile.cs create mode 100644 YY.Build.Cross.Tasks/OSX/Ld.cs create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.props create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.targets create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.props create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.targets create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.props create mode 100644 YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.targets diff --git a/.gitignore b/.gitignore index d16e668..f18c549 100644 --- a/.gitignore +++ b/.gitignore @@ -21,11 +21,11 @@ mono_crash.* [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ +# x64/ +# x86/ +# [Ww][Ii][Nn]32/ +# [Aa][Rr][Mm]/ +# [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ diff --git a/Build.proj b/Build.proj index ae81388..b66246b 100644 --- a/Build.proj +++ b/Build.proj @@ -36,19 +36,39 @@ MSBuild.exe "Build.proj" - + + $(MSBuildThisFileDirectory)VCTargets\v170\Application Type\ + - - + - - - - - - + + + + + + + + $(MSBuildThisFileDirectory)VCTargets\v170\Application Type\$(CurrentApplicationType)\1.0\Platforms\ + + + + + + + + + + + + + + + + - 注意:不支持Windows,因为Windows下微软直接支持。 +| 兼容的操作系统 | ApplicationType名称 | 支持的PlatformToolset(平台工具集) +| ---------------- | ------------------- | ----------------- +| Linux | Linux | YY_Cross_GCC_1_0(默认值)、YY_Cross_Clang_1_0 +| MacOS | OSX | YY_Cross_GCC_1_0、YY_Cross_Clang_1_0(默认值) -## 1.2. 兼容的编译器 -| 编译器名称 | 对应的平台工具集 -| -------------- | ----------- -| GCC | YY_Cross_GCC_1_0(Linux默认) -| Clang | YY_Cross_Clang_1_0 +> 温馨提示:Windows系统由自己微软MSVC直接支持,所以这边不提供支持。 -> 由于这些编译工具将作为平台工具集实现,因此使用时需要给对应的vcxproj配置平台工具集(`PlatformToolset`)。 - - -## 1.3. 兼容的平台 -* ARM -* ARM64 -* MIPS -* x64(AMD64) -* x86 +一般来说,vcxproj中的`ApplicationType`以及`PlatformToolset`无需设置,MSBuildCppCrossToolset会自动根据运行情况自动适应。 +如果你想自行设置,请严格按上述表格中的值配置ApplicationType与PlatformToolset。 # 2. 使用方式 # 2.1. 安装 .NET SDK @@ -59,15 +48,754 @@ export VCTargetsPath=/home/john/Desktop/VCTargets/v170/ 它将临时添加`VCTargetsPath`环境变量,如果需要持久配置,请自行修改系统配置。 ## 2.3. 编译vcxproj项目 -假设项目位置: `/home/john/Desktop/ConsoleApplication2/ConsoleApplication2.vcxproj`。并且编译 Release x86,那么可以输入如下命令: +我们也提供了示例项目,点击查看[Samples](Samples) + +一般来说,Platform拥有以下几种可能: +* ARM +* ARM64 +* MIPS +* x64 +* x86(注意:对于Windows系统下的vcxproj来说叫Win32) + + +假设项目位置: `/home/john/Desktop/ConsoleApplication2/ConsoleApplication2.vcxproj`。并且编译 Release版的x86版本,那么可以输入如下命令: ``` +; Linux下编译 x86 dotnet msbuild '/home/john/Desktop/ConsoleApplication2/ConsoleApplication2.vcxproj' '-p:Configuration=Release;Platform=x86' + +; Linux下编译 x64 +dotnet msbuild '/home/john/Desktop/ConsoleApplication2/ConsoleApplication2.vcxproj' '-p:Configuration=Release;Platform=x64' + + +; Windows下编译 x86。新人特别注意了,vcxproj里没有x86,只有Win32!!! +msbuild "D:\ConsoleApplication2\ConsoleApplication2.vcxproj" -p:Configuration=Release;Platform=Win32 + +; Windows下编译 x64 +msbuild "D:\ConsoleApplication2\ConsoleApplication2.vcxproj" -p:Configuration=Release;Platform=x64 + +``` + +# 3. 支持的属性以及元素参数映射情况 +## 3.1. ClCompile +它描述了C/C++代码编译参数配置情况。 + +### 3.1.1. CompileAs 属性(枚举) +选择源代码文件的编译语言选项。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ----------------- | ----------------- | ----------------- | -------- | ------ +| Default | | | | 使用默认语言(`.c` 文件编译为 C代码,`.m` 文件编译为Object-C代码,`.mm` 文件编译为Object-C++),其他统一编译为C++代码。 +| CompileAsC | /TC | -x c | -x c | 编译为 C 代码。 +| CompileAsCpp | /TP | -x c++ | -x c++ | 编译为 C++ 代码。 +| CompileAsObjC | 不支持 | 不支持 | -x objective-c | 编译为 Object-C 代码。 +| CompileAsObjCpp | 不支持 | 不支持 | -x objective-c++ | 编译为 Object-C++ 代码。 + +示例: +```xml + + CompileAsC + +``` + +### 3.1.2. AdditionalIncludeDirectories 属性(字符串列表) +指定一个或多个要添加到包括路径的目录;如果有多个目录,请用分号分开。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /I | -I | -I + +示例: +```xml + + C:\CppInlcude;D:\CppInlcude + +``` + +### 3.1.3. DebugInformationFormat 属性(枚举) +指定编译器生成的调试信息类型。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ----------------- | ----------------- | ----------------- | -------- | ------ +| None | | -g0 | -g0 | 没有生成调试信息,因此编译可能会更快。 +| Minimal | 不支持 | -g1 | -g1 | 生成最小调试信息。 +| FullDebug | 不支持 | -g2 -gdwarf-2 | -g2 -gdwarf-2 | 生成 DWARF2 调试信息。 + +示例: +```xml + + FullDebug + +``` + +### 3.1.4. ObjectFileName 属性(字符串) +指定重写默认对象文件名的名称;可以是文件名或目录名。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /Fo | -o | -o + +示例: +```xml + + 123.o + +``` + +### 3.1.5. WarningLevel 属性(枚举) +选择编译器对于外部标头中代码错误的严格程度。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| TurnOffAllWarnings | /external:W0 | -w | -w | 关闭所有警告。 +| Level1 | /external:W1 | -Wall | -Wall | 警告等级1。 +| Level2 | /external:W2 | -Wall | -Wall | 警告等级2。 +| Level3 | /external:W3 | -Wall | -Wall | 警告等级3。 +| Level4 | /external:W4 | -Wall -Wextra | -Wall -Wextra | 警告等级4。 + +示例: +```xml + + TurnOffAllWarnings + +``` + +### 3.1.6. TreatWarningAsError 属性(bool) +将所有编译器警告都视为错误。对于新项目,最好在所有编译中使用;对所有警告进行解析可确保将可能难以发现的代码缺陷减至最少。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /WX- | -Werror | -Werror +| false | | | + +示例: +```xml + + true + +``` + +### 3.1.7. AdditionalWarning 属性(字符串列表) +开启特定的警告。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -W | -W + + +### 3.1.8. Optimization 属性(枚举) +选择代码优化选项;选择“自定义”可使用特定的优化选项。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| Custom | | | | 自定义 +| Disabled | /Od | -O0 | -O0 | 禁用代码优化。 +| MinSize | /O1 | -Os | -Os | 针对文件大小进行代码优化。 +| MaxSpeed | /O2 | -O2 | -O2 | 针对速度进行代码优化。 +| Full | /Ox | -O3 | -O3 | 完全优化,类似于MaxSpeed。 + +示例: +```xml + + Full + +``` + +### 3.1.9. StrictAliasing 属性(bool) +假设使用最严格的别名检查规则。一种类型的对象将始终不会被假定驻留在与另一种类型的对象相同的位置。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fstrict-aliasing | -fstrict-aliasing +| false | 自动忽略 | -fno-strict-aliasing | -fno-strict-aliasing + +示例: +```xml + + true + +``` + +### 3.1.10. UnrollLoops 属性(bool) +Unroll loops to make application faster by reducing number of branches executed at the cost of larger code size. + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -funroll-all-loops | -funroll-all-loops +| false | 自动忽略 | | + +示例: +```xml + + true + +``` + +### 3.1.11. WholeProgramOptimization 属性(bool) +通过允许优化器跨应用程序中的对象文件进行查看,来实现过程间优化。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /GL | -flto | -flto +| false | | | + +示例: +```xml + + true + +``` + +### 3.1.12. OmitFramePointers 属性(bool) +禁止在调用堆栈上创建帧指针。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /Oy | -fomit-frame-pointer | -fomit-frame-pointer +| false | /Oy- | -fno-omit-frame-pointer | -fno-omit-frame-pointer + +示例: +```xml + + true + +``` + +### 3.1.13. NoCommonBlocks 属性(bool) +在对象文件的数据节中分配甚至未初始化的全局变量,而不是以公共块的形式生成它们。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fno-common | -fno-common +| false | 自动忽略 | | + +### 3.1.14. PreprocessorDefinitions 属性(字符串列表) +定义源文件的预处理符号。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /D | -D | -D + +示例: +```xml + + __VERSION=8848;__VERSION_INFO;%(PreprocessorDefinitions) + +``` + +### 3.1.15. UndefinePreprocessorDefinitions 属性(字符串列表) +指定取消一个或多个预处理器定义。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /U | -U | -U + +示例: +```xml + + __VERSION;__VERSION_INFO;%(UndefinePreprocessorDefinitions) + +``` + +### 3.1.16. UndefineAllPreprocessorDefinitions 属性(bool) +取消以前定义的所有预处理器值。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /u | -undef | -undef +| false | | | + +示例: +```xml + + true + +``` + +### 3.1.17. PositionIndependentCode 属性(bool) +生成位置无关代码(PIC)以便在共享库中使用。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fpic | -fpic +| false | | | + +### 3.1.18. ThreadSafeStatics 属性(bool) +发出额外代码以使用 C++ ABI 中指定的例程实现局部静态变量的线程安全初始化。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fthreadsafe-statics | -fthreadsafe-statics +| false | 自动忽略 | -fno-threadsafe-statics | -fno-threadsafe-statics + +### 3.1.19. FloatingPointModel 属性(枚举) +设置浮点模型。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| Precise | /fp:precise | | | 默认值。改进有关相等和不相等的浮点测试的一致性。 +| Strict | /fp:strict | | | 最严格的浮点模型。相对性能较低。 +| Fast | /fp:fast | -ffast-math | -ffast-math | 在大多数情况下,创建运行速度最快的代码。 + +### 3.1.20. HideInlineMethods 属性(bool) +启用时,内联方法的外联副本会声明为“private extern”。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fvisibility-inlines-hidden | -fvisibility-inlines-hidden +| false | 自动忽略 | | + +### 3.1.21. SymbolsHiddenByDefault 属性(bool) +所有符号都声明为“private extern”,除非显式标记为使用“__attribute”宏导出。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fvisibility=hidden | -fvisibility=hidden +| false | 自动忽略 | | + +### 3.1.22. ExceptionHandling 属性(枚举) +指定将由编译器使用的异常处理模型。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| false | | -fno-exceptions | -fno-exceptions | 无异常,禁用异常。 +| Async | /EHa | -fexceptions | -fexceptions | 捕获异步(SEH)和同步(C++)异常的异常处理模型。但是SEH只有Windows有,其他平台自动忽略。 +| Sync | /EHsc | -fexceptions | -fexceptions | 仅捕获 C++ 异常并通知编译器假定 Extern C 函数从不引发 C++ 异常的异常处理模型。 +| SyncCThrow | /EHs | -fexceptions | -fexceptions | 仅捕获 C++ 异常并通知编译器假定 Extern C 函数引发异常的异常处理模型。 + +示例: +```xml + + Sync + +``` + +### 3.1.23. RuntimeTypeInfo 属性(bool) +添加在运行时检查 C++ 对象类型(运行时类型信息)的代码。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /GR | -frtti | -frtti +| false | /GR- | -fno-rtti | -fno-rtti + + +### 3.1.24. LanguageStandard_C 属性(枚举) +确定编译器将强制执行的 C 语言标准。建议尽可能使用最新版本。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| Default | | | | 使用编译器默认标准,对于Windows它是旧 MSVC标准(C89 + 微软扩展),而GCC/CLang等价于gnu17标准。 +| stdc11 | /std:c11 | -std=c11 | -std=c11 | ISO C11 标准。 +| stdc17 | /std:c17 | -std=c17 | -std=c17 | ISO C17 (2018)标准。 +| c89 | 不支持 | -std=c89 | -std=c89 | ISO C89 语言标准。 +| c99 | 不支持 | -std=c99 | -std=c99 | ISO C99 语言标准。 +| c11 | 不支持 | -std=c11 | -std=c11 | ISO C11 标准。 +| c17 | 不支持 | -std=c17 | -std=c17 | ISO C17 (2018)标准。 +| c2x | 不支持 | -std=c2x | -std=c2x | C89 (GNU Dialect)语言标准。 +| gnu89 | 不支持 | -std=gnu89 | -std=gnu89 | C89 (GNU Dialect)语言标准。 +| gnu90 | 不支持 | -std=gnu90 | -std=gnu90 | C90 (GNU Dialect)语言标准。 +| gnu99 | 不支持 | -std=gnu99 | -std=gnu99 | C99 (GNU Dialect)语言标准。 +| gnu11 | 不支持 | -std=gnu11 | -std=gnu11 | C11 (GNU Dialect)语言标准。 +| gnu17 | 不支持 | -std=gnu17 | -std=gnu17 | C17 (GNU Dialect)语言标准。 + +示例: +```xml + + stdc11 + +``` + +### 3.1.25. LanguageStandard 属性(枚举) +确定编译器将强制执行的 C++ 语言标准。建议尽可能使用最新版本。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| Default | | | | 使用编译器默认标准,对于Windows它是默认(ISO C++14 标准),而GCC/CLang等价于gnu++17标准。 +| stdcpp14 | /std:c++14 | -std=c++14 | -std=c++14 | ISO C++14 标准。 +| stdcpp17 | /std:c++17 | -std=c++17 | -std=c++17 | ISO C++17 标准。 +| stdcpp20 | /std:c++20 | -std=c++20 | -std=c++20 | ISO C++20 标准。 +| stdcpplatest | /std:c++latest | -std=c++2b | -std=c++2b | 最新 C++ 工作草案中的功能。不推荐使用。 +| c++98 | 不支持 | -std=c++98 | -std=c++98 | C++98 语言标准。 +| c++03 | 不支持 | -std=c++03 | -std=c++03 | C++03 语言标准。 +| c++11 | 不支持 | -std=c++11 | -std=c++11 | C++11 语言标准。 +| c++1y | 不支持 | -std=c++14 | -std=c++14 | C++14 语言标准。 +| c++14 | 不支持 | -std=c++14 | -std=c++14 | C++14 语言标准。(建议使用 stdcpp14 +| c++17 | 不支持 | -std=c++17 | -std=c++17 | C++17 语言标准。(建议使用 stdcpp17) +| c++2a | 不支持 | -std=c++2a | -std=c++2a | C++2a 语言标准。 +| c++20 | 不支持 | -std=c++20 | -std=c++20 | C++20 语言标准。(建议使用 stdcpp20) +| c++2b | 不支持 | -std=c++2b | -std=c++2b | C++2b 语言标准。(建议使用 stdcpplatest) +| gnu++98 | 不支持 | -std=gnu++98 | -std=gnu++98 | C++98 (GNU Dialect)语言标准。 +| gnu++03 | 不支持 | -std=gnu++03 | -std=gnu++03 | C++03 (GNU Dialect)语言标准。 +| gnu++11 | 不支持 | -std=gnu++11 | -std=gnu++11 | C++11 (GNU Dialect)语言标准。 +| gnu++1y | 不支持 | -std=gnu++1y | -std=gnu++1y | C++1y (GNU Dialect)语言标准。 +| gnu++14 | 不支持 | -std=gnu++14 | -std=gnu++14 | C++14 (GNU Dialect)语言标准。 +| gnu++1z | 不支持 | -std=gnu++1z | -std=gnu++1z | C++1z (GNU Dialect)语言标准。 +| gnu++17 | 不支持 | -std=gnu++17 | -std=gnu++17 | C++17 (GNU Dialect)语言标准。 +| gnu++20 | 不支持 | -std=gnu++20 | -std=gnu++20 | C++20 (GNU Dialect)语言标准。 +| gnu++2b | 不支持 | -std=gnu++2b | -std=gnu++2b | C++2b (GNU Dialect)语言标准。 + +示例: +```xml + + stdcpp14 + +``` +### 3.1.26. ForcedIncludeFiles 属性(字符串列表) +一个或多个要强制的包含文件。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /FI | -include | -include + +示例: +```xml + + C:\123.h;D:456.h;%(ForcedIncludeFiles) + +``` + +### 3.1.27. EnableASAN 属性(bool) +使用 AddressSanitizer 编译和链接程序。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /fsanitize=address | -fsanitize=address | -fsanitize=address +| false | | | + +示例: +```xml + + true + +``` + +### 3.1.28. ObjCAutomaticRefCounting 属性(bool) +为Object-C对象开启自动引用技术支持。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | 自动忽略 | -fobjc-arc +| false | 自动忽略 | 自动忽略 | + +示例: +```xml + + true + +``` + +### 3.1.29. ObjCAutomaticRefCountingExceptionHandlingSafe 属性(bool) +ObjCAutomaticRefCounting开启时发生异常保证不泄露内存。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | 自动忽略 | -fobjc-arc-exceptions +| false | 自动忽略 | 自动忽略 | + +示例: +```xml + + true + +``` + +### 3.1.30. ObjCExceptionHandling 属性(枚举) +为Object-C开启异常支持。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| Disabled | 自动忽略 | 自动忽略 | | Obecjt-C不开启异常。 +| Enabled | 自动忽略 | 自动忽略 | -fobjc-exceptions | Obecjt-C开启异常。 + +示例: +```xml + + Enabled + +``` + +## 3.2. Link +链接配置。 + +### 3.2.1. OutputFile 属性(string) +重写链接器创建的程序的默认名称和位置。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /OUT | -o | -o + +### 3.2.2. ShowProgress 属性(字符串) +打印链接器进度消息。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| NotSet | | | | 无详细程度。 +| LinkVerbose | /VERBOSE | -Wl,--verbose | 自动忽略 | 显示所有进度消息。 +| LinkVerboseLib | /VERBOSE:Lib | 自动忽略 | 自动忽略 | 显示只指示所搜索的库的进度消息。 +| LinkVerboseICF | /VERBOSE:ICF | 自动忽略 | 自动忽略 | 显示有关优化链接期间的 COMDAT 折叠的信息。 +| LinkVerboseREF | /VERBOSE:REF | 自动忽略 | 自动忽略 | 显示有关优化链接期间移除的函数和数据的信息。 +| LinkVerboseSAFESEH | /VERBOSE:SAFESEH | 自动忽略 | 自动忽略 | 显示有关与安全异常处理不兼容的模块的信息 。 +| LinkVerboseCLR | /VERBOSE:CLR | 自动忽略 | 自动忽略 | 显示有关托管代码相关的链接器活动的信息。 + +示例: +```xml + + LinkVerbose + +``` + +### 3.2.3. TraceSymbols 属性(字符串列表) +打印符号显示在其中的文件列表。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -Wl,--trace-symbol | -Wl,--trace-symbol + +示例: +```xml + + main;%(TraceSymbols) + +``` + +### 3.2.4. GenerateMapFile 属性(bool) +通知链接器输出链接映射。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,--print-map | -Wl,--print-map +| false | 自动忽略 | | + +示例: +```xml + + true + +``` + +### 3.2.5. UnresolvedSymbolReferences 属性(bool) +报告未解析的符号引用。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,--no-undefined | -Wl,-undefined,error +| false | 自动忽略 | | + +示例: +```xml + + true + +``` + +### 3.2.6. OptimizeforMemory 属性(bool) +如有必要,通过重读符号表优化内存使用率。 +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,--no-keep-memory | -Wl,--no-keep-memory +| false | 自动忽略 | | + +示例: +```xml + + true + +``` + +### 3.2.7. SharedLibrarySearchPath 属性(字符串列表) +共享库搜索路径。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -Wl,-L | -Wl,-L + +示例: +```xml + + C:\123;D:\456;%(SharedLibrarySearchPath) + +``` + +### 3.2.8. IgnoreSpecificDefaultLibraries 属性(字符串列表) +指定要忽略的一个或多个默认库的名称;用分号分隔多个库。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | /NODEFAULTLIB | -Wl,--exclude-libs | -Wl,--exclude-libs + +示例: +```xml + + 123.a;456.a;%(IgnoreSpecificDefaultLibraries) + +``` + +### 3.2.9. ForceUndefineSymbolReferences 属性(字符串列表) +强制将符号作为未定义符号输入在输入文件中。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -Wl,-u--undefined | -Wl,-u--undefined + +示例: +```xml + + main;%(ForceUndefineSymbolReferences) + +``` + +### 3.2.10. DebuggerSymbolInformation 属性(枚举) +输出文件中的调试器符号信息。 + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| true | 自动忽略 | | | 包含全部符号。 +| IncludeAll | 自动忽略 | | | 包含全部符号。 +| OmitDebuggerSymbolInformation | 自动忽略 | -Wl,--strip-debug | -Wl,--strip-debug | 仅忽略调试器符号信息。 +| OmitAllSymbolInformation | 自动忽略 | -Wl,--strip-all | -Wl,--strip-all | 忽略所有符号信息。 +``` + +示例: +```xml + + true + +``` + +### 3.2.11. MapFileName 属性(字符串) +让链接器创建具有用户指定名称的映射文件。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -Wl,-Map | -Wl,-Map + + +示例: +```xml + + 123.map + +``` + +### 3.2.12. Relocation 属性(bool) +重定位后此选项标记变量为只读。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,-z,relro | -Wl,-z,relro +| false | 自动忽略 | -Wl,-z,norelro | -Wl,-z,norelro + + +示例: +```xml + + true + +``` + +### 3.2.13. FunctionBinding 属性(bool) +此选项标记对象用于即时函数绑定。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,-z,now | 自动忽略 +| false | 自动忽略 | | 自动忽略 + +### 3.2.14. NoExecStackRequired 属性(bool) +此选项标记输出为不需要可执行堆栈的输出。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -Wl,-z,noexecstack | 自动忽略 +| false | 自动忽略 | | 自动忽略 + +### 3.2.15. LinkDll 属性(bool) +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -shared | -shared +| false | 自动忽略 | | + +### 3.2.16. AdditionalDependencies 属性(字符串列表) +指定要添加到链接命令行的附加项。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | | | + +示例: +```xml + + C:\1111.a;%(AdditionalDependencies) + +``` + +### 3.2.17. LibraryDependencies 属性(字符串列表) +此选项允许指定要添加到链接器命令行的其他库。其他库将添加到前缀为“lib”和结尾扩展名为“.a”的链接器命令行的末尾。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | -l | -l + +示例: +```xml + + 1111.a;%(LibraryDependencies) + +``` + +### 3.2.18. EnableASAN 属性(bool) +使用 AddressSanitizer 链接程序。还必须使用地址擦除系统选项进行编译。必须使用调试程序运行以查看诊断结果。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | 自动忽略 | -fsanitize=address | -fsanitize=address +| false | 自动忽略 | | + +示例: +```xml + + true + +``` + +### 3.2.19. UseOfStl 属性(bool) + +| 选项 | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) | 选项含义 +| ------------------ | ----------------- | ----------------- | -------- | ------ +| libstdc++_shared | 自动忽略 | | | 动态使用。 +| libstdc++_static | 自动忽略 | -static-libstdc++ | -static-libstdc++ | 静态使用。 + +### 3.2.20. LinkStatus 属性(bool) +指定链接器是否应显示进度指示器,它显示完成的链接百分比。默认情况下不显示此状态信息。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| true | /LTCG:STATUS | -Wl,--stats | 自动忽略 +| false | /LTCG:NOSTATUS | | + +示例: +```xml + + true + +``` + +### 3.2.21. Frameworks 属性(字符串列表) +Apple特有的Framework引用(-framework)。 + +| | Windows(MSVC) | Linux(GCC/CLang) | OSX(GCC/CLang) +| ----------------- | ----------------- | ----------------- | -------- +| 映射参数 | 自动忽略 | 自动忽略 | -framework + +示例: +```xml + + Foundation;Cocoa;%(Frameworks) + ``` -> 温馨提示:`PlatformToolset` 必须从 1.2. 兼容的编译器小节中对应的平台工具集中选择,比如说想用GCC就设置`YY_Cross_GCC_1_0`。如果为空则根据平台自动选择。 -# 3. 我怎么自己编译 MSBuildCppCrossToolset? +# 附: 我怎么自己编译 MSBuildCppCrossToolset? > 温馨提示:普通用户无需关心如何编译 MSBuildCppCrossToolset。只需要从Release产物中下载即可。 注意:编译MSBuildCppCrossToolset需要安装`.NET 6.0 SDK`。 diff --git a/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj b/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj new file mode 100644 index 0000000..3e48a7d --- /dev/null +++ b/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj @@ -0,0 +1,82 @@ + + + + + + Debug + Win32 + + + + Release + Win32 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + + {1ce21f15-9bf3-41f8-86db-a8a85a9051e8} + Linux + HelloWorldApplication + 15.0 + + + + + true + false + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/HelloWorldApplication/main.cpp b/Samples/HelloWorld----C++/main.cpp similarity index 100% rename from Samples/HelloWorldApplication/main.cpp rename to Samples/HelloWorld----C++/main.cpp diff --git a/Samples/HelloWorldApplication/HelloWorldApplication.vcxproj b/Samples/HelloWorld----ObjectC++/HelloWorldApplication.vcxproj similarity index 91% rename from Samples/HelloWorldApplication/HelloWorldApplication.vcxproj rename to Samples/HelloWorld----ObjectC++/HelloWorldApplication.vcxproj index 5fea7c5..a19169d 100644 --- a/Samples/HelloWorldApplication/HelloWorldApplication.vcxproj +++ b/Samples/HelloWorld----ObjectC++/HelloWorldApplication.vcxproj @@ -61,12 +61,21 @@ + + + true + + + Foundation;Cocoa;%(Frameworks) + + - + + - + \ No newline at end of file diff --git a/Samples/HelloWorld----ObjectC++/main.mm b/Samples/HelloWorld----ObjectC++/main.mm new file mode 100644 index 0000000..1594048 --- /dev/null +++ b/Samples/HelloWorld----ObjectC++/main.mm @@ -0,0 +1,11 @@ +#import + +int main() +{ + @autoreleasepool + { + NSLog(@"Hello World Object-C++ built via MSBuildCppCrossToolset."); + } + + return 0; +} \ No newline at end of file diff --git a/Samples/MSBuildCppCrossToolsetSamples.sln b/Samples/MSBuildCppCrossToolsetSamples.sln deleted file mode 100644 index d73c3a0..0000000 --- a/Samples/MSBuildCppCrossToolsetSamples.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33530.505 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorldApplication", "HelloWorldApplication\HelloWorldApplication.vcxproj", "{1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM.ActiveCfg = Debug|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM.Build.0 = Debug|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM.Deploy.0 = Debug|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM64.Build.0 = Debug|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x64.ActiveCfg = Debug|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x64.Build.0 = Debug|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x64.Deploy.0 = Debug|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x86.ActiveCfg = Debug|x86 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x86.Build.0 = Debug|x86 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Debug|x86.Deploy.0 = Debug|x86 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM.ActiveCfg = Release|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM.Build.0 = Release|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM.Deploy.0 = Release|ARM - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM64.ActiveCfg = Release|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM64.Build.0 = Release|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|ARM64.Deploy.0 = Release|ARM64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x64.ActiveCfg = Release|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x64.Build.0 = Release|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x64.Deploy.0 = Release|x64 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x86.ActiveCfg = Release|x86 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x86.Build.0 = Release|x86 - {1CE21F15-9BF3-41F8-86DB-A8A85A9051E8}.Release|x86.Deploy.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3CAE289A-B58A-43DD-B2FB-4F5F2507A19D} - EndGlobalSection -EndGlobal diff --git a/Samples/ReadMe.md b/Samples/ReadMe.md index 0643c5f..6c855d0 100644 --- a/Samples/ReadMe.md +++ b/Samples/ReadMe.md @@ -13,15 +13,49 @@ export VCTargetsPath=/home/mouri/Workspace/MSBuildCppCrossToolsetRelease/VCTarge ``` ### 编译项目 +一般来说,Platform拥有以下几种可能: +* ARM +* ARM64 +* MIPS +* x64 +* x86(注意:对于Windows系统下的vcxproj来说叫Win32) -假设项目位置为 `/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples/MSBuildCppCrossToolsetSamples.sln`。并且编译 Release x86,那么可以输入如下命令: +> 温馨提示:Windows下搞不懂x86还是Win32的可以先尝试Win32,如果报错那么尝试一下x86。 + +; 假设项目位置为 `/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples`。并且编译一些 Release,那么可以输入如下命令: ``` -dotnet build '/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples/MSBuildCppCrossToolsetSamples.sln' '-p:Configuration=Release;Platform=x86' +; Linux、MacOS下编译 x86 +dotnet msbuild '/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj' '-p:Configuration=Release;Platform=x86' + +; Linux、MacOS下编译 x64 +dotnet msbuild '/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj' '-p:Configuration=Release;Platform=x64' + +; Linux、MacOS下编译 ARM64 +dotnet msbuild '/home/mouri/Workspace/MSBuildCppCrossToolsetWorkspace/Samples/HelloWorld----C++/HelloWorldApplication.vcxproj' '-p:Configuration=Release;Platform=ARM64' + +``` + +我们也可以在Windows平台编译`HelloWorldApplication.vcxproj`,命令如下: +``` +; Windows下编译 x86,注意它叫 Win32! +msbuild "D:\MSBuildCppCrossToolsetWorkspace\Samples\HelloWorld----C++\HelloWorldApplication.vcxproj" -p:Configuration=Release;Platform=Win32 + +; Windows下编译 x64 +msbuild "D:\MSBuildCppCrossToolsetWorkspace\Samples\HelloWorld----C++\HelloWorldApplication.vcxproj" -p:Configuration=Release;Platform=x64 + +; Windows下编译 ARM64 +msbuild "D:\MSBuildCppCrossToolsetWorkspace\Samples\HelloWorld----C++\HelloWorldApplication.vcxproj" -p:Configuration=Release;Platform=ARM64 + ``` ## 示例列表 -### [HelloWorldApplication](HelloWorldApplication/main.cpp) +### [HelloWorld----C++](HelloWorld----C++/HelloWorldApplication.vcxproj) + +一个简单的向控制台输出一段文本的应用,支持Windows、Linux以及MacOS。 + + +### [HelloWorld----ObjectC++](HelloWorld----ObjectC++/HelloWorldApplication.vcxproj) -一个简单的向控制台输出一段文本的应用 +使用`ObjectC++`输出一段文本的应用,注意这个示例仅支持MacOS。 diff --git a/VCTargets/v170/Application Type/OSX/1.0/Default.props b/VCTargets/v170/Application Type/OSX/1.0/Default.props new file mode 100644 index 0000000..2b12d6e --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Default.props @@ -0,0 +1,35 @@ + + + + + + + + + $(VCTargetsPath)\Application Type\$(ApplicationType)\$(ApplicationTypeRevision)\ + + YY_Cross_Clang_1_0 + + YY_Cross_Clang_1_0 + libstdc++_shared + Application + OSX + Raspberry + $(MSBuildProjectName) + ~/projects + $(ProjectName) + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.props b/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.props new file mode 100644 index 0000000..030c55a --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.props @@ -0,0 +1,33 @@ + + + + + + + + + BreadthFirst + + + + + + + false + + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.targets b/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.targets new file mode 100644 index 0000000..99617c7 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.Common.targets @@ -0,0 +1,140 @@ + + + + + + + + CreateRecipeFile; + MergeRecipeFiles; + ComputeIncludePathsFromRecipes; + $(BeforeBuildCompileTargets); + + + + $(DetermineProjectTypeTargets); + ComputeIncludePathsFromRecipes + + + + + + + $([System.IO.Path]::Combine($(ProjectDir), $(TargetName)$(TargetExt).recipe)) + + + + + $(Configuration) + $(Platform) + $(TargetTriplet) + + + + + + + + + + + + + + $(TargetPath) + $(RemoteTargetPath) + @(IncludeFolders->'%(fullpath)') + $(RemoteIncludePath) + $([System.IO.Path]::Combine($(ProjectDir), $(IntDir))) + @(ReferenceRecipeFiles) + $(_ResolvedRemoteProjectDir) + + + + + + + + + + + + + + + %(MergedRecipe.RemoteIncludePath);$(AdditionalIncludeDirectoriesFromRecipes) + %(MergedRecipe.ProjectPublicIncludePath);$(AdditionalIncludeDirectoriesFromRecipes) + $(IncludePath);$(AdditionalIncludeDirectoriesFromRecipes) + + + + + + + + + + + + + + $(TLogLocation)SharedLibraryPaths.$(TargetName).tlog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.props b/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.props new file mode 100644 index 0000000..75adbdf --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.props @@ -0,0 +1,151 @@ + + + + + + + true + false + + $(IntermediateOutputPath) + obj\$(Platform)\$(Configuration)\ + $(IntDir) + bin\$(Platform)\$(Configuration)\ + + + false + false + Unicode + + + + + Native + + $(MSBuildProjectName) + + Application + + + + + true + .out + $(ProjectName) + exe + + + + true + .so.1.0 + lib$(ProjectName) + library + + + + true + .a + lib$(ProjectName) + staticlibrary + + + + + VCToolsInstallDir_is_not_defined + WindowsSdkDir_is_not_defined + <_CheckDev11ToolsInstalled>false + + + + + Performing Custom Build Tools + true + false + $(TLogLocation) + true + $(AcceptableNonZeroExitCodes) + + + Performing Custom Build Step + + + false + true + false + false + true + + + true + EnableAllWarnings + FullDebug + Minimal + NDEBUG;%(PreprocessorDefinitions) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-pointer-sign;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CAdditionalWarning) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CppAdditionalWarning) + Disabled + Full + false + $(IntDir) + false + false + false + false + true + Enabled + Disabled + true + false + false + false + false + NotUsing + $(IntDir)%(filename).o + Default + false + false + false + false + true + $(IntDir) + + CompileAsCpp + c11 + c++11 + true + + + false + false + false + false + false + false + false + false + true + $(OutDir)$(TargetName)$(TargetExt) + true + + + $(OutDir)$(TargetName)$(TargetExt) + Replacement + true + true + true + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.targets b/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.targets new file mode 100644 index 0000000..15d288f --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.Cross.Common.targets @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.Makefile.targets b/VCTargets/v170/Application Type/OSX/1.0/Linux.Makefile.targets new file mode 100644 index 0000000..46cab23 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.Makefile.targets @@ -0,0 +1,528 @@ + + + + + + + <_MSBuildProjectReferenceExistent Include="@(_MSBuildProjectReferenceExistent)"> + Linux + + + + + + + + $(NMakeOutput) + Undefined + + + + + $(TargetPlatformMoniker) + $(TargetPlatformIdentifier) + + + + + + + + + + + + $(RemoteBuildOutputs) + + + + + false + + + + + + + + + + + + + + + + + + + + + + + false + + true + ResolveRemoteDir;_CopySources;$(CreateRecipeFileDependOnTargets) + true + <_BuildUpToDateFile>$(IntDir)$(ProjectName).builduptodate + $(NMakeIncludeSearchPath) + + $(RemoteRootDir)/$(RemoteProjectRelDir)/ + $(RemoteRootDir)/$(RemoteOutRelDir)/ + $(RemoteRootDir)/$(RemoteIntRelDir)/ + + + + + + CompileAsC + + + + + CompileAsCpp + + + + + + + + + + + $(NMakeIncludeSearchPath) + + + + $(RemoteCppCompileToolExe) + $(RemoteCCompileToolExe) + + + + + + + + + + + + + + $(CIntelliSenseIncludePath) + $(CppIntelliSenseIncludePath) + + + @(TranslatedClCompile->'%(AdditionalIncludeDirectories)');@(ClCompile->'%(ISenseIncludeDirectories)') + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + + $([System.IO.Path]::Combine('$(_ResolvedRemoteProjectDir)','$(RemoteBuildOutputs)')) + + + + + + + + obj + lib + lib + dll + dll + xdc + + + + + + + + + + + + + + + $(IntDir)$(ResolvedRemoteTargetId).CopySourcesUpToDateFile.tlog + $(IntDir)$(ResolvedRemoteTargetId).CompileUpToDateFile.tlog + $(IntDir)$(ResolvedRemoteTargetId).RemoteProjectDirFile.tlog + + + + + + + + + + + + + + + + + + + + + + + + + PrepareForNMakeBuild;ResolveReferences;GetTargetPath;PreBuildEvent;RemotePreBuildEvent;_ResolveRemoteTarget;ResolveRemoteDir;_RequiresRemoteConnection;GetBuildInputsForIncrementalBuild + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project + + + File;BrowseObject + + + + + File + + + + File + + + File + + + Project + + + + + + + + + + + + + + + + + + + + + + _SetLinuxISenseIdentifier;$(DetermineProjectTypeTargets) + + + + + Linux;$(IntDir)iconfig.json + Linux.x64;$(IntDir)iconfig.json* + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.STL.props b/VCTargets/v170/Application Type/OSX/1.0/Linux.STL.props new file mode 100644 index 0000000..d02aadc --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.STL.props @@ -0,0 +1,38 @@ + + + + + <_PropertySheetDisplayName>Use of STL + + + + + + + + + + c++11 + false + + + + + + $(StlAdditionalDependencies) + + + $(StlIncludeDirectories) + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.props b/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.props new file mode 100644 index 0000000..108286a --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.props @@ -0,0 +1,253 @@ + + + + + + + x64 + + + + $(DevEnvDir)VC\Linux\include + $(DevEnvDir)VC\Linux\bin\gdb\gdb-multiarch\ + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + + + + $(GDBRoot)gdb-multiarch.exe + $(GdbShellExecProgramPath)\shellexec.exe + + $(LinuxNatvisPath)\stl.natvis + BreadthFirst + + + + + true + false + + $(IntermediateOutputPath) + $(ProjectDir)obj\$(Platform)\$(Configuration)\ + $(IntDir) + $(ProjectDir)bin\$(Platform)\$(Configuration)\ + + $(IntDir)LastWSLTarget.tlog + + + false + false + Unicode + + + + + Native + + $(MSBuildProjectName) + $(RemoteRootDir)/$(ProjectName) + $(RemoteProjectDir)/obj/$(Platform)/$(Configuration)/ + $(RemoteProjectDir) + No + build.ninja + $(RemoteDeployDir)/bin/$(Platform)/$(Configuration) + *.d;*.tlog;$(ExtensionsToDeleteOnClean) + true + true + true + true + true + true + + + WSL + + Application + + 7200000 + 3600000 + 3600000 + 3600000 + + false + true + + false + + True + false + default + $(RemoteRootDir)/$(ProjectName) + <_VC_IsWSLToolset>true + + + + + + + + + false + @(SourcesToCopyRemotely);@(DataFilesToCopyRemotely) + + + + + + true + .out + $(ProjectName) + exe + + + + true + .so + lib$(ProjectName) + library + + + + true + .a + lib$(ProjectName) + staticlibrary + + + + gdb + $(OutDir) + + true + true + enabled + gdb + detect_leaks=0 + + + + + VCToolsInstallDir_is_not_defined + WindowsSdkDir_is_not_defined + + LlvmPlatformName_is_not_defined + <_CheckDev11ToolsInstalled>false + + + + Performing Custom Build Tools + true + false + $(TLogLocation) + true + $(AcceptableNonZeroExitCodes) + + + Performing Custom Build Step + + + false + true + false + false + true + + + true + EnableAllWarnings + FullDebug + Minimal + NDEBUG;%(PreprocessorDefinitions) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-pointer-sign;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CAdditionalWarning) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CppAdditionalWarning) + Disabled + Full + false + $(IntDir) + false + false + false + false + true + Enabled + Disabled + true + Yes + false + false + false + true + false + NotUsing + $(IntDir)%(filename).o + Default + false + false + false + false + true + $(IntDir) + + CompileAsCpp + c11 + c++11 + true + true + + + false + false + false + false + false + false + false + true + false + true + $(OutDir)$(TargetName)$(TargetExt) + false + true + + true + false + true + true + + + $(OutDir)$(TargetName)$(TargetExt) + Replacement + true + true + + + $(LastBuildState) + + + + + LinuxWSLDebugger + NativeOnly + + + false + + + false + + + {EB21DC10-A496-4D6C-B221-49E4C7F8FB0B} + + 1 + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.targets b/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.targets new file mode 100644 index 0000000..d22044a --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.WSL.targets @@ -0,0 +1,541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Ubuntu + $(IntDir)LastWSLTarget.tlog + false + + + + + + %(Link.OutputFile) + $(LibraryPath);%(AdditionalLibraryDirectories) + + + + + + + + + + + + $(CIntelliSenseIncludePath) + $(CppIntelliSenseIncludePath) + + + @(TranslatedClCompile->'%(AdditionalIncludeDirectories)');@(ClCompile->'%(ISenseIncludeDirectories)') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(BeforeBuildCompileTargets); + _PrepareForClCompile; + + + + $(BuildLinkTargets); + + + + RemotePostBuildEvent; + $(AfterBuildLinkTargets); + + + + $(BuildGenerateSourcesTargets); + RemotePreBuildEvent; + + + $(OutDir)\$(TargetName)$(TargetExt) + $(RemoteOutDir)/$(TargetName)$(TargetExt) + + + + + + + + + + + + + + + EnableAllWarnings + CompileAsC + + + + + CompileAsCpp + + + + + + + + + + + + + + $(RemoteCppCompileToolExe) + $(RemoteCCompileToolExe) + + + + + + + + + + true + + + + + + + + + + false + + + + + + + <_MSBuildProjectReferenceExistent Include="@(_MSBuildProjectReferenceExistent)"> + Linux + + + + + + + + + + + $(IntDir)$(WindowsSubsystem).CopySourcesUpToDateFile.tlog + $(IntDir)$(WindowsSubsystem).CompileUpToDateFile.tlog + $(IntDir)$(WindowsSubsystem).LinkUpToDateFile.tlog + $(IntDir)$(WindowsSubsystem).RemoteProjectDirFile.tlog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(CompileUpToDateFile) + + + + + + + + + + + + + + + + $(CompileUpToDateFile) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project + + + Project + + + File;BrowseObject + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _SetLinuxISenseIdentifier;$(DetermineProjectTypeTargets) + + + + + Linux;$(IntDir)iconfig.json + + + + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.props b/VCTargets/v170/Application Type/OSX/1.0/Linux.props new file mode 100644 index 0000000..db3a34b --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.props @@ -0,0 +1,256 @@ + + + + + + + + x64 + + + + + $(DevEnvDir)VC\Linux\include\wiringPi\2.32 + $(DevEnvDir)VC\Linux\include + $(DevEnvDir)VC\Linux\bin\gdb\gdb-multiarch\ + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + + + + $(GDBRoot)gdb-multiarch.exe + $(GdbShellExecProgramPath)\shellexec.exe + + $(LinuxNatvisPath)\stl.natvis + + + + + true + false + + $(IntermediateOutputPath) + $(ProjectDir)obj\$(Platform)\$(Configuration)\ + $(IntDir) + $(ProjectDir)bin\$(Platform)\$(Configuration)\ + + $(IntDir)LastRemoteTarget.tlog + + + false + false + Unicode + + + + + $(RemoteRootDir)/$(ProjectName) + No + + $(RemoteProjectRelDir)/bin/$(Platform)/$(Configuration) + $(RemoteProjectRelDir)/obj/$(Platform)/$(Configuration) + + build.ninja + + Native + + + *.d;*.tlog;$(ExtensionsToDeleteOnClean) + true + true + true + true + true + true + + Application + + 7200000 + 3600000 + 3600000 + 3600000 + + false + true + + false + + True + false + true + rsync + + + + + + + + + true + @(SourcesToCopyRemotely);@(DataFilesToCopyRemotely) + + + + + + true + .out + $(ProjectName) + exe + + + + true + .so + lib$(ProjectName) + library + + + + true + .a + lib$(ProjectName) + staticlibrary + + + + gdb + $(RemoteOutDir) + + true + true + enabled + gdb + detect_leaks=0 + <_VC_IsWSLToolset>false + + + + + VCToolsInstallDir_is_not_defined + WindowsSdkDir_is_not_defined + + LlvmPlatformName_is_not_defined + <_CheckDev11ToolsInstalled>false + + + + + Performing Custom Build Tools + true + false + $(TLogLocation) + true + $(AcceptableNonZeroExitCodes) + + + Performing Custom Build Step + + + false + true + false + false + true + + + true + EnableAllWarnings + FullDebug + Minimal + NDEBUG;%(PreprocessorDefinitions) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-pointer-sign;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CAdditionalWarning) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CppAdditionalWarning) + Disabled + Full + false + $(IntDir) + false + false + false + false + true + Enabled + Disabled + true + Yes + false + false + false + true + false + NotUsing + $(IntDir)%(filename).o + Default + false + false + false + false + true + $(IntDir) + + CompileAsCpp + c11 + c++11 + true + true + + + false + false + false + false + false + false + false + true + false + true + $(TargetPath) + false + true + + true + false + true + true + + + $(TargetPath) + Replacement + true + true + + + + + + LinuxDebugger + NativeOnly + + + false + + + false + + + {EB21DC10-A496-4D6C-B221-49E4C7F8FB0B} + + 1 + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Linux.targets b/VCTargets/v170/Application Type/OSX/1.0/Linux.targets new file mode 100644 index 0000000..cb9177a --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Linux.targets @@ -0,0 +1,713 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(Link.OutputFile) + $(LibraryPath);%(AdditionalLibraryDirectories) + + + + + + false + + $(LocalRemoteCopySources) + _RequiresRemoteConnection;_ResolveRemoteTarget;ResolveRemoteDir;_CopySources;$(CreateRecipeFileDependOnTargets) + true + + $(RemoteRootDir)/$(RemoteProjectRelDir)/ + $(RemoteRootDir)/$(RemoteOutRelDir)/ + $(RemoteRootDir)/$(RemoteIntRelDir)/ + + true + $(RemoteOutDir) + + + + + + + + + + + + $(CIntelliSenseIncludePath) + $(CppIntelliSenseIncludePath) + + + @(TranslatedClCompile->'%(AdditionalIncludeDirectories)');@(ClCompile->'%(ISenseIncludeDirectories)') + + + + + + + + <_LibFullPath Condition="'$(ConfigurationType)'=='StaticLibrary' and '%(_ResolvedNativeProjectReferencePaths.FileType)' =='lib'">@(_ResolvedNativeProjectReferencePaths) + <_LibFullPath Condition="'$(ConfigurationType)'=='DynamicLibrary' and '$(IgnoreImportLibrary)'!='true'">$(ResolvedTargetPath) + <_LibFullPath Condition="'$(ConfigurationType)'=='StaticLibrary' and '$(GetResolvedLinkLibs_Order)' == 'BreadthFirst'">$(ResolvedTargetPath);$(_LibFullPath) + <_LibFullPath Condition="'$(ConfigurationType)'=='StaticLibrary' and '$(GetResolvedLinkLibs_Order)' != 'BreadthFirst'">$(_LibFullPath);$(ResolvedTargetPath) + + + + $(ConfigurationType) + lib + false + $(LinkUpToDateFile) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntDir)$(ResolvedRemoteTargetId).CopySourcesUpToDateFile.tlog + $(IntDir)$(ResolvedRemoteTargetId).CompileUpToDateFile.tlog + $(IntDir)$(ResolvedRemoteTargetId).LinkUpToDateFile.tlog + $(IntDir)$(ResolvedRemoteTargetId).RemoteProjectDirFile.tlog + + + + + + + + + + + + + <_Compile + Sources="@(ClCompile)" + ObjectFileName="%(ClCompile.ObjectFileName)" + DebugInformationFormat="%(ClCompile.DebugInformationFormat)" + TreatWarningAsError="%(ClCompile.TreatWarningAsError)" + Verbose="%(ClCompile.Verbose)" /> + + + + + + + + + false + + + + + + + <_MSBuildProjectReferenceExistent Include="@(_MSBuildProjectReferenceExistent)"> + Linux + + + + + + + + + + + + + + + + + + + + + + $(BeforeBuildCompileTargets); + _PrepareForClCompile; + + + + $(BuildLinkTargets); + + + + RemotePostBuildEvent + $(AfterBuildLinkTargets); + _WriteRemoteTarget; + + + + + $(CppCleanDependsOn); + _RemoteClean; + + + + $(BuildGenerateSourcesTargets); + RemotePreBuildEvent; + + + $(RemoteOutDir)/$(TargetName)$(TargetExt) + $(RemoteTargetPath) + + + + + + + + + + + + + + + + + + EnableAllWarnings + CompileAsC + + + + + CompileAsCpp + + + + + + + + + + + + + + $(RemoteCppCompileToolExe) + $(RemoteCCompileToolExe) + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(CompileUpToDateFile) + + + + + + + + + + + + + + + + $(CompileUpToDateFile) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project + + + File;BrowseObject + + + + + + + + File + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _SetLinuxISenseIdentifier;$(DetermineProjectTypeTargets) + + + + + Linux;$(IntDir)iconfig.json + Linux.x64;$(IntDir)iconfig.json* + + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.Default.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.Default.props new file mode 100644 index 0000000..b587d25 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.Default.props @@ -0,0 +1,28 @@ + + + + + + + + + ARM + ARM64 + ARM64 + armv7 + aarch64-linux-gnu + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.props new file mode 100644 index 0000000..685ee81 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.props @@ -0,0 +1,23 @@ + + + + + <_PlatformFolder>$(MSBuildThisFileDirectory) + + + + x86_64 + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.targets b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.targets new file mode 100644 index 0000000..c5b1ca6 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/ARM64/Platform.targets @@ -0,0 +1,18 @@ + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.Default.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.Default.props new file mode 100644 index 0000000..2b2fa06 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.Default.props @@ -0,0 +1,29 @@ + + + + + + + + + x86_64 + 64 + x64 + x86_64 + Disabled + x86_64-linux-gnu + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.props new file mode 100644 index 0000000..685ee81 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.props @@ -0,0 +1,23 @@ + + + + + <_PlatformFolder>$(MSBuildThisFileDirectory) + + + + x86_64 + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.targets b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.targets new file mode 100644 index 0000000..c5b1ca6 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x64/Platform.targets @@ -0,0 +1,18 @@ + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.Default.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.Default.props new file mode 100644 index 0000000..ef27a7a --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.Default.props @@ -0,0 +1,29 @@ + + + + + + + + + x86 + 32 + x86 + i386 + Disabled + i686-linux-gnu + + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.props b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.props new file mode 100644 index 0000000..7ca819d --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.props @@ -0,0 +1,23 @@ + + + + + <_PlatformFolder>$(MSBuildThisFileDirectory) + + + + i386 + + + + diff --git a/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.targets b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.targets new file mode 100644 index 0000000..c5b1ca6 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/1.0/Platforms/x86/Platform.targets @@ -0,0 +1,18 @@ + + + + + diff --git a/VCTargets/v170/Application Type/OSX/Default.props b/VCTargets/v170/Application Type/OSX/Default.props new file mode 100644 index 0000000..c5540f5 --- /dev/null +++ b/VCTargets/v170/Application Type/OSX/Default.props @@ -0,0 +1,26 @@ + + + + + + + + + OSX + OSX + x86 + + + + + diff --git a/YY.Build.Cross.Tasks/OSX/Compile.cs b/YY.Build.Cross.Tasks/OSX/Compile.cs new file mode 100644 index 0000000..e5296eb --- /dev/null +++ b/YY.Build.Cross.Tasks/OSX/Compile.cs @@ -0,0 +1,151 @@ +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System.Collections; +using Microsoft.Build.CPPTasks; +using Microsoft.Build.Framework; +// using Microsoft.Build.Linux.Shared; +// using Microsoft.Build.Linux.Tasks; +using Microsoft.Build.Utilities; +using System.Resources; +using Microsoft.Build.Shared; +using System.Text; +using System; + +namespace YY.Build.Cross.Tasks.OSX +{ + public class Compile : YY.Build.Cross.Tasks.Cross.Compile + { + public Compile() + : base() + { + var Index = SwitchOrderList.IndexOf("AdditionalOptions"); + SwitchOrderList.Insert(Index++, "ObjCAutomaticRefCounting"); + SwitchOrderList.Insert(Index++, "ObjCAutomaticRefCountingExceptionHandlingSafe"); + SwitchOrderList.Insert(Index++, "ObjCExceptionHandling"); + } + + // OSX 添加ObjectC 以及ObjectC++支持 + public virtual string CompileAs + { + get + { + if (IsPropertySet("CompileAs")) + { + return base.ActiveToolSwitches["CompileAs"].Value; + } + return null; + } + set + { + base.ActiveToolSwitches.Remove("CompileAs"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String); + toolSwitch.DisplayName = "Compile As"; + toolSwitch.Description = "Select compile language option for .c and .cpp files. 'Default' will detect based on .c or .cpp extention. (-x c, -x c++)"; + toolSwitch.ArgumentRelationList = new ArrayList(); + string[][] switchMap = new string[][] + { + new string[2] { "Default", "" }, + new string[2] { "CompileAsC", "-x c" }, + new string[2] { "CompileAsCpp", "-x c++" }, + new string[2] { "CompileAsObjC", "-x objective-c" }, + new string[2] { "CompileAsObjCpp", "-x objective-c++" } + }; + toolSwitch.SwitchValue = ReadSwitchMap("CompileAs", switchMap, value); + toolSwitch.Name = "CompileAs"; + toolSwitch.Value = value; + toolSwitch.MultipleValues = true; + base.ActiveToolSwitches.Add("CompileAs", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + public bool ObjCAutomaticRefCounting + { + get + { + if (IsPropertySet("ObjCAutomaticRefCounting")) + { + return base.ActiveToolSwitches["ObjCAutomaticRefCounting"].BooleanValue; + } + return false; + } + set + { + base.ActiveToolSwitches.Remove("ObjCAutomaticRefCounting"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.Boolean); + toolSwitch.DisplayName = "Object-C Automatic Reference Counting"; + toolSwitch.Description = "Synthesize retain and release calls for Objective-C pointers"; + toolSwitch.ArgumentRelationList = new ArrayList(); + toolSwitch.SwitchValue = "-fobjc-arc"; + toolSwitch.Name = "ObjCAutomaticRefCounting"; + toolSwitch.BooleanValue = value; + base.ActiveToolSwitches.Add("ObjCAutomaticRefCounting", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + public bool ObjCAutomaticRefCountingExceptionHandlingSafe + { + get + { + if (IsPropertySet("ObjCAutomaticRefCountingExceptionHandlingSafe")) + { + return base.ActiveToolSwitches["ObjCAutomaticRefCountingExceptionHandlingSafe"].BooleanValue; + } + return false; + } + set + { + base.ActiveToolSwitches.Remove("ObjCAutomaticRefCountingExceptionHandlingSafe"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.Boolean); + toolSwitch.DisplayName = "Object-C Automatic Reference Counting Except Handle Safe"; + toolSwitch.Description = "Use EH-safe code when synthesizing retains and releases in -fobjc-arc."; + toolSwitch.ArgumentRelationList = new ArrayList(); + toolSwitch.SwitchValue = "-fobjc-arc-exceptions"; + toolSwitch.Name = "ObjCAutomaticRefCountingExceptionHandlingSafe"; + toolSwitch.BooleanValue = value; + base.ActiveToolSwitches.Add("ObjCAutomaticRefCountingExceptionHandlingSafe", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + public string ObjCExceptionHandling + { + get + { + if (IsPropertySet("ObjCExceptionHandling")) + { + return base.ActiveToolSwitches["ObjCExceptionHandling"].Value; + } + return null; + } + set + { + base.ActiveToolSwitches.Remove("ObjCExceptionHandling"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String); + toolSwitch.DisplayName = "ObjC Exception Handling"; + toolSwitch.Description = "Enable Objective-C exceptions."; + toolSwitch.ArgumentRelationList = new ArrayList(); + string[][] switchMap = new string[][] + { + new string[2] { "Disabled", "" }, + new string[2] { "Enabled", "-fobjc-exceptions" } + }; + toolSwitch.SwitchValue = ReadSwitchMap("ObjCExceptionHandling", switchMap, value); + toolSwitch.Name = "ObjCExceptionHandling"; + toolSwitch.Value = value; + toolSwitch.MultipleValues = true; + base.ActiveToolSwitches.Add("ObjCExceptionHandling", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + protected override void ValidateRelations() + { + if(!ObjCAutomaticRefCounting) + { + base.ActiveToolSwitches.Remove("ObjCAutomaticRefCountingExceptionHandlingSafe"); + } + } + } +} \ No newline at end of file diff --git a/YY.Build.Cross.Tasks/OSX/Ld.cs b/YY.Build.Cross.Tasks/OSX/Ld.cs new file mode 100644 index 0000000..0d5c40a --- /dev/null +++ b/YY.Build.Cross.Tasks/OSX/Ld.cs @@ -0,0 +1,102 @@ +using Microsoft.Build.CPPTasks; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace YY.Build.Cross.Tasks.OSX +{ + public class Ld : YY.Build.Cross.Tasks.Cross.Ld + { + public Ld() + : base() + { + // 苹果自带的ld不支持这几个选项 + SwitchOrderList.Remove("Relocation"); + SwitchOrderList.Remove("FunctionBinding"); + SwitchOrderList.Remove("NoExecStackRequired"); + SwitchOrderList.Remove("ShowProgress"); + SwitchOrderList.Remove("LinkStatus"); + + var Index = SwitchOrderList.IndexOf("AdditionalOptions"); + SwitchOrderList.Insert(Index++, "FlatNamespace"); + SwitchOrderList.Insert(Index++, "Frameworks"); + } + + public override bool UnresolvedSymbolReferences + { + get + { + if (IsPropertySet("UnresolvedSymbolReferences")) + { + return base.ActiveToolSwitches["UnresolvedSymbolReferences"].BooleanValue; + } + return false; + } + set + { + base.ActiveToolSwitches.Remove("UnresolvedSymbolReferences"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.Boolean); + toolSwitch.DisplayName = "Report Unresolved Symbol References"; + toolSwitch.Description = "This option when enabled will report unresolved symbol references."; + toolSwitch.ArgumentRelationList = new ArrayList(); + // toolSwitch.SwitchValue = "-Wl,--no-undefined"; + toolSwitch.SwitchValue = "-Wl,-undefined,error"; + toolSwitch.Name = "UnresolvedSymbolReferences"; + toolSwitch.BooleanValue = value; + base.ActiveToolSwitches.Add("UnresolvedSymbolReferences", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + public virtual bool FlatNamespace + { + get + { + if (IsPropertySet("FlatNamespace")) + { + return base.ActiveToolSwitches["FlatNamespace"].BooleanValue; + } + return false; + } + set + { + base.ActiveToolSwitches.Remove("FlatNamespace"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.Boolean); + toolSwitch.DisplayName = "启用一级命名"; + toolSwitch.Description = "如果关闭则保存默认,默认值为二级命名(two_levelnamespace)。"; + toolSwitch.ArgumentRelationList = new ArrayList(); + toolSwitch.SwitchValue = "-Wl,-flat_namespace"; + toolSwitch.Name = "FlatNamespace"; + toolSwitch.BooleanValue = value; + base.ActiveToolSwitches.Add("FlatNamespace", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + + public string[] Frameworks + { + get + { + if (IsPropertySet("Frameworks")) + { + return base.ActiveToolSwitches["Frameworks"].StringList; + } + return null; + } + set + { + base.ActiveToolSwitches.Remove("Frameworks"); + ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.StringArray); + toolSwitch.DisplayName = "依赖的Framework"; + toolSwitch.Description = "Apple特有的Framework引用(-framework)。"; + toolSwitch.ArgumentRelationList = new ArrayList(); + toolSwitch.SwitchValue = "-framework "; + toolSwitch.Name = "Frameworks"; + toolSwitch.StringList = value; + base.ActiveToolSwitches.Add("Frameworks", toolSwitch); + AddActiveSwitchToolValue(toolSwitch); + } + } + } +} diff --git a/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.props b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.props new file mode 100644 index 0000000..c920c71 --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.props @@ -0,0 +1,48 @@ + + + + + + + + + + + clang++ + clang++ + clang++ + clang++ + ar + gdbserver + gdb + + $(Path) + <_IsClang>true + <__IsYYLinuxCross>true + + + + + $(StlIncludeDirectories);%(ClCompile.AdditionalIncludeDirectories) + $(ThumbMode) + false + + + $(StlAdditionalDependencies);%(Link.AdditionalDependencies) + %(Link.AdditionalLibraryDirectories) + %(Link.SharedLibrarySearchPath) + + + + + diff --git a/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.targets b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.targets new file mode 100644 index 0000000..04a319a --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_Clang_1_0/Toolset.targets @@ -0,0 +1,38 @@ + + + + + + + false + <_ApplicableDebuggers>Desktop + + + + + + + + + <_TargetExt>$(TargetExt) + + + + $(_TargetExt) + + + + + + + diff --git a/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.props b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.props new file mode 100644 index 0000000..e59ad2a --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.props @@ -0,0 +1,48 @@ + + + + + + + + + + + g++ + g++ + g++ + g++ + ar + gdbserver + gdb + + $(Path) + <_IsClang>false + <__IsYYLinuxCross>true + + + + + $(StlIncludeDirectories);%(ClCompile.AdditionalIncludeDirectories) + $(ThumbMode) + false + + + $(StlAdditionalDependencies);%(Link.AdditionalDependencies) + %(Link.AdditionalLibraryDirectories) + %(Link.SharedLibrarySearchPath) + + + + + diff --git a/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.targets b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.targets new file mode 100644 index 0000000..2bbdf75 --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/Platforms/YY_Cross_GCC_1_0/Toolset.targets @@ -0,0 +1,39 @@ + + + + + + + false + <_ApplicableDebuggers>Desktop + + + + + + + + + <_TargetExt>$(TargetExt) + false + + + + $(_TargetExt) + + + + + + + diff --git a/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.props b/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.props new file mode 100644 index 0000000..0f3d1da --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.props @@ -0,0 +1,230 @@ + + + + + + + x64 + + + + $(DevEnvDir)VC\Linux\include + $(DevEnvDir)VC\Linux\bin\gdb\gdb-multiarch\ + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + $(DevEnvDir)CommonExtensions\Microsoft\Linux\Linux + + + + $(GDBRoot)gdb-multiarch.exe + $(GdbShellExecProgramPath)\shellexec.exe + + $(LinuxNatvisPath)\stl.natvis + BreadthFirst + + + + + true + false + + $(IntermediateOutputPath) + $(ProjectDir)obj\$(Platform)\$(Configuration)\ + $(IntDir) + $(ProjectDir)bin\$(Platform)\$(Configuration)\ + + $(IntDir)LastWSLTarget.tlog + + + false + false + Unicode + + + + + Native + + $(MSBuildProjectName) + No + build.ninja + *.d;*.tlog;$(ExtensionsToDeleteOnClean) + true + true + true + + + WSL + + Application + + false + + True + false + default + $(RemoteRootDir)/$(ProjectName) + <_VC_IsWSLToolset>true + + + + + true + .out + $(ProjectName) + exe + + + + true + .so + lib$(ProjectName) + library + + + + true + .a + lib$(ProjectName) + staticlibrary + + + + gdb + $(OutDir) + + true + true + enabled + gdb + detect_leaks=0 + + + + + VCToolsInstallDir_is_not_defined + WindowsSdkDir_is_not_defined + + LlvmPlatformName_is_not_defined + <_CheckDev11ToolsInstalled>false + + + + Performing Custom Build Tools + true + false + $(TLogLocation) + true + $(AcceptableNonZeroExitCodes) + + + Performing Custom Build Step + + + false + true + false + false + true + + + true + EnableAllWarnings + FullDebug + Minimal + NDEBUG;%(PreprocessorDefinitions) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-pointer-sign;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CAdditionalWarning) + switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CppAdditionalWarning) + Disabled + Full + false + $(IntDir) + false + false + false + false + true + Enabled + Disabled + true + Yes + Precise + false + false + true + false + NotUsing + $(IntDir)%(filename).o + Default + false + false + false + false + true + $(IntDir) + + CompileAsCpp + c11 + c++11 + true + true + true + + + false + false + NotSet + false + false + false + false + true + false + true + $(OutDir)$(TargetName)$(TargetExt) + false + true + + true + false + true + true + true + + + $(OutDir)$(TargetName)$(TargetExt) + Replacement + true + true + true + + + $(LastBuildState) + + + + + LinuxWSLDebugger + NativeOnly + + + false + + + false + + + {EB21DC10-A496-4D6C-B221-49E4C7F8FB0B} + + 1 + + diff --git a/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.targets b/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.targets new file mode 100644 index 0000000..0e3d876 --- /dev/null +++ b/YY.Build.Cross.Tasks/Targets/OSX/YY.OSX.Cross.targets @@ -0,0 +1,327 @@ + + + + + + + + + + + + + MacOS + + + + + + %(Link.OutputFile) + $(LibraryPath);%(AdditionalLibraryDirectories) + + + %(Link.GenerateMapFile) + true + + + + + + + + $(BeforeBuildCompileTargets); + _PrepareForClCompile; + + + + $(BuildLinkTargets); + + + $(OutDir)\$(TargetName)$(TargetExt) + $(RemoteOutDir)/$(TargetName)$(TargetExt) + + + + + + + + + + + + + + false + EnableAllWarnings + CompileAsC + true + Fast + + + + CompileAsObjC + + + + CompileAsObjCpp + + + + + CompileAsCpp + + + %(ClCompile.CLanguageStandard) + %(ClCompile.CppLanguageStandard) + + + + + + + + + + + + + + $(RemoteCppCompileToolExe) + $(RemoteCCompileToolExe) + + + + + + + + + + true + + + + + + <_MSBuildProjectReferenceExistent Include="@(_MSBuildProjectReferenceExistent)"> + Linux + + + + + + + + + + + + false + false + true + + + + + + + + + + + + + false + $(ExcludePath) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project + + + Project + + + File;BrowseObject + + + + + + + + + + + + + + + + + + + + + + + + + + _SetLinuxISenseIdentifier;$(DetermineProjectTypeTargets) + + + + + Linux;$(IntDir)iconfig.json + + + + + + + + + diff --git a/YY.Build.Cross.Tasks/YY.Build.Cross.Tasks.projitems b/YY.Build.Cross.Tasks/YY.Build.Cross.Tasks.projitems index 271519c..ed2bad9 100644 --- a/YY.Build.Cross.Tasks/YY.Build.Cross.Tasks.projitems +++ b/YY.Build.Cross.Tasks/YY.Build.Cross.Tasks.projitems @@ -13,6 +13,8 @@ + + @@ -21,6 +23,10 @@ + + + +