Skip to content

Commit 0c3df9b

Browse files
authored
Merge pull request #50 from fosslight/build
Find build output path from new format build log
2 parents f4abe2b + bb1d8c4 commit 0c3df9b

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/fosslight_android/android_binary_analysis.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,30 +211,29 @@ def set_env_variables_from_result_log():
211211
pass
212212

213213
# FIND a NOTICE file and build out path
214+
pattern_notice = r'\[.*?\]\s*build\s+(([^\s]*?)/obj/NOTICE\.(?:xml(?:\.gz)?|html|txt))'
214215
for line in reversed(android_log_lines):
215-
line = line.strip()
216-
if line.endswith("obj/NOTICE.xml") or line.endswith("obj/NOTICE.html") or line.endswith("obj/NOTICE.txt"):
217-
words = line.split()
218-
build_out_notice_file_path = words[-1]
219-
find_idx = build_out_notice_file_path.find("obj/")
220-
build_out_path = build_out_notice_file_path[:find_idx]
216+
match = re.search(pattern_notice, line)
217+
if match:
218+
build_out_notice_file_path = match.group(1)
219+
build_out_path = match.group(2)
221220
break
222221

223-
if build_out_path == "":
222+
if not build_out_path:
223+
pattern = re.compile(r'.*Installed file list:\s*([^\s]+)')
224224
for line in reversed(android_log_lines):
225225
try:
226-
pattern = re.compile(r'.*Installed file list\s*(.*):\s*(.*)')
227226
matched = pattern.match(line)
228227
if matched is not None:
229-
build_out_path = os.path.dirname(matched.group(2))
228+
build_out_path = os.path.dirname(matched.group(1))
230229
break
231230
except Exception:
232231
pass
233-
if build_out_path == "":
232+
if not build_out_path:
234233
logger.error("Can't find a build output path.")
235234
sys.exit(1)
236235

237-
if build_out_notice_file_path == "":
236+
if not build_out_notice_file_path:
238237
build_out_notice_file_path = os.path.join(build_out_path, "obj")
239238

240239
read_module_info_from_build_output_file()

src/fosslight_android/check_notice_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def read_notice_file(notice_file_path):
104104

105105
if os.path.isfile(notice_file_path):
106106
notice_files.append(notice_file_path)
107-
if notice_file_path.endswith(".html") or notice_file_path.endswith(".xml") or notice_file_path.endswith(".txt"):
108-
notice_file_path = os.path.dirname(notice_file_path)
107+
if notice_file_path.endswith((".xml", ".html", ".txt", "xml.gz")):
108+
notice_file_path = os.path.dirname(notice_file_path)
109109

110110
if os.path.isdir(notice_file_path):
111111
additional_notice_files = find_files_by_extension(notice_file_path)

0 commit comments

Comments
 (0)