如何使用 Gradle DSL(领域特定语言)上的文档?
How to use the documentation on the Gradle DSL (domain specific language)?
我目前正在设置我的混合java/cpp多模块gradle项目几天。虽然我承认我是groovy &Co的新手,但似乎每一步我都需要找到一个确切的例子来说明我正在努力做的事情,否则我无法进步。
问:谁能告诉我如何阅读这个 Gradle DSL 页面?我正在尝试使我的库编译为仅静态(不共享(,即使我使用了baseName
并看到了页面上记录的static
和shared
属性,我也无法理解如何使用它们。我的代码是:
components {
api(NativeLibrarySpec) {
sources {
cpp {
source {
srcDir "src/main/stuff"
include "**/*.cpp"
}
}
}
baseName "mylibrary"
static "true" <-- what to write here??
shared "false" <-- ??
}
}
我环顾四周,似乎你应该尝试一下:
components {
api(NativeLibrarySpec) {
sources {
cpp {
source {
srcDir "src/main/stuff"
include "**/*.cpp"
}
}
}
binaries {
all {
lib library: "mylibrary", linkage: "static"
}
}
}
}
编辑:
all
是来自ModelMap
接口的方法,由getBinaries
方法返回。它说:将给定的操作应用于集合中的每个项目
ModelMap
使用BinarySpec
作为参数,因此all
的参数是一个Action<BinarySpec>
对象。
所以Action
类(函数接口(定义了一个方法execute(BinarySpec spec)
。lib
的方法来自NativeBinarySpec
void lib(对象库(
将库作为输入添加到此二进制文件。
此方法接受以下类型:
A NativeLibrarySpec A NativeDependencySet A Map containing the library selector.
映射表示法支持以下字符串属性:
project: the path to the project containing the library (optional, defaults to current project) library: the name of the library (required) linkage: the library linkage required ['shared'/'static'] (optional, defaults to 'shared')
因此,总而言之,mylibrary
被添加为所有二进制文件的输入。
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 如何在文档文件夹中创建目录
- 当Microsoft文档仅包含 C# 示例时,如何查找 C++ 包含文件名
- 通过构造函数创建一些值并尝试添加到文档中使用 rapidjson 不起作用
- 关于类的 Python 文档 - 对C++的引用不正确
- C++/autoconf 等效于文档库要求.txt的要求是什么?
- mbed:使用 USB 文档库编译会导致错误
- C++ VISUAL STUDIO:GLFWwindow没有初始化,即使它是在文档中编写的并且以前工作过
- 使用 yaml-cpp 更新 YAML 文档的节点和值
- 在加载 MSHTML 文档之前从 MSHTML 文档中删除无效的 URL
- 如何在C++中表示JSON文档的递归对象结构?
- 如何查找 Redshift Maya API 文档?
- 如何使用值模板编写文档测试用例?
- 如何使用 Gradle DSL(领域特定语言)上的文档?
- ncurses 找不到任何关于cchar_t的文档
- 提取狮身人面像文档中的C++代码片段
- 关于 API 文档和设备操作 在助手-sdk-cpp 上
- 为整个Markdown文档设置默认的PER代码语言
- 如何在没有UTF-8特定代码的情况下解析多语言文档
- 混合语言代码文档-需要帮助调试氧