blob: 11d7614b7af5b8470d449b36d712fb101027977d [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// 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
15package cc
16
17import (
18 "io"
Dan Willemsen218f6562015-07-08 18:13:11 -070019 "strings"
20
21 "android/soong/common"
22)
23
24func (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 Willemsen34cc69e2015-09-23 15:26:20 -070031 ret.Extra = func(name, prefix string, outputFile common.Path, arch common.Arch) (ret []string) {
Dan Willemsen218f6562015-07-08 18:13:11 -070032 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 Willemsen34cc69e2015-09-23 15:26:20 -070040 ret = append(ret, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Willemsen218f6562015-07-08 18:13:11 -070041 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
56func (c *ccObject) AndroidMk() (ret common.AndroidMkData) {
57 ret.OutputFile = c.outputFile()
58 ret.Custom = func(w io.Writer, name, prefix string) {
Dan Willemsen34cc69e2015-09-23 15:26:20 -070059 out := c.outputFile().Path()
Dan Willemsen218f6562015-07-08 18:13:11 -070060
Dan Willemsen34cc69e2015-09-23 15:26:20 -070061 io.WriteString(w, "$("+prefix+"TARGET_OUT_INTERMEDIATE_LIBRARIES)/"+name+objectExtension+": "+out.String()+" | $(ACP)\n")
Dan Willemsen218f6562015-07-08 18:13:11 -070062 io.WriteString(w, "\t$(copy-file-to-target)\n")
63 }
64 return
65}
66
67func (c *CCBinary) AndroidMk() (ret common.AndroidMkData) {
68 ret.Class = "EXECUTABLES"
Dan Willemsen34cc69e2015-09-23 15:26:20 -070069 ret.Extra = func(name, prefix string, outputFile common.Path, arch common.Arch) []string {
Dan Willemsen218f6562015-07-08 18:13:11 -070070 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}