Try to find host tools in the same directory as the caller
common.py is used by many python-based host tools. When a host tool invokes another host tool, it's usually done with the name of the tool, not the absolute path of the tool. For example, ["cmd", "arg"] instead of ["out/soong/host/linux-x86/bin/cmd", "arg"]. Previously, the caller of the tool has to teach all the locations of the sub-tools that the tool will internally use. But this isn't ideal; 1) It's against the abstraction. The existence of the sub tools and their names are implementation detail of the containing tool. It's also subject to change. 2) This isn't scalable. Sometimes a host tool invokes a large number of host tools. Furthermore, the sub tools might invoke other sub-sub tools. Then the location of the sub-sub-tools had to be known to the top-level tool. The idea here is to make use of the fact that a) dependencies to the sub (and sub-sub) tools are already described in the Android.bp and b) the dependencies are guaranteed to be up-to-date and installed to the host tool directory (out/soong/host/linux-x86/bin) by Soong. Then by the time a host tool is invoked, all of its sub tools should be found in the host tool directory. So, when "cmd" is about to be invoked, common.py first tries to find it from the user-given paths. If not found there, it falls back to search the directory where the current tool is located at. Then finally falls back to the original name "cmd" and expects it to be found under PATH. Bug: 172414391 Test: m Change-Id: Id7b44f9021be3bbf0631ddafe382ea3990f7ea74
Loading
Please register or sign in to comment