aboutsummaryrefslogtreecommitdiffstats
path: root/common/config.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-07-14 00:39:06 -0700
committerDan Willemsen <dwillemsen@google.com>2015-09-17 23:42:25 -0700
commit87b17d1ff46ab86ab897c50435c423f28be4895f (patch)
tree69d5b2ed53c5b99aacef6b3d692256ec0b671d21 /common/config.go
parentc3ba6cb9707730e0fc553fa86b9fe6b6c9bbb4b9 (diff)
downloadbuild_soong-87b17d1ff46ab86ab897c50435c423f28be4895f.tar.gz
build_soong-87b17d1ff46ab86ab897c50435c423f28be4895f.tar.bz2
build_soong-87b17d1ff46ab86ab897c50435c423f28be4895f.zip
Use SRCDIR as a working directory
The existing behavior of using the build directory as the working directory is useful if you want to move/copy the output directory around and SRCDIR still refers the the source. But, it's more useful to have the source directory be the working directory. Tools like cpp(__FILE__) and other debug prints embed relative paths from the working directory. We also have tools that expect the working directory to be $TOP. Change-Id: Ia0f1d3c6b7df72d61cf5628efa2baa98bd19775b
Diffstat (limited to 'common/config.go')
-rw-r--r--common/config.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/common/config.go b/common/config.go
index f8231f07..a7675b97 100644
--- a/common/config.go
+++ b/common/config.go
@@ -24,8 +24,8 @@ import (
)
// The configuration file name
-const ConfigFileName = "soong.config"
-const ProductVariablesFileName = "soong.variables"
+const configFileName = "soong.config"
+const productVariablesFileName = "soong.variables"
// A FileConfigurableOptions contains options which can be configured by the
// config file. These will be included in the config struct.
@@ -46,7 +46,11 @@ type config struct {
FileConfigurableOptions
ProductVariables productVariables
- srcDir string // the path of the root source directory
+ ConfigFileName string
+ ProductVariablesFileName string
+
+ srcDir string // the path of the root source directory
+ buildDir string // the path of the build output directory
envLock sync.Mutex
envDeps map[string]string
@@ -58,12 +62,12 @@ type jsonConfigurable interface {
}
func loadConfig(config *config) error {
- err := loadFromConfigFile(&config.FileConfigurableOptions, ConfigFileName)
+ err := loadFromConfigFile(&config.FileConfigurableOptions, config.ConfigFileName)
if err != nil {
return err
}
- return loadFromConfigFile(&config.ProductVariables, ProductVariablesFileName)
+ return loadFromConfigFile(&config.ProductVariables, config.ProductVariablesFileName)
}
// loads configuration options from a JSON file in the cwd.
@@ -120,12 +124,16 @@ func saveToConfigFile(config jsonConfigurable, filename string) error {
// New creates a new Config object. The srcDir argument specifies the path to
// the root source directory. It also loads the config file, if found.
-func NewConfig(srcDir string) (Config, error) {
+func NewConfig(srcDir, buildDir string) (Config, error) {
// Make a config with default options
config := Config{
config: &config{
- srcDir: srcDir,
- envDeps: make(map[string]string),
+ ConfigFileName: filepath.Join(buildDir, configFileName),
+ ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName),
+
+ srcDir: srcDir,
+ buildDir: buildDir,
+ envDeps: make(map[string]string),
},
}
@@ -142,8 +150,12 @@ func (c *config) SrcDir() string {
return c.srcDir
}
+func (c *config) BuildDir() string {
+ return c.buildDir
+}
+
func (c *config) IntermediatesDir() string {
- return ".intermediates"
+ return filepath.Join(c.BuildDir(), ".intermediates")
}
// PrebuiltOS returns the name of the host OS used in prebuilts directories
@@ -204,12 +216,12 @@ func (c *config) DeviceName() string {
// DeviceOut returns the path to out directory for device targets
func (c *config) DeviceOut() string {
- return filepath.Join("target/product", c.DeviceName())
+ return filepath.Join(c.BuildDir(), "target/product", c.DeviceName())
}
// HostOut returns the path to out directory for host targets
func (c *config) HostOut() string {
- return filepath.Join("host", c.PrebuiltOS())
+ return filepath.Join(c.BuildDir(), "host", c.PrebuiltOS())
}
// HostBin returns the path to bin directory for host targets