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: cts/hostsidetests/media/Android.bp <https://android.googlesource.com/platform/cts/+/5e4cf896152ad4ef4218f180800dc864ba16e84c/hostsidetests/media/Android.bp#38> filegroup { name: "CtsMediaSessionTestCommon", srcs: ["common/**/*.java"], } And then used in the srcs list with ":CtsMediaSessionTestCommon": cts/hostsidetests/media/app/MediaSessionTest/Android.bp <https://android.googlesource.com/platform/cts/+/5e4cf896152ad4ef4218f180800dc864ba16e84c/hostsidetests/media/app/MediaSessionTest/Android.bp> 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 <[email protected]> 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 > > On Thu, Oct 17, 2019 at 10:19 PM 'Dan Willemsen' via Android Building < > [email protected]> wrote: > >> 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 ____ <[email protected]> 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 [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/android-building/75ea2ea6-f85b-4577-a98c-1fd42f867150%40googlegroups.com >>> <https://groups.google.com/d/msgid/android-building/75ea2ea6-f85b-4577-a98c-1fd42f867150%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> -- >> You received this message because you are subscribed to the "Android >> Building" mailing list. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/android-building/CALQgHd%3DXqqOGRCSHorr1UFV%3Dok%3DLHqEGmRrru9vGP%2BswDiZTxw%40mail.gmail.com >> <https://groups.google.com/d/msgid/android-building/CALQgHd%3DXqqOGRCSHorr1UFV%3Dok%3DLHqEGmRrru9vGP%2BswDiZTxw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > -- > You received this message because you are subscribed to the "Android > Building" mailing list. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/android-building/CA%2BVoWj7h3XMDiJY5ukqeMJnt7PPxAfLtrExG0BnLPY_%3DGp9Uyw%40mail.gmail.com > <https://groups.google.com/d/msgid/android-building/CA%2BVoWj7h3XMDiJY5ukqeMJnt7PPxAfLtrExG0BnLPY_%3DGp9Uyw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- -- You received this message because you are subscribed to the "Android Building" mailing list. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/CALQgHdkx5qE6whPr1OqTnmGnVdSefct8pSxUangoWwzun593Cw%40mail.gmail.com.
