diff options
Diffstat (limited to 'apex/androidmk.go')
| -rw-r--r-- | apex/androidmk.go | 37 | 
1 files changed, 32 insertions, 5 deletions
diff --git a/apex/androidmk.go b/apex/androidmk.go index ad7d2f142..f1194be71 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -52,13 +52,40 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)  		return moduleNames  	} +	var postInstallCommands []string +	for _, fi := range a.filesInfo { +		if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() { +			// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here +			linkTarget := filepath.Join("/system", fi.Path()) +			linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexName, fi.Path()) +			mkdirCmd := "mkdir -p " + filepath.Dir(linkPath) +			linkCmd := "ln -sfn " + linkTarget + " " + linkPath +			postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd) +		} +	} +	postInstallCommands = append(postInstallCommands, a.compatSymlinks...) +  	for _, fi := range a.filesInfo {  		if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake {  			continue  		} -		if !android.InList(fi.moduleName, moduleNames) { -			moduleNames = append(moduleNames, fi.moduleName) +		linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() + +		var moduleName string +		if linkToSystemLib { +			moduleName = fi.moduleName +		} else { +			moduleName = fi.moduleName + "." + apexName + a.suffix +		} + +		if !android.InList(moduleName, moduleNames) { +			moduleNames = append(moduleNames, moduleName) +		} + +		if linkToSystemLib { +			// No need to copy the file since it's linked to the system file +			continue  		}  		fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") @@ -67,7 +94,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)  		} else {  			fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)  		} -		fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName) +		fmt.Fprintln(w, "LOCAL_MODULE :=", moduleName)  		// /apex/<apex_name>/{lib|framework|...}  		pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)  		if apexType == flattenedApex { @@ -160,9 +187,9 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)  				}  				fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " ")) -				if len(a.compatSymlinks) > 0 { +				if apexType == flattenedApex && len(postInstallCommands) > 0 {  					// For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex -					fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(a.compatSymlinks, " && ")) +					fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))  				}  			}  			fmt.Fprintln(w, "include $(BUILD_PREBUILT)")  |