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" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 19 | "strings" |
| 20 | |
| 21 | "android/soong/common" |
| 22 | ) |
| 23 | |
| 24 | func (c *CCLibrary) AndroidMk() (ret common.AndroidMkData) { |
| 25 | if c.static() { |
| 26 | ret.Class = "STATIC_LIBRARIES" |
| 27 | } else { |
| 28 | ret.Class = "SHARED_LIBRARIES" |
| 29 | } |
| 30 | ret.OutputFile = c.outputFile() |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame^] | 31 | ret.Extra = func(name, prefix string, outputFile common.Path, arch common.Arch) (ret []string) { |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 32 | exportedIncludes := c.exportedFlags() |
| 33 | for i := range exportedIncludes { |
| 34 | exportedIncludes[i] = strings.TrimPrefix(exportedIncludes[i], "-I") |
| 35 | } |
| 36 | if len(exportedIncludes) > 0 { |
| 37 | ret = append(ret, "LOCAL_EXPORT_C_INCLUDE_DIRS := "+strings.Join(exportedIncludes, " ")) |
| 38 | } |
| 39 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame^] | 40 | ret = append(ret, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 41 | ret = append(ret, "LOCAL_SHARED_LIBRARIES_"+arch.ArchType.String()+" := "+strings.Join(c.savedDepNames.SharedLibs, " ")) |
| 42 | |
| 43 | if c.Properties.Relative_install_path != "" { |
| 44 | ret = append(ret, "LOCAL_MODULE_RELATIVE_PATH := "+c.Properties.Relative_install_path) |
| 45 | } |
| 46 | |
| 47 | // These are already included in LOCAL_SHARED_LIBRARIES |
| 48 | ret = append(ret, "LOCAL_CXX_STL := none") |
| 49 | ret = append(ret, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 50 | |
| 51 | return |
| 52 | } |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | func (c *ccObject) AndroidMk() (ret common.AndroidMkData) { |
| 57 | ret.OutputFile = c.outputFile() |
| 58 | ret.Custom = func(w io.Writer, name, prefix string) { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame^] | 59 | out := c.outputFile().Path() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 60 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame^] | 61 | io.WriteString(w, "$("+prefix+"TARGET_OUT_INTERMEDIATE_LIBRARIES)/"+name+objectExtension+": "+out.String()+" | $(ACP)\n") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 62 | io.WriteString(w, "\t$(copy-file-to-target)\n") |
| 63 | } |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | func (c *CCBinary) AndroidMk() (ret common.AndroidMkData) { |
| 68 | ret.Class = "EXECUTABLES" |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame^] | 69 | ret.Extra = func(name, prefix string, outputFile common.Path, arch common.Arch) []string { |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 70 | ret := []string{ |
| 71 | "LOCAL_CXX_STL := none", |
| 72 | "LOCAL_SYSTEM_SHARED_LIBRARIES :=", |
| 73 | "LOCAL_SHARED_LIBRARIES_" + arch.ArchType.String() + " += " + strings.Join(c.savedDepNames.SharedLibs, " "), |
| 74 | } |
| 75 | if c.Properties.Relative_install_path != "" { |
| 76 | ret = append(ret, "LOCAL_MODULE_RELATIVE_PATH_"+arch.ArchType.String()+" := "+c.Properties.Relative_install_path) |
| 77 | } |
| 78 | return ret |
| 79 | } |
| 80 | ret.OutputFile = c.outputFile() |
| 81 | return |
| 82 | } |