Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / compilers / ponyc / make-safe-for-sandbox.patch
blob098b61c1886750979e031b4d5b1c201cfec41710
1 From e26ae067644ea780f050fb900bd850027bb86456 Mon Sep 17 00:00:00 2001
2 From: superherointj <5861043+superherointj@users.noreply.github.com>
3 Date: Tue, 7 Mar 2023 14:59:31 -0300
4 Subject: [PATCH] make-safe-for-sandbox.patch
6 ---
7 lib/CMakeLists.txt | 80 ++--------------------------------------------
8 1 file changed, 2 insertions(+), 78 deletions(-)
10 diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
11 index 129e26e6..d25bdf9d 100644
12 --- a/lib/CMakeLists.txt
13 +++ b/lib/CMakeLists.txt
14 @@ -32,14 +32,14 @@ endif()
16 set(PONYC_GBENCHMARK_URL https://github.com/google/benchmark/archive/v1.7.1.tar.gz)
17 ExternalProject_Add(gbenchmark
18 - URL ${PONYC_GBENCHMARK_URL}
19 + SOURCE_DIR gbenchmark-prefix/src/benchmark
20 CMAKE_ARGS -DCMAKE_BUILD_TYPE=${PONYC_LIBS_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -DBENCHMARK_ENABLE_WERROR=OFF -DCMAKE_CXX_FLAGS=${PONY_PIC_FLAG} --no-warn-unused-cli
23 set(PONYC_GOOGLETEST_URL https://github.com/google/googletest/archive/release-1.12.1.tar.gz)
25 ExternalProject_Add(googletest
26 - URL ${PONYC_GOOGLETEST_URL}
27 + URL @googletest@
28 CMAKE_ARGS -DCMAKE_BUILD_TYPE=${PONYC_LIBS_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_FLAGS=${PONY_PIC_FLAG} -Dgtest_force_shared_crt=ON --no-warn-unused-cli
31 @@ -52,82 +52,6 @@ install(TARGETS blake2
32 COMPONENT library
35 -find_package(Git)
37 -set(LLVM_DESIRED_HASH "1f9140064dfbfb0bbda8e51306ea51080b2f7aac")
38 -set(PATCHES_DESIRED_HASH "3e16c097794cb669a8f6a0bd7600b440205ac5c29a6135750c2e83263eb16a95")
40 -if(GIT_FOUND)
41 - if(EXISTS "${PROJECT_SOURCE_DIR}/../.git")
42 - # Update submodules as needed
43 - option(GIT_SUBMODULE "Check submodules during build" ON)
44 - if(GIT_SUBMODULE)
45 - message(STATUS "Updating submodules...")
46 - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --depth 1
47 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
48 - RESULT_VARIABLE git_submod_result)
49 - #message("git_submod_result ${git_submod_result}")
50 - if(NOT git_submod_result EQUAL "0")
51 - message(FATAL_ERROR "git submodule update --init --recursive --depth 1 failed with ${git_submod_result}, please checkout submodules")
52 - endif()
54 - # we check to make sure the submodule hash matches
55 - # the reason the submodule hash is in this file is to be able to use this file as a key for caching the libs in CI
56 - execute_process(COMMAND ${GIT_EXECUTABLE} submodule status
57 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
58 - OUTPUT_VARIABLE git_submod_output)
59 - #message("git_submod_output ${git_submod_output}")
60 - string(FIND "${git_submod_output}" "${LLVM_DESIRED_HASH}" LLVM_SUBMOD_POS)
61 - if(LLVM_SUBMOD_POS EQUAL "-1")
62 - message(FATAL_ERROR "Expecting the lib/llvm/src submodule to be at hash '${LLVM_DESIRED_HASH}'; found '${git_submod_output}'; update the LLVM_DESIRED_HASH variable in lib/CMakeLists.txt if you've updated the submodule.")
63 - endif()
64 - endif()
65 - endif()
67 - # Apply patches
68 - message("Applying patches...")
69 - file(GLOB PONY_LLVM_PATCHES "${PROJECT_SOURCE_DIR}/llvm/patches/*.diff")
71 - # check to see if the patch hashes match
72 - message("Checking patches ${PONY_LLVM_PATCHES}")
73 - set(PATCHES_ACTUAL_HASH "needed_if_no_patches")
74 - foreach (PATCH ${PONY_LLVM_PATCHES})
75 - file(STRINGS ${PATCH} patch_file NEWLINE_CONSUME)
76 - string(REPLACE "\n" " " patch_file ${patch_file})
77 - string(SHA256 patch_file_hash ${patch_file})
78 - # message("${PATCH}: '${patch_file_hash}'")
79 - string(CONCAT PATCHES_ACTUAL_HASH ${PATCHES_ACTUAL_HASH} ${patch_file_hash})
80 - # message("concat is '${PATCHES_ACTUAL_HASH}'")
81 - endforeach()
82 - string(SHA256 PATCHES_ACTUAL_HASH ${PATCHES_ACTUAL_HASH})
83 - # message("Desired hash ${PATCHES_DESIRED_HASH}")
84 - # message("Actual hash ${PATCHES_ACTUAL_HASH}")
85 - if(NOT PATCHES_ACTUAL_HASH MATCHES "${PATCHES_DESIRED_HASH}")
86 - message(FATAL_ERROR "Patch hash actual '${PATCHES_ACTUAL_HASH}' does not match desired '${PATCHES_DESIRED_HASH}'")
87 - endif()
89 - foreach (PATCH ${PONY_LLVM_PATCHES})
90 - message(" Checking ${PATCH}")
91 - execute_process(COMMAND ${GIT_EXECUTABLE} apply --check -p 1 --ignore-whitespace --whitespace=nowarn ${PATCH}
92 - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/llvm/src"
93 - ERROR_VARIABLE _err_out
94 - RESULT_VARIABLE git_apply_check_result)
95 - if(git_apply_check_result EQUAL "0")
96 - message(" Applying ${PATCH}")
97 - execute_process(COMMAND ${GIT_EXECUTABLE} apply -p 1 --ignore-whitespace --whitespace=nowarn ${PATCH}
98 - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/llvm/src"
99 - RESULT_VARIABLE git_apply_result)
100 - if(NOT git_apply_result EQUAL "0")
101 - message(FATAL_ERROR "Unable to apply ${PATCH}")
102 - endif()
103 - else()
104 - message(" Already applied ${PATCH}")
105 - endif()
106 - endforeach()
107 -else()
108 - message(FATAL_ERROR "Git not found!")
109 -endif()
111 message("Building targets: ${LLVM_TARGETS_TO_BUILD}")
113 set(LLVM_ENABLE_BINDINGS OFF CACHE BOOL "ponyc specific override of LLVM cache entry")
115 2.39.2