Beispiel #1
0
def run_task_build_pdfium():
    f.debug("Building PDFium...")

    target = "android"
    build_dir = os.path.join("build", target)
    f.create_dir(build_dir)

    target_dir = os.path.join(build_dir, "pdfium")
    f.remove_dir(target_dir)

    cwd = build_dir
    command = " ".join(
        [
            "gclient",
            "config",
            "--unmanaged",
            "https://pdfium.googlesource.com/pdfium.git",
        ]
    )
    check_call(command, cwd=cwd, shell=True)

    gclient_file = os.path.join(build_dir, ".gclient")
    f.append_to_file(gclient_file, "target_os = [ 'android' ]")

    cwd = build_dir
    command = " ".join(["gclient", "sync"])
    check_call(command, cwd=cwd, shell=True)

    cwd = target_dir
    command = " ".join(["git", "checkout", c.pdfium_git_commit])
    check_call(command, cwd=cwd, shell=True)
Beispiel #2
0
def run_task_patch():
    f.debug("Patching...")

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

    # build gn
    source_file = os.path.join(
        source_dir,
        "BUILD.gn",
    )
    if not f.file_line_has_content(source_file, 235,
                                   '#test("pdfium_unittests") {\n'):
        f.file_line_comment_range(source_file, 235, 282)
        f.file_line_comment_range(source_file, 375, 376)

        f.debug("Applied: Build GN")
    else:
        f.debug("Skipped: Build GN")

    # libjpeg
    source_file = os.path.join(
        source_dir,
        "third_party",
        "libjpeg_turbo",
        "BUILD.gn",
    )
    if not f.file_line_has_content(
            source_file,
            13,
            '#assert(!is_ios, "This is not used on iOS, don\'t drag it in unintentionally")\n',
    ):
        f.file_line_comment(source_file, 13)

        f.debug("Applied: Lib JPEG")
    else:
        f.debug("Skipped: Lib JPEG")

    # ios automatically manage certs
    source_file = os.path.join(
        source_dir,
        "build",
        "config",
        "ios",
        "ios_sdk_overrides.gni",
    )
    if not f.file_has_content(source_file, "ios_automatically_manage_certs"):
        f.append_to_file(
            source_file,
            "if (is_ios) { ios_automatically_manage_certs = true }")

        f.debug("Applied: iOS Automatically Manage Certs")
    else:
        f.debug("Skipped: iOS Automatically Manage Certs")

    # compiler
    source_file = os.path.join(
        source_dir,
        "build",
        "config",
        "compiler",
        "BUILD.gn",
    )
    if not f.file_line_has_content(source_file, 1630,
                                   '#      "-Wimplicit-fallthrough",\n'):
        f.file_line_comment(source_file, 1630)

        f.debug("Applied: Compiler")
    else:
        f.debug("Skipped: Compiler")

    # carbon
    source_file = os.path.join(
        source_dir,
        "core",
        "fxge",
        "apple",
        "fx_quartz_device.h",
    )
    if not f.file_line_has_content(source_file, 10,
                                   "#include <CoreGraphics/CoreGraphics.h>\n"):
        f.replace_line_in_file(
            source_file,
            10,
            "#include <CoreGraphics/CoreGraphics.h>\n#include <CoreFoundation/CFString.h>\n",
        )

        f.debug("Applied: Carbon")
    else:
        f.debug("Skipped: Carbon")

    # ios simulator
    source_file = os.path.join(
        source_dir,
        "build",
        "config",
        "ios",
        "rules.gni",
    )
    if not f.file_line_has_content(
            source_file, 930,
            '#          data_deps += [ "//testing/iossim" ]\n'):
        f.file_line_comment(source_file, 930)

        f.debug("Applied: iOS Simulator")
    else:
        f.debug("Skipped: iOS Simulator")

    # 32bits constexpr
    source_file = os.path.join(
        source_dir,
        "third_party",
        "base",
        "allocator",
        "partition_allocator",
        "address_space_randomization.h",
    )
    if f.file_line_has_content(
            source_file, 248,
            "  constexpr ALWAYS_INLINE uintptr_t ASLRMask() {\n"):
        f.replace_line_in_file(
            source_file,
            248,
            "  PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t ASLRMask() {\n",
        )
        f.replace_line_in_file(
            source_file,
            251,
            "  PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t ASLROffset() {\n",
        )

        f.debug("Applied: 32bits constexpr")
    else:
        f.debug("Skipped: 32bits constexpr")

    # ARM Neon
    source_file = os.path.join(
        source_dir,
        "build_overrides",
        "build.gni",
    )
    if f.file_line_has_content(source_file, 18,
                               'if (current_cpu == "arm") {\n'):
        f.replace_line_in_file(source_file, 18,
                               'if (current_cpu == "arm64") {\n')

        f.debug("Applied: ARM Neon")
    else:
        f.debug("Skipped: ARM Neon")

    # core fxge
    source_file = os.path.join(source_dir, "core", "fxge", "BUILD.gn")
    if f.file_line_has_content(source_file, 167, "  if (is_mac) {\n"):
        f.replace_line_in_file(source_file, 167, "  if (is_mac || is_ios) {\n")

        f.debug("Applied: Core FXGE")
    else:
        f.debug("Skipped: Core FXGE")