DUB:创建两个具有共同代码库的可执行文件
DUB: Create two executable files with common code base
我需要生成两个具有一些通用源代码的 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 不推荐
为此目的使用子包:
It is also possible to define the sub packages within the root package file, but note that it is generally discouraged to put the source code of multiple sub packages into the same source folder. Doing so can lead to hidden dependencies to sub packages that haven't been explicitly stated in the "dependencies" section. These hidden dependencies can then result in build errors in conjunction with certain build modes or dependency trees that may be hard to understand.
我发现你用的是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"
}
我需要生成两个具有一些通用源代码的 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 不推荐 为此目的使用子包:
It is also possible to define the sub packages within the root package file, but note that it is generally discouraged to put the source code of multiple sub packages into the same source folder. Doing so can lead to hidden dependencies to sub packages that haven't been explicitly stated in the "dependencies" section. These hidden dependencies can then result in build errors in conjunction with certain build modes or dependency trees that may be hard to understand.
我发现你用的是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"
}