Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame^] | 1 | // Copyright 2015 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "io" |
| 19 | "path/filepath" |
| 20 | "strings" |
| 21 | |
| 22 | "android/soong/common" |
| 23 | ) |
| 24 | |
| 25 | func (c *CCLibrary) AndroidMk() (ret common.AndroidMkData) { |
| 26 | if c.static() { |
| 27 | ret.Class = "STATIC_LIBRARIES" |
| 28 | } else { |
| 29 | ret.Class = "SHARED_LIBRARIES" |
| 30 | } |
| 31 | ret.OutputFile = c.outputFile() |
| 32 | ret.Extra = func(name, prefix, outputFile string, arch common.Arch) (ret []string) { |
| 33 | exportedIncludes := c.exportedFlags() |
| 34 | for i := range exportedIncludes { |
| 35 | exportedIncludes[i] = strings.TrimPrefix(exportedIncludes[i], "-I") |
| 36 | } |
| 37 | if len(exportedIncludes) > 0 { |
| 38 | ret = append(ret, "LOCAL_EXPORT_C_INCLUDE_DIRS := "+strings.Join(exportedIncludes, " ")) |
| 39 | } |
| 40 | |
| 41 | ret = append(ret, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(outputFile)) |
| 42 | ret = append(ret, "LOCAL_SHARED_LIBRARIES_"+arch.ArchType.String()+" := "+strings.Join(c.savedDepNames.SharedLibs, " ")) |
| 43 | |
| 44 | if c.Properties.Relative_install_path != "" { |
| 45 | ret = append(ret, "LOCAL_MODULE_RELATIVE_PATH := "+c.Properties.Relative_install_path) |
| 46 | } |
| 47 | |
| 48 | // These are already included in LOCAL_SHARED_LIBRARIES |
| 49 | ret = append(ret, "LOCAL_CXX_STL := none") |
| 50 | ret = append(ret, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 51 | |
| 52 | return |
| 53 | } |
| 54 | return |
| 55 | } |
| 56 | |
| 57 | func (c *ccObject) AndroidMk() (ret common.AndroidMkData) { |
| 58 | ret.OutputFile = c.outputFile() |
| 59 | ret.Custom = func(w io.Writer, name, prefix string) { |
| 60 | out := c.outputFile() |
| 61 | |
| 62 | io.WriteString(w, "$("+prefix+"TARGET_OUT_INTERMEDIATE_LIBRARIES)/"+name+objectExtension+": "+out+" | $(ACP)\n") |
| 63 | io.WriteString(w, "\t$(copy-file-to-target)\n") |
| 64 | } |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | func (c *CCBinary) AndroidMk() (ret common.AndroidMkData) { |
| 69 | ret.Class = "EXECUTABLES" |
| 70 | ret.Extra = func(name, prefix, outputFile string, arch common.Arch) []string { |
| 71 | ret := []string{ |
| 72 | "LOCAL_CXX_STL := none", |
| 73 | "LOCAL_SYSTEM_SHARED_LIBRARIES :=", |
| 74 | "LOCAL_SHARED_LIBRARIES_" + arch.ArchType.String() + " += " + strings.Join(c.savedDepNames.SharedLibs, " "), |
| 75 | } |
| 76 | if c.Properties.Relative_install_path != "" { |
| 77 | ret = append(ret, "LOCAL_MODULE_RELATIVE_PATH_"+arch.ArchType.String()+" := "+c.Properties.Relative_install_path) |
| 78 | } |
| 79 | return ret |
| 80 | } |
| 81 | ret.OutputFile = c.outputFile() |
| 82 | return |
| 83 | } |