diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-12-11 13:51:06 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-12-15 13:05:56 -0800 |
commit | 5ba07e8fe47bdbefe4c9a292d1441b9e08170095 (patch) | |
tree | 1927c8ebb98809df9ee87822fd9edb9ec59b9cee | |
parent | c7e45974615735f2337ddfcd1f756062443d254d (diff) | |
download | build_soong-5ba07e8fe47bdbefe4c9a292d1441b9e08170095.tar.gz build_soong-5ba07e8fe47bdbefe4c9a292d1441b9e08170095.tar.bz2 build_soong-5ba07e8fe47bdbefe4c9a292d1441b9e08170095.zip |
Only change behavior when actually embedded in make
The change to enable embedding in make change the default behavior to
produce an Android.mk file, change the ninja builddir, and add the
-soong suffix to the end of target names. These don't make sense if
we're not building inside make, so detect if we're running under make
by checking for a .soong.in_make file in the builddir.
Change-Id: I1a0f4c1becb327c769b8a130cafef11d83eb49f4
-rw-r--r-- | common/androidmk.go | 4 | ||||
-rw-r--r-- | common/config.go | 11 | ||||
-rw-r--r-- | common/module.go | 18 |
3 files changed, 30 insertions, 3 deletions
diff --git a/common/androidmk.go b/common/androidmk.go index 06aa30c5..9470b6b6 100644 --- a/common/androidmk.go +++ b/common/androidmk.go @@ -55,6 +55,10 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext hasBPDir := make(map[string]bool) bpDirs := []string{} + if !ctx.Config().(Config).EmbeddedInMake() { + return + } + ctx.SetNinjaBuildDir(pctx, filepath.Join(ctx.Config().(Config).buildDir, "..")) ctx.VisitAllModules(func(module blueprint.Module) { diff --git a/common/config.go b/common/config.go index 7f6ee65d..971c4c11 100644 --- a/common/config.go +++ b/common/config.go @@ -58,6 +58,8 @@ type config struct { envLock sync.Mutex envDeps map[string]string envFrozen bool + + inMake bool } type jsonConfigurable interface { @@ -163,6 +165,11 @@ func NewConfig(srcDir, buildDir string) (Config, error) { return Config{}, err } + inMakeFile := filepath.Join(buildDir, ".soong.in_make") + if _, err := os.Stat(inMakeFile); err == nil { + config.inMake = true + } + hostArches, deviceArches, err := decodeArchProductVariables(config.ProductVariables) if err != nil { return Config{}, err @@ -228,6 +235,10 @@ func (c *config) EnvDeps() map[string]string { return c.envDeps } +func (c *config) EmbeddedInMake() bool { + return c.inMake +} + // DeviceName returns the name of the current device target // TODO: take an AndroidModuleContext to select the device name for multi-device builds func (c *config) DeviceName() string { diff --git a/common/module.go b/common/module.go index 36710c5a..bdaeb7aa 100644 --- a/common/module.go +++ b/common/module.go @@ -331,9 +331,14 @@ func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { } if len(deps) > 0 { + suffix := "" + if ctx.Config().(Config).EmbeddedInMake() { + suffix = "-soong" + } + ctx.Build(pctx, blueprint.BuildParams{ Rule: blueprint.Phony, - Outputs: []string{ctx.ModuleName() + "-soong"}, + Outputs: []string{ctx.ModuleName() + suffix}, Implicits: deps, Optional: true, }) @@ -568,10 +573,15 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte } }) + suffix := "" + if ctx.Config().(Config).EmbeddedInMake() { + suffix = "-soong" + } + // Create a top-level checkbuild target that depends on all modules ctx.Build(pctx, blueprint.BuildParams{ Rule: blueprint.Phony, - Outputs: []string{"checkbuild-soong"}, + Outputs: []string{"checkbuild" + suffix}, Implicits: checkbuildDeps, Optional: true, }) @@ -583,7 +593,9 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte Rule: blueprint.Phony, Outputs: []string{filepath.Join("mm", dir)}, Implicits: dirModules[dir], - Optional: true, + // HACK: checkbuild should be an optional build, but force it + // enabled for now in standalone builds + Optional: ctx.Config().(Config).EmbeddedInMake(), }) } } |