我需要生成两个具有一些通用源代码的exe文件。配音的最佳方法是什么?
我尝试做像一样,但是收到有关仅允许一个主要功能的错误消息。
这是我的dub.json:
{
"name": "code1",
"authors": [ "Suliman" ],
"description": "A minimal D application.",
"copyright": "Copyright © 2016, Suliman",
"license": "proprietary",
"subPackages": [
{
"name": "App1",
"targetName": "App1",
"description": "App1",
"targetType": "executable",
"excludedSourceFiles" : ["source/App2/*"],
"excludedSourceFiles" : ["source/app2.d"]
},
{
"name": "App2",
"targetName": "App2",
"description": "App2",
"targetType": "executable",
"excludedSourceFiles" : ["source/App1/*"],
"excludedSourceFiles" : ["source/app1.d"]
}]
}
最佳答案
您的dub.json
可以使用,但是您需要明确地告诉它以构建以下内容之一
带有dub build :App1
或dub build :App2
(其中:App1
是code1:App1
的快捷方式)。
单独配置可能更合适:
"configurations": [
{
"name": "App1",
"targetType": "executable",
"mainSourceFile": "source/app1.d",
"excludedSourceFiles": [ "source/app2.d", "source/App2/*" ],
"targetName": "app1"
},
{
"name": "App2",
"targetType": "executable",
"mainSourceFile": "source/app2.d",
"excludedSourceFiles": [ "source/app1.d", "source/App1/*" ],
"targetName": "app2"
}
]
dub build --config=App1
将产生app1
,dub build --config=App2
将产生app2
普通的
dub build
将默认为App1
。请注意,您需要
excludedSourceFiles
,因此dub不会看到重复的main
。The docs建议反对
为此目的使用子包:
我意识到您使用的是
dub.json
,所以我在上面放了json格式。对于参考,这是我之前发布的
dub.sdl
格式。configuration "App1" {
targetType "executable"
mainSourceFile "source/app1.d"
excludedSourceFiles "source/app2.d" "source/App2/*"
targetName "app1"
}
configuration "App2" {
targetType "executable"
mainSourceFile "source/app2.d"
excludedSourceFiles "source/app1.d" "source/App1/*"
targetName "app2"
}