Gradle-为多个本机组件生成单个Visual Studio解决方案

light_keeper

我正在将大型代码库从自定义构建系统移植到Gradle。

我有什么办法用2个项目而不是2个单独的解决方案生成单个VS解决方案?

我的示例build.gradle文件:

apply plugin: 'cpp'
apply plugin: 'visual-studio'


model {
    components {
        debugger(NativeExecutableSpec) {
        }

        nativeagent(NativeLibrarySpec) {
        }
    }

    visualStudio {
            solutions.all {
                solutionFile.location = "vs/${name}.sln"
            }

            projects.all {
                projectFile.location = "vs/${name}.vcxproj"
                filtersFile.location = "vs/${name}.filters"
            }
    }
}

来自的输出.\gradlew tasks

.....
IDE tasks
---------
cleanVisualStudio - Removes all generated Visual Studio project and solution files
debuggerVisualStudio - Generates the Visual Studio solution for native executable 'debugger'.
nativeagentVisualStudio - Generates the Visual Studio solution for native library 'nativeagent'.
light_keeper

我自己弄清楚了,只需指定项目之间的依赖关系即可:

debugger(NativeExecutableSpec) {
            sources {
                cpp {
                    lib library: "nativeagent"                      
                    source {
                        srcDir "debugger/src"
                        include "**/*.cpp"
                    }
                }
            }
        }

并运行 .\gradlew debuggerVisualStudio

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章