---
source: src/patch/parse.rs
expression: patches
input_file: src/patch/test-data/0001-cross-findllvm.patch
---
Ok(
    [
        Patch {
            original: Some(
                Filename(
                    "cmake/Findllvm.cmake",
                ),
            ),
            modified: Some(
                Filename(
                    "cmake/Findllvm.cmake",
                ),
            ),
            hunks: [
                Hunk {
                    old_range: HunkRange {
                        start: 35,
                        len: 6,
                    },
                    new_range: HunkRange {
                        start: 35,
                        len: 6,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "\n",
                        ),
                        Context(
                            "    # Check that this LLVM is the right version\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "      COMMAND ${LLVM_CONFIG_EXE} --version\n",
                        ),
                        Insert(
                            "      COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --version\n",
                        ),
                        Context(
                            "      OUTPUT_VARIABLE LLVM_CONFIG_VERSION\n",
                        ),
                        Context(
                            "      OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 58,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 58,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "      endif()\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "      execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --libs ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --libs ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Context(
                            "        OUTPUT_QUIET\n",
                        ),
                        Context(
                            "        ERROR_VARIABLE LLVM_CONFIG_ERROR\n",
                        ),
                        Context(
                            "        ERROR_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 78,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 78,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "    endif()\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "      COMMAND ${LLVM_CONFIG_EXE} --targets-built\n",
                        ),
                        Insert(
                            "      COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --targets-built\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES\n",
                        ),
                        Context(
                            "      OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_TARGETS_BUILT \"${LLVM_TARGETS_BUILT_SPACES}\")\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 108,
                        len: 48,
                    },
                    new_range: HunkRange {
                        start: 108,
                        len: 48,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "\n",
                        ),
                        Context(
                            "  if(ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --libfiles ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --libfiles ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_LIBRARIES \"${LLVM_LIBRARIES_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --libdir ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --libdir ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_LIBDIRS \"${LLVM_LIBDIRS_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --system-libs ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --system-libs ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_SYSTEM_LIBS \"${LLVM_SYSTEM_LIBS_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "      COMMAND ${LLVM_CONFIG_EXE} --shared-mode ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Insert(
                            "      COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --shared-mode ${STATIC_OR_SHARED_LINK}\n",
                        ),
                        Context(
                            "      OUTPUT_VARIABLE LLVM_LINK_MODE\n",
                        ),
                        Context(
                            "      OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "  else()\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --libs\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --libs\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_LIBRARIES \"${LLVM_LIBRARIES_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --libdir\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --libdir\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_LIBDIRS \"${LLVM_LIBDIRS_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --system-libs\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --system-libs\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "    string(REPLACE \" \" \";\" LLVM_SYSTEM_LIBS \"${LLVM_SYSTEM_LIBS_SPACES}\")\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "      COMMAND ${LLVM_CONFIG_EXE} --shared-mode\n",
                        ),
                        Insert(
                            "      COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --shared-mode\n",
                        ),
                        Context(
                            "      OUTPUT_VARIABLE LLVM_LINK_MODE\n",
                        ),
                        Context(
                            "      OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "  endif()\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 159,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 159,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "    # since on some distros LLD is only available as a static library\n",
                        ),
                        Context(
                            "    # and we need these libraries to link it successfully\n",
                        ),
                        Context(
                            "    execute_process(\n",
                        ),
                        Delete(
                            "        COMMAND ${LLVM_CONFIG_EXE} --system-libs --link-static\n",
                        ),
                        Insert(
                            "        COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --system-libs --link-static\n",
                        ),
                        Context(
                            "        OUTPUT_VARIABLE LLVM_STATIC_SYSTEM_LIBS_SPACES\n",
                        ),
                        Context(
                            "        ERROR_QUIET # Some installations have no static libs, we just ignore the failure\n",
                        ),
                        Context(
                            "        OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                    ],
                },
                Hunk {
                    old_range: HunkRange {
                        start: 171,
                        len: 7,
                    },
                    new_range: HunkRange {
                        start: 171,
                        len: 7,
                    },
                    function_context: None,
                    lines: [
                        Context(
                            "  endif()\n",
                        ),
                        Context(
                            "\n",
                        ),
                        Context(
                            "  execute_process(\n",
                        ),
                        Delete(
                            "      COMMAND ${LLVM_CONFIG_EXE} --includedir\n",
                        ),
                        Insert(
                            "      COMMAND $ENV{CROSSCOMPILING_EMULATOR} ${LLVM_CONFIG_EXE} --includedir\n",
                        ),
                        Context(
                            "      OUTPUT_VARIABLE LLVM_INCLUDE_DIRS_SPACES\n",
                        ),
                        Context(
                            "      OUTPUT_STRIP_TRAILING_WHITESPACE)\n",
                        ),
                        Context(
                            "  string(REPLACE \" \" \";\" LLVM_INCLUDE_DIRS \"${LLVM_INCLUDE_DIRS_SPACES}\")\n",
                        ),
                    ],
                },
            ],
        },
    ],
)
