2017-07-31 4 views
0

"myapp"というプロジェクトがあり、 "sdlang-d"に依存しているとします。私はコマンドラインからdub build --build=release-debugを使って、リリースデバッグとして私のプロジェクトをビルドしたいと思います。 SDLang issue #54のため、私はそれをsdlang-dをrelease-debugとしてビルドすることはできないので、ダブ設定ファイルを使用してsdlang-dをビルドオプションを選択したときに関係なく "debug"または "debugMode" "myapp"を実行してから、sdlang-dのデバッグバージョンをmyappのリリースバージョンにリンクします(sdlang-d以外のコードでも最適化のメリットが得られます)。DUB設定ファイルで、依存関係の設定(buildOptions)を変更するにはどうすればよいですか?

テストの目的で、この状況をシミュレートするために"dub_dependency_config"と呼ばれるプロジェクトをgithubするために作成しました。以下のテキストでは、私が試したことから見た具体的な出力を提供するので、 "myapp"の代わりに "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" 

...シンプルdub.sdl設定ファイルで始まり...そして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" 
} 

私は関数expませんでしたこれを実際に働かせてください。ドキュメンテーションの何もそれはすべきではないと言った。とにかく試してみましたが、ダブはdependencyタグ内のbuildOptionsタグを無視しているようです。設定ファイルは前のものと同等になり、同じ問題#54コンパイラエラーが発生します。

this threadで説明したようにこの問題を解決するには、お勧めの方法と思われる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" 

この1利回り:

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 

nagが去っていきました!しかし、私はそれが単に失敗したことを意味すると思います。学習の興味で

、私は私がサブコ​​ンタグから情報のいずれかのきしむ音を得ることを期待通りに動作しないことを知っている何かをしてみてください:

// 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 

どうすればいいですか?

(余談:。。私は.jsonのバージョンでは、この同じ問題に遭遇し、言葉だけで能力をコメントの欠如だけで文書を聞かせて、トラブルシューティングにこれは難治作ら.sdl形式のために非常に感謝しています)

答えて

0

あなたは依存関係自体で利用可能な設定を参照する必要があると思います。ダブドコははっきりしていないし、前に似たような間違いをしている。 sdlang-Dにとっては、それがパッケージ内に4つの構成があります表示されますdub.sdl

  • CLI
  • ライブラリ
  • unittestの-組み込み
  • unittestの

これらは、中から選択するオプションですsubConfigurationブロック。私はあなたが実際にあなたのパッケージdub.sdlでそれらを宣言できるとは思わない。あなたの最初の出力ブロックでは、sdlang-dがlibrary構成を構築していることを示しています。

関連する問題