blob: 08cdbdcf13d66f37b8c220173a2b31b6aa574a16 [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 (
Dan Willemsen97750522016-02-09 17:43:51 -080018 "fmt"
Dan Willemsen218f6562015-07-08 18:13:11 -070019 "io"
Dan Willemsen218f6562015-07-08 18:13:11 -070020 "strings"
21
22 "android/soong/common"
23)
24
Dan Willemsen97750522016-02-09 17:43:51 -080025func (c *CCLibrary) AndroidMk() (ret common.AndroidMkData, err error) {
Dan Willemsen218f6562015-07-08 18:13:11 -070026 if c.static() {
27 ret.Class = "STATIC_LIBRARIES"
28 } else {
29 ret.Class = "SHARED_LIBRARIES"
30 }
31 ret.OutputFile = c.outputFile()
Dan Willemsen97750522016-02-09 17:43:51 -080032 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 Willemsen218f6562015-07-08 18:13:11 -070038 }
39 if len(exportedIncludes) > 0 {
Dan Willemsen97750522016-02-09 17:43:51 -080040 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " "))
Dan Willemsen218f6562015-07-08 18:13:11 -070041 }
42
Dan Willemsen97750522016-02-09 17:43:51 -080043 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 Willemsen218f6562015-07-08 18:13:11 -070047
48 if c.Properties.Relative_install_path != "" {
Dan Willemsen97750522016-02-09 17:43:51 -080049 fmt.Fprintln(w, "LOCAL_MODULE_RELATIVE_PATH :=", c.Properties.Relative_install_path)
Dan Willemsen218f6562015-07-08 18:13:11 -070050 }
51
52 // These are already included in LOCAL_SHARED_LIBRARIES
Dan Willemsen97750522016-02-09 17:43:51 -080053 fmt.Fprintln(w, "LOCAL_CXX_STL := none")
54 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsen218f6562015-07-08 18:13:11 -070055
Dan Willemsen97750522016-02-09 17:43:51 -080056 return nil
Dan Willemsen218f6562015-07-08 18:13:11 -070057 }
58 return
59}
60
Dan Willemsen97750522016-02-09 17:43:51 -080061func (c *ccObject) AndroidMk() (ret common.AndroidMkData, err error) {
Dan Willemsen218f6562015-07-08 18:13:11 -070062 ret.OutputFile = c.outputFile()
Dan Willemsen97750522016-02-09 17:43:51 -080063 ret.Custom = func(w io.Writer, name, prefix string) error {
Dan Willemsen34cc69e2015-09-23 15:26:20 -070064 out := c.outputFile().Path()
Dan Willemsen218f6562015-07-08 18:13:11 -070065
Dan Willemsen97750522016-02-09 17:43:51 -080066 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 Willemsen218f6562015-07-08 18:13:11 -070070 }
71 return
72}
73
Dan Willemsen97750522016-02-09 17:43:51 -080074func (c *CCBinary) AndroidMk() (ret common.AndroidMkData, err error) {
Dan Willemsen218f6562015-07-08 18:13:11 -070075 ret.Class = "EXECUTABLES"
Dan Willemsen97750522016-02-09 17:43:51 -080076 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 Willemsen218f6562015-07-08 18:13:11 -070080 if c.Properties.Relative_install_path != "" {
Dan Willemsen97750522016-02-09 17:43:51 -080081 fmt.Fprintln(w, "LOCAL_MODULE_RELATIVE_PATH :=", c.Properties.Relative_install_path)
Dan Willemsen218f6562015-07-08 18:13:11 -070082 }
Dan Willemsen97750522016-02-09 17:43:51 -080083
84 return nil
Dan Willemsen218f6562015-07-08 18:13:11 -070085 }
86 ret.OutputFile = c.outputFile()
87 return
88}