6

I m using androidmk tool to convert Android.mk files to Android.bp at many places we have Android.mk chanining so it produces relative path for srcs:[], but its not working with Android.bp build. Throwing error : Path is outside directory: ../../XX.cpp

srcs:[ "example1.cpp" "../../example2.cpp" --- error for this file ]

Path is outside directory:"../../example2.cpp"

Shabaz Khan
  • 71
  • 1
  • 5

2 Answers2

2

This is not allowed in Soong. You have to move your Android.bp to a common parent folder so that it looks like this.

srcs: ["a/b/example1.cpp", "example2.cpp"]
Simpl
  • 1,938
  • 1
  • 10
  • 21
  • Is there any other workaround ... since i have a lot of Android.mk files chained ?? It will take some efforts for me to realign allow the Android.mk files ?? – Shabaz Khan Jul 23 '19 at 13:43
  • You could try creating symlinks of your sources in the `Android.bp` folder or a subfolder of it if you don't mind willingly bypass `Soong` checks: https://android.googlesource.com/platform/build/soong/+/refs/heads/pie-release/android/paths_test.go#61 – Simpl Jul 23 '19 at 13:50
2

We don't allow references outside of the current directory and its subdirectories in Soong

There are two ways to overcome to resolve the above issue.

  • defining filegroup modules that can be used in the src[s] fields via ":myfilegroup".

Define the below code in parent or root dir:

    filegroup {
    name: "commaonfile",
    srcs: ["common/**/*.cpp"],
}

And use the filegroup in inner dirs where wants to use like below code:

cc_binary {
name: "abc"
srcs: [
       "src/a/b/abc.cpp"
       ":commaonfile"
      ],
}
  • shift all the Android.bp to parent dir and make it work.