diff options
author | Colin Cross <ccross@android.com> | 2016-08-24 15:25:47 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-08-25 22:42:02 +0000 |
commit | 1e7d3706d67d6203be4db91362277548d6fc65b7 (patch) | |
tree | f8ae3756ac778f039d8a207da53c25c55b3c8304 | |
parent | 0f4e0d6c5d3688766747f353e1799c259d6c0d99 (diff) | |
download | build_soong-1e7d3706d67d6203be4db91362277548d6fc65b7.tar.gz build_soong-1e7d3706d67d6203be4db91362277548d6fc65b7.tar.bz2 build_soong-1e7d3706d67d6203be4db91362277548d6fc65b7.zip |
Add support for preferred arch symlinks
Add a symlink_preferred_arch property to binaries to allow compiling the
binary for multiple architectures and then creating a symlink to the
preferred archicture, for example dalvikvm32 and dalvikvm64, with
dalvikvm symlinked to dalvikvm64.
Test: mmma -j art/dalvikvm
Change-Id: Ied15f2be9d52c01006fe8ac207c175b78558eab1
-rw-r--r-- | android/config.go | 9 | ||||
-rw-r--r-- | android/module.go | 5 | ||||
-rw-r--r-- | android/variable.go | 3 | ||||
-rw-r--r-- | cc/androidmk.go | 1 | ||||
-rw-r--r-- | cc/binary.go | 25 |
5 files changed, 41 insertions, 2 deletions
diff --git a/android/config.go b/android/config.go index 6c524e1a..21a72339 100644 --- a/android/config.go +++ b/android/config.go @@ -75,6 +75,7 @@ type config struct { envFrozen bool inMake bool + OncePer } @@ -332,6 +333,14 @@ func (c *config) AllowMissingDependencies() bool { return Bool(c.ProductVariables.Allow_missing_dependencies) } +func (c *config) DevicePrefer32BitExecutables() bool { + return Bool(c.ProductVariables.DevicePrefer32BitExecutables) +} + +func (c *config) HostPrefer32BitExecutables() bool { + return Bool(c.ProductVariables.HostPrefer32BitExecutables) +} + func (c *config) SkipDeviceInstall() bool { return c.EmbeddedInMake() || Bool(c.Mega_device) } diff --git a/android/module.go b/android/module.go index fd37ca85..45afec14 100644 --- a/android/module.go +++ b/android/module.go @@ -63,6 +63,7 @@ type androidBaseContext interface { Device() bool Darwin() bool Debug() bool + PrimaryArch() bool AConfig() Config DeviceConfig() DeviceConfig } @@ -548,6 +549,10 @@ func (a *androidBaseContextImpl) Debug() bool { return a.debug } +func (a *androidBaseContextImpl) PrimaryArch() bool { + return a.target.Arch.ArchType == a.config.Targets[a.target.Os.Class][0].Arch.ArchType +} + func (a *androidBaseContextImpl) AConfig() Config { return a.config } diff --git a/android/variable.go b/android/variable.go index 531125d5..be2407d1 100644 --- a/android/variable.go +++ b/android/variable.go @@ -102,6 +102,9 @@ type productVariables struct { Schedboost *bool `json:",omitempty"` Binder32bit *bool `json:",omitempty"` + DevicePrefer32BitExecutables *bool `json:",omitempty"` + HostPrefer32BitExecutables *bool `json:",omitempty"` + SanitizeHost *[]string `json:",omitempty"` SanitizeDevice *[]string `json:",omitempty"` } diff --git a/cc/androidmk.go b/cc/androidmk.go index 283fe277..d4965d8d 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -125,6 +125,7 @@ func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.Android } func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { + ctx.subAndroidMk(ret, binary.baseInstaller) ctx.subAndroidMk(ret, &binary.stripper) ret.Class = "EXECUTABLES" diff --git a/cc/binary.go b/cc/binary.go index 2dbce66c..38fc938f 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -34,6 +34,9 @@ type BinaryLinkerProperties struct { // if set, add an extra objcopy --prefix-symbols= step Prefix_symbols string + + // if set, install a symlink to the preferred architecture + Symlink_preferred_arch bool } func init() { @@ -59,6 +62,7 @@ func binaryHostFactory() (blueprint.Module, []interface{}) { type binaryDecorator struct { *baseLinker + *baseInstaller stripper Properties BinaryLinkerProperties @@ -137,11 +141,12 @@ func (binary *binaryDecorator) isDependencyRoot() bool { func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { module := newModule(hod, android.MultilibFirst) binary := &binaryDecorator{ - baseLinker: NewBaseLinker(), + baseLinker: NewBaseLinker(), + baseInstaller: NewBaseInstaller("bin", "", InstallInSystem), } module.compiler = NewBaseCompiler() module.linker = binary - module.installer = NewBaseInstaller("bin", "", InstallInSystem) + module.installer = binary return module, binary } @@ -158,6 +163,22 @@ func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) { binary.Properties.Static_executable = nil } } + + if binary.Properties.Symlink_preferred_arch { + if binary.Properties.Stem == "" && binary.Properties.Suffix == "" { + ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix") + } + var prefer bool + if ctx.Host() { + prefer = ctx.AConfig().HostPrefer32BitExecutables() + } else { + prefer = ctx.AConfig().DevicePrefer32BitExecutables() + } + if ctx.PrimaryArch() != prefer { + binary.baseInstaller.Properties.Symlinks = append(binary.baseInstaller.Properties.Symlinks, + ctx.ModuleName()) + } + } } func (binary *binaryDecorator) static() bool { |