多くのプラットフォームでC++ファイルを構築するために使用されるbuild.gradle
ファイルがあります。これは多くのプロジェクトで行われ、すべて同じプラットフォームを対象としています。このコードを別のプラグインに移動して、ビルドファイルのコードを最小限に抑えたいと思います。Gradle 3:カスタムプラグインの中からモデル要素を追加する方法は?
だから、私はbuild.gradle
で、現時点では、次のいる:
model {
platforms {
"osx-x86_64" {
operatingSystem "osx"
architecture "x86_64"
}
"stm32f4xx-arm" {
architecture "arm"
}
"windows" {
operatingSystem "windows"
architecture "x86_64"
}
"linux" {
operatingSystem "linux"
architecture "x86_64"
}
"pi" {
operatingSystem "linux"
architecture "arm"
}
}
toolChains {
clang(Clang)
gcc(Gcc) {
target('stm32f4xx-arm') {
def prefix = "arm-none-eabi-"
cCompiler.executable = prefix + cCompiler.executable
cppCompiler.executable = prefix + cppCompiler.executable
assembler.executable = prefix + assembler.executable
linker.executable = prefix + linker.executable
staticLibArchiver.executable = prefix + staticLibArchiver.executable
}
target('windows') {
def prefix = "x86_64-w64-mingw32-"
cCompiler.executable = prefix + cCompiler.executable
cppCompiler.executable = prefix + cppCompiler.executable
assembler.executable = prefix + assembler.executable
linker.executable = prefix + linker.executable
staticLibArchiver.executable = prefix + staticLibArchiver.executable
}
target('linux') {
def prefix = "x86_64-linux-"
cCompiler.executable = prefix + cCompiler.executable
cppCompiler.executable = prefix + cppCompiler.executable
assembler.executable = prefix + assembler.executable
linker.executable = prefix + linker.executable
staticLibArchiver.executable = prefix + staticLibArchiver.executable
}
target('pi') {
def prefix = "arm-none-linux-gnueabi-"
cCompiler.executable = prefix + cCompiler.executable
cppCompiler.executable = prefix + cppCompiler.executable
assembler.executable = prefix + assembler.executable
linker.executable = prefix + linker.executable
staticLibArchiver.executable = prefix + staticLibArchiver.executable
}
}
}
}
私はプラグインにこれを動かすにはどうすればよいですか?モデル空間ではなくプロジェクト空間を使用するので、Plugin.apply()
メソッドの中からモデル要素にアクセスすることはできません。これをRuleSourceルールでどのように使用するのか分かりません。