Skip to content

Commit e20e4d3

Browse files
committed
Bump prebuilt version to 4, to make sure that the old cache is not used
1 parent e9946ad commit e20e4d3

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

buildtools/build_dependency.cmake

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ endfunction()
266266

267267
# macOS: make installed dylibs relocatable, and point them at sibling deps'
268268
# lib directories so transitive runtime dependencies can be found.
269-
function(_bd_relocatable_macos os install_dir depends_prefixes)
269+
function(_bd_relocatable_macos os name install_dir depends_prefixes)
270270
if(NOT os STREQUAL "macos")
271271
return()
272272
endif()
@@ -282,17 +282,15 @@ function(_bd_relocatable_macos os install_dir depends_prefixes)
282282
endif()
283283

284284
get_filename_component(_install_lib "${install_dir}/lib" ABSOLUTE)
285-
set(_rpath_entries "")
285+
set(_rpath_entries "@loader_path")
286286
foreach(_prefix ${depends_prefixes})
287287
if(EXISTS "${_prefix}/lib")
288288
get_filename_component(_dep_lib "${_prefix}/lib" ABSOLUTE)
289289
file(RELATIVE_PATH _rel "${_install_lib}" "${_dep_lib}")
290290
list(APPEND _rpath_entries "@loader_path/${_rel}")
291291
endif()
292292
endforeach()
293-
if(_rpath_entries)
294-
list(REMOVE_DUPLICATES _rpath_entries)
295-
endif()
293+
list(REMOVE_DUPLICATES _rpath_entries)
296294

297295
foreach(_dylib ${_dylibs})
298296
if(IS_SYMLINK "${_dylib}")
@@ -302,19 +300,30 @@ function(_bd_relocatable_macos os install_dir depends_prefixes)
302300
get_filename_component(_name "${_dylib}" NAME)
303301
if(NOT _install_name MATCHES "@rpath/")
304302
execute_process(COMMAND ${INSTALL_NAME_TOOL} -id "@rpath/${_name}" "${_dylib}" ERROR_QUIET)
305-
message(STATUS "[${BD_NAME}] install_name -> @rpath/${_name}")
303+
message(STATUS "[${name}] install_name -> @rpath/${_name}")
306304
endif()
307305

308306
foreach(_entry ${_rpath_entries})
309-
# -add_rpath fails (non-fatally, ERROR_QUIET'd) if the entry is already present
310-
execute_process(COMMAND ${INSTALL_NAME_TOOL} -add_rpath "${_entry}" "${_dylib}" ERROR_QUIET)
307+
execute_process(COMMAND ${INSTALL_NAME_TOOL} -add_rpath "${_entry}" "${_dylib}"
308+
RESULT_VARIABLE _result ERROR_VARIABLE _err)
309+
# duplicate entries are expected when re-running
310+
if(NOT _result EQUAL 0 AND NOT _err MATCHES "duplicate")
311+
message(FATAL_ERROR "[${name}] add_rpath ${_entry} failed for ${_dylib}: ${_err}")
312+
endif()
311313
endforeach()
312314
endforeach()
313315
endfunction()
314316

317+
# Fix up libraries
318+
function(_bd_fixup_installed os name install_dir depends_prefixes)
319+
_bd_ensure_sonames("${os}" "${name}" "${install_dir}")
320+
_bd_relocatable_elf("${os}" "${name}" "${install_dir}" "${depends_prefixes}")
321+
_bd_relocatable_macos("${os}" "${name}" "${install_dir}" "${depends_prefixes}")
322+
endfunction()
323+
315324
# Create a signature of the recipe directory and its contents
316325
function(_bd_recipe_sig recipe_dir os arch out)
317-
set(_BD_ENGINE_REV 3)
326+
set(_BD_ENGINE_REV 4)
318327
set(_sig "${_BD_ENGINE_REV}|${os}|${arch}")
319328
file(GLOB_RECURSE _files "${recipe_dir}/*")
320329
list(SORT _files)
@@ -369,9 +378,7 @@ function(build_dep)
369378
file(READ "${_build_stamp}" _prev_sig)
370379
if(_prev_sig STREQUAL "${_build_sig}")
371380
message(STATUS "[${BD_NAME}] up-to-date (recipe unchanged), skipping build")
372-
_bd_ensure_sonames("${BD_OS}" "${BD_NAME}" "${BD_INSTALL_DIR}")
373-
_bd_relocatable_elf("${BD_OS}" "${BD_NAME}" "${BD_INSTALL_DIR}" "${BD_DEPENDS_PREFIXES}")
374-
_bd_relocatable_macos("${BD_OS}" "${BD_INSTALL_DIR}" "${BD_DEPENDS_PREFIXES}")
381+
_bd_fixup_installed("${BD_OS}" "${BD_NAME}" "${BD_INSTALL_DIR}" "${BD_DEPENDS_PREFIXES}")
375382
return()
376383
endif()
377384
endif()
@@ -468,9 +475,7 @@ function(build_dep)
468475
endif()
469476

470477
# Fix-up installed libraries
471-
_bd_ensure_sonames("${BD_OS}" "${BD_NAME}" "${INSTALL}")
472-
_bd_relocatable_elf("${BD_OS}" "${BD_NAME}" "${INSTALL}" "${BD_DEPENDS_PREFIXES}")
473-
_bd_relocatable_macos("${BD_OS}" "${INSTALL}" "${BD_DEPENDS_PREFIXES}")
478+
_bd_fixup_installed("${BD_OS}" "${BD_NAME}" "${INSTALL}" "${BD_DEPENDS_PREFIXES}")
474479

475480
# Record the build signature
476481
file(WRITE "${_build_stamp}" "${_build_sig}")

0 commit comments

Comments
 (0)