如何在 Dub 中添加和 运行 子包?
How to add and run subPackages in Dub?
Project/
dub.sdl/
source/
examples/
test/
source/
app.d
dub.sdl
Project/dub.sdl
...
subpackage "./examples/test"
...
Project/examples/test/dub.sdl
name "test"
targetType "executeable"
如果我尝试执行 dub run test
如果出现以下错误
Failed to parse package description for test in Project/examples/test.
Failed to find a package named 'test'.
如果我尝试执行 dub run :test
.
也会发生同样的情况
在命令中,您应该在子包名称前加上根包名称。
dub run rootpackagename:test
您似乎需要明确指定 run
(或 build
或其他命令)。
截至 2017 年配音版本 1.3.0:<rootpackagename>
是可选的。例如,我正在测试 jsoniopipe 包如下:
# Add dependency which is not found on dub's repo:
git clone https://github.com/schveiguy/iopipe ../iopipe
dub add-local ../iopipe
dub.sdl 文件:
name "jsoniopipe"
description "JSON parser for iopipe"
authors "Steven Schveighoffer"
copyright "Copyright © 2017, Steven Schveighoffer"
license "boost"
targetType "library"
dependency "iopipe" version="*"
subPackage {
name "formatjson"
targetType "executable"
sourcePaths "examples/formatjson"
dependency "jsoniopipe" version="*"
}
testjson.json
的内容
{
"name": "myproject",
"authors": [
"My Name"
],
"description": "My first project",
"copyright": "Copyright © 2017, imadev",
"license": "Boost"
}
运行 命令:
dub run :formatjson -- ./testjson.json
Project/
dub.sdl/
source/
examples/
test/
source/
app.d
dub.sdl
Project/dub.sdl
...
subpackage "./examples/test"
...
Project/examples/test/dub.sdl
name "test"
targetType "executeable"
如果我尝试执行 dub run test
如果出现以下错误
Failed to parse package description for test in Project/examples/test.
Failed to find a package named 'test'.
如果我尝试执行 dub run :test
.
在命令中,您应该在子包名称前加上根包名称。
dub run rootpackagename:test
您似乎需要明确指定 run
(或 build
或其他命令)。
截至 2017 年配音版本 1.3.0:<rootpackagename>
是可选的。例如,我正在测试 jsoniopipe 包如下:
# Add dependency which is not found on dub's repo:
git clone https://github.com/schveiguy/iopipe ../iopipe
dub add-local ../iopipe
dub.sdl 文件:
name "jsoniopipe"
description "JSON parser for iopipe"
authors "Steven Schveighoffer"
copyright "Copyright © 2017, Steven Schveighoffer"
license "boost"
targetType "library"
dependency "iopipe" version="*"
subPackage {
name "formatjson"
targetType "executable"
sourcePaths "examples/formatjson"
dependency "jsoniopipe" version="*"
}
testjson.json
的内容{
"name": "myproject",
"authors": [
"My Name"
],
"description": "My first project",
"copyright": "Copyright © 2017, imadev",
"license": "Boost"
}
运行 命令:
dub run :formatjson -- ./testjson.json