「myapp」というプロジェクトがあり、「sdlang-d」に依存しているとします。dub build --build=release-debug
コマンド ラインから使用して、プロジェクトをリリース デバッグとしてビルドしたいと考えています。SDLang の問題 #54により、sdlang-d を release-debug としてビルドすることはできません。そのため、ダブ構成ファイルを使用して、ビルド時に関係なく、sdlang-d を強制的に「debug」または「debugMode」としてビルドしたいと考えています。 「myapp」のオプションを選択し、デバッグ バージョンの sdlang-d をリリース バージョンの myapp にリンクします (これにより、sdlang-d の外部にあるコードが最適化の恩恵を受けることができます)。
テスト目的で、この状況をシミュレートするために「dub_dependency_config」という github プロジェクトを作成しました。次のテキストでは、私が試したことから観察した具体的な出力を提供するため、「myapp」の代わりに「 dub_dependency_config 」を参照します。
シンプルな dub.sdl 設定ファイルから始めます...
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1"
...そしてでコンパイルしようとするdub build --build=release-debug
と、もちろん問題#54がそのことを行います:
C:\dprojects\dub_dependency_config>dub build --build=release-debug
Performing "release-debug" build using dmd for x86_64.
libinputvisitor 1.2.2: target for configuration "library" is up to date.
taggedalgebraic 0.10.7: target for configuration "library" is up to date.
sdlang-d 0.10.1: building configuration "library"...
..\..\Users\cjoan\AppData\Roaming\dub\packages\sdlang-d-0.10.1\sdlang-d\src\sdlang\lexer.d(1273,41): Deprecation: function std.datetime.TimeZone.getTimeZone is deprecated - Use PosixTimeZone.getTimeZone or WindowsTimeZone.getTimeZone instead
..\..\Users\cjoan\AppData\Roaming\dub\packages\sdlang-d-0.10.1\sdlang-d\src\sdlang\ast.d(680,21): Error: null dereference in function _D6sdlang3ast3Tag16getTagAttributesMFAyaAyaZS6sdlang3ast3Tag146__T11MemberRangeTC6sdlang3ast9AttributeVAyaa13_616c6c41747472696275746573VAyaa17_617474726962757465496e646963696573VAyaa11_5f61747472696275746573Z11MemberRange
dmd failed with exit code 1.
これを回避するには、次のように書けると思います。
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1" {
buildOptions "debugMode"
}
これが実際に機能するとは思っていませんでした。ドキュメントには、そうすべきだとは書かれていません。とにかく試してみましたが、ダブはbuildOptions
タグ内のdependency
タグを無視しているようです。構成ファイルは以前のものと同等になり、同じ問題 #54 コンパイラ エラーが発生します。
このスレッドで言及されているように、この問題を解決するための推奨される方法と思われるsubConfigurationについて読みました。 経験するために失敗した構成をたくさん与えてくれました。いくつか見てみましょう:subConfiguration
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1"
configuration "application" {
targetType "executable"
targetName "bin/app"
mainSourceFile "source/app.d"
}
configuration "sdlang-hax" {
buildOptions "debugMode"
}
subConfiguration "sdlang-d" "sdlang-hax"
これにより、次の結果が得られます。
C:\dprojects\dub_dependency_config>dub build --build=release-debug
## Warning for package dub_dependency_config, configuration sdlang-hax ##
The following compiler flags have been specified in the package description
file. They are handled by DUB and direct use in packages is discouraged.
Alternatively, you can set the DFLAGS environment variable to pass custom flags
to the compiler, or use one of the suggestions below:
debugMode: Call DUB with --build=debug
Could not resolve configuration for package dub_dependency_config
そのため、私が何を意味するのか理解できず、慰めの賞として、私は取り除くことができないというしつこいメッセージを受け取りました;)
先へ!
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1"
configuration "application" {
targetType "executable"
targetName "bin/app"
mainSourceFile "source/app.d"
subConfiguration "sdlang-d" "sdlang-hax"
}
configuration "sdlang-hax" {
buildOptions "debugMode"
}
出力:
C:\dprojects\dub_dependency_config>dub build --build=release-debug
## Warning for package dub_dependency_config, configuration sdlang-hax ##
The following compiler flags have been specified in the package description
file. They are handled by DUB and direct use in packages is discouraged.
Alternatively, you can set the DFLAGS environment variable to pass custom flags
to the compiler, or use one of the suggestions below:
debugMode: Call DUB with --build=debug
Performing "release-debug" build using dmd for x86_64.
dub_dependency_config ~master: target for configuration "sdlang-hax" is up to date.
C:\dprojects\dub_dependency_config>bin\app.exe
'bin\app.exe' is not recognized as an internal or external command,
operable program or batch file.
興味深いことに、私たちはそれを構築して...何かを手に入れました (私には何のことかわかりませんが、それは私のプログラムではありません)。
より多くの組み合わせ!再帰しましょう!
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1"
configuration "application" {
targetType "executable"
targetName "bin/app"
mainSourceFile "source/app.d"
subConfiguration "sdlang-d" "sdlang-hax"
configuration "sdlang-hax" {
buildOptions "debugMode"
}
}
出力:
C:\dprojects\dub_dependency_config>dub build --build=release-debug
Could not resolve configuration for package dub_dependency_config
ナグが消えた!しかし、それは単に私がもっと失敗したことを意味すると思います。
学習のために、subConfiguration タグから情報のきしみを取得したいので、機能しないことがわかっていることを試します。
// dub.sdl
name "dub_dependency_config"
description "Example of configuring dependencies in dub.sdl."
authors "chadjoan"
copyright "Copyright © 2017, cjoan"
license "BSL-1.0"
dependency "sdlang-d" version="~>0.10.1"
configuration "application" {
targetType "executable"
targetName "bin/app"
mainSourceFile "source/app.d"
}
subConfiguration "sdlang-d" "application"
いいえ、私の間違った試みは間違った結果をもたらしました:
C:\dprojects\dub_dependency_config>dub build --build=release-debug
Could not resolve configuration for package dub_dependency_config
どうすれば機能しますか?
(余談ですが、.sdl 形式には非常に感謝しています。.json バージョンでも同じ問題が発生しました。コメント機能が不足しているだけで、ドキュメントはおろか、トラブルシューティングも困難になりました。)