Skip to content

Commit

Permalink
fix android patch
Browse files Browse the repository at this point in the history
  • Loading branch information
paulocoutinhox committed Dec 15, 2023
1 parent 09eef4e commit a867043
Showing 1 changed file with 10 additions and 50 deletions.
60 changes: 10 additions & 50 deletions modules/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,23 @@ def run_task_patch():

source_dir = os.path.join("build", "android", "pdfium")

# build gn
# build config
source_file = os.path.join(
source_dir,
"BUILD.gn",
"build",
"config",
"BUILDCONFIG.gn",
)

original_content = 'include_dirs = [ "." ]\n defines = []'
has_patch = f.file_has_content(source_file, original_content)
original_content = 'set_defaults("shared_library") {\n configs = default_shared_library_configs\n}'
has_content = f.file_has_content(source_file, original_content)

if has_patch:
new_content = 'include_dirs = [ "." ]\n defines = ["FPDFSDK_EXPORTS"]'
if has_content:
new_content = 'set_defaults("shared_library") {\n configs = default_shared_library_configs\n\n if (is_android) {\n configs -= [ "//build/config/android:hide_all_but_jni_onload" ]\n }\n}'
f.replace_in_file(source_file, original_content, new_content)
l.bullet("Applied: build gn", l.GREEN)
l.bullet("Applied: build config", l.GREEN)
else:
l.bullet("Skipped: build gn", l.PURPLE)

# build gn flags
source_file = os.path.join(
source_dir,
"BUILD.gn",
)

line_content = "cflags = []"
line_number = f.get_file_line_number_with_content(
source_file, line_content, strip=True
)

if line_number:
content = ' cflags = [ "-fvisibility=default" ]'

# cflags #1
f.set_file_line_content(source_file, line_number, content, new_line=True)

# cflags #2
line_number = f.get_file_line_number_with_content(
source_file, line_content, strip=True
)

f.set_file_line_content(source_file, line_number, content, new_line=True)

# cflags #3
line_number = f.get_file_line_number_with_content(
source_file, line_content, strip=True
)

f.set_file_line_content(source_file, line_number, content, new_line=True)

# cflags #4
line_number = f.get_file_line_number_with_content(
source_file, line_content, strip=True
)

f.set_file_line_content(source_file, line_number, content, new_line=True)

l.bullet("Applied: build gn flags", l.GREEN)
else:
l.bullet("Skipped: build gn flags", l.PURPLE)
l.bullet("Skipped: build config", l.PURPLE)

l.ok()

Expand Down

0 comments on commit a867043

Please sign in to comment.