Skip to content

Commit

Permalink
Merge pull request #4315 from ayeung/timob-13944
Browse files Browse the repository at this point in the history
TIMOB-13944: Also search inside build-tools directory for platform tools
  • Loading branch information
matt-langston committed May 22, 2013
2 parents 9ab7295 + 3910abf commit b10f0da
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion support/android/androidsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def get_sdk_platform_tools_dir(self):
return sdk_platform_tools
return None

def get_build_tools_dir(self):
if self.android_sdk is not None:
build_tools = os.path.join(self.android_sdk, 'build-tools')
if os.path.exists(build_tools):
return build_tools
return None

def get_api_level(self):
return self.api_level

Expand All @@ -195,13 +202,23 @@ def get_sdk_tool(self, tool):
def get_platform_tool(self, tool):
platform_tools_dir = self.get_platform_tools_dir()
sdk_platform_tools_dir = self.get_sdk_platform_tools_dir()
build_tools_dir = self.get_build_tools_dir()
tool_path = None
if platform_tools_dir is not None:
tool_path = self.get_tool(platform_tools_dir, tool)
if tool_path is None and sdk_platform_tools_dir is not None:
tool_path = self.get_tool(sdk_platform_tools_dir, tool)
if tool_path is None or not os.path.exists(tool_path):
return self.get_sdk_tool(tool)
tool_path = self.get_sdk_tool(tool)
if tool_path is None and build_tools_dir is not None:
# Many tools were moved to build-tools/17.0.0 in sdk tools r22

# Here, we list all the directories in build-tools and check inside
# each one for the tool we are looking for (there can be future versions besides 17.0.0).
for dirname in os.listdir(build_tools_dir):
if os.path.exists(os.path.join(build_tools_dir, dirname, tool)):
return os.path.join(build_tools_dir, dirname, tool)

return tool_path

def get_dx(self):
Expand Down

0 comments on commit b10f0da

Please sign in to comment.