本文整理汇总了Golang中github.com/google/blueprint.ModuleContext.ModuleDir方法的典型用法代码示例。如果您正苦于以下问题:Golang ModuleContext.ModuleDir方法的具体用法?Golang ModuleContext.ModuleDir怎么用?Golang ModuleContext.ModuleDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/blueprint.ModuleContext
的用法示例。
在下文中一共展示了ModuleContext.ModuleDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: phonyGoTarget
func phonyGoTarget(ctx blueprint.ModuleContext, target string, srcs []string,
gensrcs []string, intermediates []string) {
var depTargets []string
ctx.VisitDepsDepthFirstIf(isGoPackageProducer,
func(module blueprint.Module) {
dep := module.(goPackageProducer)
target := dep.GoPackageTarget()
depTargets = append(depTargets, target)
})
moduleDir := ctx.ModuleDir()
srcs = pathtools.PrefixPaths(srcs, filepath.Join("$srcDir", moduleDir))
srcs = append(srcs, gensrcs...)
ctx.Build(pctx, blueprint.BuildParams{
Rule: phony,
Outputs: []string{target},
Inputs: srcs,
Implicits: depTargets,
})
// If one of the source files gets deleted or renamed that will prevent the
// re-bootstrapping happening because it depends on the missing source file.
// To get around this we add a build statement using the built-in phony rule
// for each source file, which will cause Ninja to treat it as dirty if its
// missing.
for _, src := range srcs {
ctx.Build(pctx, blueprint.BuildParams{
Rule: blueprint.Phony,
Outputs: []string{src},
})
}
// If there is no rule to build the intermediate files of a bootstrap go package
// the cleanup phase of the primary builder will delete the intermediate files,
// forcing an unnecessary rebuild. Add phony rules for all of them.
for _, intermediate := range intermediates {
ctx.Build(pctx, blueprint.BuildParams{
Rule: blueprint.Phony,
Outputs: []string{intermediate},
})
}
}
示例2: moduleSrcDir
// moduleSrcDir returns the path of the directory that all source file paths are
// specified relative to.
func moduleSrcDir(ctx blueprint.ModuleContext) string {
return filepath.Join("$srcDir", ctx.ModuleDir())
}