From 5c38199c8d5f8f2d96b991027f9dadc9ddf23550 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 15 Dec 2021 12:53:01 +0100 Subject: [PATCH 1/4] fix meson linker detection ..... --- .../fix_linker_detection.patch | 25 +++++++++++++++++++ ports/vcpkg-tool-meson/portfile.cmake | 1 + ports/vcpkg-tool-meson/vcpkg.json | 1 + 3 files changed, 27 insertions(+) create mode 100644 ports/vcpkg-tool-meson/fix_linker_detection.patch diff --git a/ports/vcpkg-tool-meson/fix_linker_detection.patch b/ports/vcpkg-tool-meson/fix_linker_detection.patch new file mode 100644 index 00000000000000..89e6dfa214b850 --- /dev/null +++ b/ports/vcpkg-tool-meson/fix_linker_detection.patch @@ -0,0 +1,25 @@ +diff --git a/tools/meson/mesonbuild/compilers/detect.py b/tools/meson/mesonbuild/compilers/detect.py +index 1eacecfa8..74668da1a 100644 +--- a/tools/meson/mesonbuild/compilers/detect.py ++++ b/tools/meson/mesonbuild/compilers/detect.py +@@ -292,7 +292,7 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker + linkers = default_linkers + popen_exceptions = {} + for linker in linkers: +- if not {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'}.isdisjoint(linker): ++ if any(os.path.basename(x) in {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'} for x in linker): + arg = '/?' + elif not {'ar2000', 'ar2000.exe'}.isdisjoint(linker): + arg = '?' +diff --git a/tools/meson/mesonbuild/linkers/detect.py b/tools/meson/mesonbuild/linkers/detect.py +index 0bfd7083b..323801d9a 100644 +--- a/tools/meson/mesonbuild/linkers/detect.py ++++ b/tools/meson/mesonbuild/linkers/detect.py +@@ -72,6 +72,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty + override = [] # type: T.List[str] + value = env.lookup_binary_entry(for_machine, comp_class.language + '_ld') + if value is not None: ++ compiler = value + override = comp_class.use_linker_args(value[0]) + check_args += override + diff --git a/ports/vcpkg-tool-meson/portfile.cmake b/ports/vcpkg-tool-meson/portfile.cmake index a858c5f45d9c25..fd0110847ccfa5 100644 --- a/ports/vcpkg-tool-meson/portfile.cmake +++ b/ports/vcpkg-tool-meson/portfile.cmake @@ -47,6 +47,7 @@ if(NOT "${program}") z_vcpkg_apply_patches( SOURCE_PATH "${CURRENT_PACKAGES_DIR}" PATCHES meson-intl.patch + fix_linker_detection.patch ) endif() diff --git a/ports/vcpkg-tool-meson/vcpkg.json b/ports/vcpkg-tool-meson/vcpkg.json index 418753714e4b88..ec48241bd25769 100644 --- a/ports/vcpkg-tool-meson/vcpkg.json +++ b/ports/vcpkg-tool-meson/vcpkg.json @@ -1,6 +1,7 @@ { "name": "vcpkg-tool-meson", "version": "0.60.2", + "port-version": 1, "description": "Meson build system", "homepage": "https://github.com/mesonbuild/meson", "supports": "native" From c652783e0aedb411ad8b59473b22e9d25eb753bf Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 15 Dec 2021 12:54:15 +0100 Subject: [PATCH 2/4] bit of code cleanup in vcpkg_configure_meson --- scripts/cmake/vcpkg_configure_meson.cmake | 109 +++++++++------------- 1 file changed, 44 insertions(+), 65 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake index 88f0abc81ad667..28dfb725c51783 100644 --- a/scripts/cmake/vcpkg_configure_meson.cmake +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -40,45 +40,72 @@ This command supplies many common arguments to Meson. To see the full list, exam * [libepoxy](https://github.com/Microsoft/vcpkg/blob/master/ports/libepoxy/portfile.cmake) #]===] -function(z_vcpkg_meson_generate_native_file additional_binaries) #https://mesonbuild.com/Native-environments.html - set(native_config "[binaries]\n") - #set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT) +function(z_vcpkg_append_proglist var_to_append additional_binaries) + string(APPEND "${var_to_append}" "[binaries]\n") if(VCPKG_TARGET_IS_WINDOWS) - set(proglist MT) + set(proglist MT AR) else() set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT) endif() foreach(prog IN LISTS proglist) if(VCPKG_DETECTED_CMAKE_${prog}) - string(TOLOWER "${prog}" proglower) - string(APPEND native_config "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n") + if(meson_${prog}) + string(APPEND "${var_to_append}" "${meson_${prog}} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n") + else() + string(TOLOWER "${prog}" proglower) + string(APPEND "${var_to_append}" "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n") + endif() endif() endforeach() set(programs C CXX RC) + set(meson_RC windres) + set(meson_CXX cpp) foreach(prog IN LISTS programs) if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER) - string(REPLACE "CXX" "CPP" mesonprog "${prog}") - string(REPLACE "RC" "windres" mesonprog "${mesonprog}") # https://mesonbuild.com/Windows-module.html - string(TOLOWER "${mesonprog}" proglower) - string(APPEND native_config "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n") + if(meson_${prog}) + string(APPEND "${var_to_append}" "${meson_${prog}} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n") + else() + string(TOLOWER "${prog}" proglower) + string(APPEND "${var_to_append}" "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n") + endif() endif() endforeach() if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 if (NOT VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel)$") - string(APPEND native_config "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + string(APPEND "${var_to_append}" "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") endif() endif() if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 if (NOT VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel)$") - string(APPEND native_config "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + string(APPEND "${var_to_append}" "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") endif() endif() - string(APPEND native_config "cmake = '${CMAKE_COMMAND}'\n") + + get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY) + #vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson + string(APPEND "${var_to_append}" "cmake = '${CMAKE_COMMAND}'\n") + + vcpkg_find_acquire_program(PYTHON3) + get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) + vcpkg_add_to_path("${PYTHON3_DIR}") + string(APPEND "${var_to_append}" "python = '${PYTHON3}'\n") + + vcpkg_find_acquire_program(NINJA) + get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) + vcpkg_add_to_path(PREPEND "${NINJA_PATH}") # Prepend to use the correct ninja. + # string(APPEND "${var_to_append}" "ninja = '${NINJA}'\n") # This does not work due to meson issues + foreach(additional_binary IN LISTS additional_binaries) - string(APPEND native_config "${additional_binary}\n") + string(APPEND "${var_to_append}" "${additional_binary}\n") endforeach() + set("${var_to_append}" "${${var_to_append}}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_meson_generate_native_file additional_binaries) #https://mesonbuild.com/Native-environments.html + set(native_config "") + z_vcpkg_append_proglist(native_config "${additional_binaries}") string(APPEND native_config "[built-in options]\n") #https://mesonbuild.com/Builtin-options.html if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") @@ -276,43 +303,9 @@ function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbu else() message(FATAL_ERROR "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}!" ) endif() - set(cross_file "[binaries]\n") - if(VCPKG_TARGET_IS_WINDOWS) - set(proglist MT) - else() - set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT) - endif() - foreach(prog IN LISTS proglist) - if(VCPKG_DETECTED_CMAKE_${prog}) - string(TOLOWER "${prog}" proglower) - string(APPEND cross_file "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n") - endif() - endforeach() - set(programs C CXX RC) - foreach(prog IN LISTS programs) - if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER) - string(REPLACE "CXX" "CPP" mesonprog "${prog}") - string(REPLACE "RC" "windres" mesonprog "${mesonprog}") # https://mesonbuild.com/Windows-module.html - string(TOLOWER "${mesonprog}" proglower) - string(APPEND cross_file "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n") - endif() - endforeach() - if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) - # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 - if (NOT VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel)$") - string(APPEND cross_file "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") - endif() - endif() - if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) - # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 - if (NOT VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel)$") - string(APPEND cross_file "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") - endif() - endif() - string(APPEND cross_file "cmake = '${CMAKE_COMMAND}'\n") - foreach(additional_binary IN LISTS additional_binaries) - string(APPEND cross_file "${additional_binary}\n") - endforeach() + + set(cross_file "") + z_vcpkg_append_proglist(cross_file "${additional_binaries}") string(APPEND cross_file "[properties]\n") @@ -391,22 +384,8 @@ function(vcpkg_configure_meson) debug_message("Including cmake vars from: ${cmake_vars_file}") include("${cmake_vars_file}") - vcpkg_find_acquire_program(PYTHON3) - get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) - vcpkg_add_to_path("${PYTHON3_DIR}") - vcpkg_list(APPEND arg_ADDITIONAL_NATIVE_BINARIES "python = '${PYTHON3}'") - vcpkg_list(APPEND arg_ADDITIONAL_CROSS_BINARIES "python = '${PYTHON3}'") - vcpkg_find_acquire_program(MESON) - get_filename_component(CMAKE_PATH ${CMAKE_COMMAND} DIRECTORY) - vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson - - vcpkg_find_acquire_program(NINJA) - get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) - vcpkg_add_to_path(PREPEND "${NINJA_PATH}") # Need to prepend so that meson picks up the correct ninja from vcpkg .... - # vcpkg_list(APPEND arg_ADDITIONAL_NATIVE_BINARIES "ninja = '${NINJA}'") # This does not work due to meson issues ...... - vcpkg_list(APPEND arg_OPTIONS --buildtype plain --backend ninja --wrap-mode nodownload) if(NOT vcpkg_meson_cross_file) From 1636c0badc06c5da9ed4edca3678a109db1ff413 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 15 Dec 2021 12:59:22 +0100 Subject: [PATCH 3/4] forgot the version stuff --- versions/baseline.json | 2 +- versions/v-/vcpkg-tool-meson.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index 84f02eb71b38cc..209b1048e40c3d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7126,7 +7126,7 @@ }, "vcpkg-tool-meson": { "baseline": "0.60.2", - "port-version": 0 + "port-version": 1 }, "vcpkg-tool-nodejs": { "baseline": "14.17.4", diff --git a/versions/v-/vcpkg-tool-meson.json b/versions/v-/vcpkg-tool-meson.json index cb90b4013dc1f1..69969c8559d818 100644 --- a/versions/v-/vcpkg-tool-meson.json +++ b/versions/v-/vcpkg-tool-meson.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "932036adfc24dd5fa63787b825974b6938402700", + "version": "0.60.2", + "port-version": 1 + }, { "git-tree": "e6ef15a9dc810b4bde53d9b1e3da3a20107e3983", "version": "0.60.2", From 0862c17cc0b25ef8bc111108f0e26a3530a63475 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 15 Dec 2021 22:14:38 +0100 Subject: [PATCH 4/4] put cmake back on path because meson is buggy as hell --- scripts/cmake/vcpkg_configure_meson.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake index 28dfb725c51783..02e189b3140dad 100644 --- a/scripts/cmake/vcpkg_configure_meson.cmake +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -84,7 +84,7 @@ function(z_vcpkg_append_proglist var_to_append additional_binaries) endif() get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY) - #vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson + vcpkg_add_to_path("${CMAKE_PATH}" PREPEND) # Make CMake invokeable for Meson string(APPEND "${var_to_append}" "cmake = '${CMAKE_COMMAND}'\n") vcpkg_find_acquire_program(PYTHON3)