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