Re: [android-building] How to add relative path for srcs:[] in Android.bp

2,240 views
Skip to first unread message

Dan Willemsen

unread,
Oct 17, 2019, 12:49:29 PM10/17/19
to Android Building
We don't allow references outside of the current directory and its subdirectories in Soong. We require the directory with the sources to opt-into being used by others, either by directly defining the modules, or by defining filegroup modules that can be used in the src[s] fields via ":myfilegroup" (colon-prefixed module name). This way we can actually let you control who uses files within your directory (via visibility), and tools like `mma` and `atest` are more likely to be able to handle "build/test everything in this directory" properly.

So in this case, either move the Android.bp up to the parent path (which usually makes sense for parents, or for apps that have "src" / "jni" / "res" dirs, as we do automatically look for files in the same directory for some things), or define a filegroup in the parent and use it below (this can be more useful if the same file is used by multiple children, though it may make more sense to use a static library or something more specific).

That error is that you have multiple definitions of the same module, and is unlikely to be related to just moving an Android.bp upwards (unless it was below a `soong_namespace {}` definition, but that means you weren't using that Android.bp in the first place).

- Dan


On Tue, Oct 15, 2019 at 8:27 AM ____ <akhire...@gmail.com> wrote:
hello,
say in a Android.bp file srcs:["../../../a.cpp"]
I am getting the error Path is outside directory "../../../a.cpp"? How to overcome this?

Later I tried declaring Android.bp in to a parent folder so that srcs:["a.cpp"] but then ,
FAILED:
build/make/core/base_rules.mk:325: error: /gps-noship/cacert_location: MODULE.TARGET.ETC.cacert_location.pem already defined by /prebuilt_HY11.
02:01:45 ckati failed with: exit status 1

#### failed to build some targets (02:16 (mm:ss)) ####

How to overcome these?
Thanks in advance

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/75ea2ea6-f85b-4577-a98c-1fd42f867150%40googlegroups.com.
Message has been deleted

Dan Willemsen

unread,
Oct 17, 2019, 6:52:22 PM10/17/19
to Android Building
Here's an example of using a filegroup for this -- cts/hostsidetests/media/common/**/*.java is used by two modules under cts/hostsidetests/media/app/...

So we've got the filegroup that defines all the files in the common directory:
filegroup {
    name: "CtsMediaSessionTestCommon",
    srcs: ["common/**/*.java"],
}


And then used in the srcs list with ":CtsMediaSessionTestCommon":
android_test_helper_app {
    name: "CtsMediaSessionHostTestApp",
    defaults: ["cts_defaults"],
    test_suites: [
        "cts",
        "vts",
        "general-tests",
    ],
    srcs: [
        "src/**/*.java",
        ":CtsMediaSessionTestCommon",
    ],
    static_libs: [
        "androidx.test.rules",
        "compatibility-device-util-axt",
    ],
    sdk_version: "test_current",
    min_sdk_version: "26",
}


In this case, it may have been possible to instead refactor the common file into a library that would be used instead (and then only compiling the files once instead of 2 times), but both would function.

- Dan

On Thu, Oct 17, 2019 at 3:08 PM REGURI AKANKSHA <akhire...@gmail.com> wrote:
Thanks,Dan I was able to tackle the above error. I am new to these things. Can u explain this  filegroup with an example, like by defining some module, that would be really helpful 
Thanks in advance

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.

Akanksha

unread,
Oct 18, 2019, 11:46:57 AM10/18/19
to Android Building
This works well, Thanks

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages