Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/maintainers/vcpkg_copy_tool_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ Copy all DLL dependencies of built tools into the tool folder.

## Usage
```cmake
vcpkg_copy_tool_dependencies(<${CURRENT_PACKAGES_DIR}/tools/${PORT}>)
vcpkg_copy_tool_dependencies(
<${CURRENT_PACKAGES_DIR}/tools/${PORT}>
[DEPENDENCIES <dep1>...]
)
```
## Parameters
The path to the directory containing the tools.
## tool_dir
The path to the directory containing the tools. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.

## DEPENDENCIES
A list of dynamic libraries a tool is likely to load at runtime, such as plugins,
or other Run-Time Dynamic Linking mechanisms like LoadLibrary or dlopen.
These libraries will be copied into the same directory as the tool
even if they are not statically determined as dependencies from inspection of their import tables.

## Notes
This command should always be called by portfiles after they have finished rearranging the binary output, if they have any tools.
Expand Down
7 changes: 7 additions & 0 deletions docs/maintainers/vcpkg_copy_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vcpkg_copy_tools(
TOOL_NAMES <tool1>...
[SEARCH_DIR <${CURRENT_PACKAGES_DIR}/bin>]
[DESTINATION <${CURRENT_PACKAGES_DIR}/tools/${PORT}>]
[DEPENDENCIES <dep1>...]
[AUTO_CLEAN]
)
```
Expand All @@ -23,6 +24,12 @@ The path to the directory containing the tools. This will be set to `${CURRENT_P
### DESTINATION
Destination to copy the tools to. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.

### DEPENDENCIES
A list of dynamic libraries a tool is likely to load at runtime, such as plugins,
or other Run-Time Dynamic Linking mechanisms like LoadLibrary or dlopen.
These libraries will be copied into the same directory as the tool
even if they are not statically determined as dependencies from inspection of their import tables.

### AUTO_CLEAN
Auto clean the copied executables from `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`.

Expand Down
4 changes: 2 additions & 2 deletions ports/gmp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gmp",
"version-string": "6.2.1",
"port-version": 7,
"port-version": 8,
"description": "The GNU Multiple Precision Arithmetic Library",
"homepage": "https://gmplib.org",
"supports": "!(windows & (arm | arm64))",
Expand All @@ -12,7 +12,7 @@
"platform": "windows"
},
{
"name": "yasm-tool",
"name": "yasm",
"host": true,
"platform": "windows"
}
Expand Down
10 changes: 7 additions & 3 deletions ports/yasm-tool-helper/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "yasm-tool-helper",
"version-string": "2020-03-11",
"description": "Backfill that depends on yasm-tool:host",
"port-version": 1,
"description": "Backfill that depends on yasm:host",
"homepage": "https://github.com/Microsoft/vcpkg",
"dependencies": [
{
"name": "yasm-tool",
"host": true
"name": "yasm",
"host": true,
"features": [
"tools"
]
}
]
}
2 changes: 1 addition & 1 deletion ports/yasm-tool-helper/yasm-tool-helper.cmake.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../../@HOST_TRIPLET@/share/yasm-tool/vcpkg-port-config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../../../@HOST_TRIPLET@/share/yasm/vcpkg-port-config.cmake")
48 changes: 1 addition & 47 deletions ports/yasm-tool/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,47 +1 @@
vcpkg_fail_port_install(ON_TARGET "uwp")

if(VCPKG_TARGET_IS_WINDOWS)
set(YASM_BUILD_BINARY ON)
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
set(VCPKG_LIBRARY_LINKAGE static)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO yasm/yasm
REF 009450c7ad4d425fa5a10ac4bd6efbd25248d823 # 1.3.0 plus bugfixes for https://github.com/yasm/yasm/issues/153
SHA512 a542577558676d11b52981925ea6219bffe699faa1682c033b33b7534f5a0dfe9f29c56b32076b68c48f65e0aef7c451be3a3af804c52caa4d4357de4caad83c
)

file(INSTALL "${SOURCE_PATH}/COPYING"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
RENAME copyright)
foreach(LICENSE Artistic.txt BSD.txt GNU_GPL-2.0 GNU_LGPL-2.0)
file(COPY "${SOURCE_PATH}/${LICENSE}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
endforeach()

vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DENABLE_NLS=OFF
-DYASM_BUILD_TESTS=OFF
)
vcpkg_install_cmake()

vcpkg_copy_tools(TOOL_NAMES yasm)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include")
else()
set(YASM_BUILD_BINARY OFF)
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
endif()

configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake.in"
"${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake" @ONLY)
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this print a warning that it's now defunct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Robert's comment, we should not remove any ports.
So I think that's okay, both yasm-tool or yasm[tools] can be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove it because that would break people's scripts and stuff, but we can warn that they aren't using the canonical one.

31 changes: 0 additions & 31 deletions ports/yasm-tool/vcpkg-port-config.cmake.in

This file was deleted.

9 changes: 5 additions & 4 deletions ports/yasm-tool/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "yasm-tool",
"version": "1.3.0",
"description": "A modular assembler.",
"homepage": "http://yasm.tortall.net/",
"supports": "native & !uwp"
"version-date": "2021-12-14",
"description": "Legacy port. Use port yasm instead.",
"dependencies": [
"yasm"
]
}
7 changes: 5 additions & 2 deletions ports/yasm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ vcpkg_copy_pdbs()

if (BUILD_TOOLS)
if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(COPY "${CURRENT_PACKAGES_DIR}/bin/yasmstd${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}"
set(EXTRA_OPTION yasmstd${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX})
file(COPY "${CURRENT_PACKAGES_DIR}/bin/${EXTRA_OPTION}"
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
endif()
vcpkg_copy_tools(TOOL_NAMES vsyasm yasm ytasm AUTO_CLEAN)
vcpkg_copy_tools(TOOL_NAMES vsyasm yasm ytasm DEPENDENCIES ${EXTRA_OPTION} AUTO_CLEAN)
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
Expand All @@ -42,5 +43,7 @@ endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

configure_file("${CURRENT_PORT_DIR}/vcpkg-port-config.cmake.in"
"${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake" @ONLY)
# Handle copyright
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
35 changes: 35 additions & 0 deletions ports/yasm/vcpkg-port-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# For the exported file, we should set 'Z_YASM_TOOL_HELPER_LIST_DIR' before calling 'find_package'
if (NOT DEFINED Z_YASM_TOOL_HELPER_LIST_DIR OR NOT Z_YASM_TOOL_HELPER_LIST_DIR)
# Get the host installed dir, use relative path here
set(Z_YASM_TOOL_HELPER_LIST_DIR "${CMAKE_CURRENT_LIST_DIR}")
get_filename_component(Z_YASM_TOOL_HELPER_LIST_DIR "${Z_YASM_TOOL_HELPER_LIST_DIR}" PATH)
get_filename_component(Z_YASM_TOOL_HELPER_LIST_DIR "${Z_YASM_TOOL_HELPER_LIST_DIR}" PATH)
get_filename_component(Z_YASM_TOOL_HELPER_LIST_DIR "${Z_YASM_TOOL_HELPER_LIST_DIR}" PATH)
set(Z_YASM_TOOL_HELPER_LIST_DIR "${Z_YASM_TOOL_HELPER_LIST_DIR}/@HOST_TRIPLET@")
endif()

function(yasm_tool_helper)
cmake_parse_arguments(PARSE_ARGV 0 arg
"APPEND_TO_PATH;PREPEND_TO_PATH"
"OUT_VAR"
""
)

if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected arguments to yasm_tool_helper: ${arg_UNPARSED_ARGUMENTS}")
endif()

find_program(YASM yasm PATHS "${Z_YASM_TOOL_HELPER_LIST_DIR}/tools/yasm")

if(arg_APPEND_TO_PATH)
get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY)
vcpkg_add_to_path("${YASM_EXE_PATH}")
endif()
if(arg_PREPEND_TO_PATH)
get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY)
vcpkg_add_to_path(PREPEND "${YASM_EXE_PATH}")
endif()
if(DEFINED arg_OUT_VAR)
set("${arg_OUT_VAR}" "${YASM}" PARENT_SCOPE)
endif()
endfunction()
4 changes: 2 additions & 2 deletions ports/yasm/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yasm",
"version-string": "1.3.0",
"port-version": 2,
"version": "1.3.0",
"port-version": 3,
"description": "Yasm is a complete rewrite of the NASM assembler under the new BSD License.",
"homepage": "https://github.com/yasm/yasm",
"supports": "windows & !uwp & !arm",
Expand Down
41 changes: 32 additions & 9 deletions scripts/cmake/vcpkg_copy_tool_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ Copy all DLL dependencies of built tools into the tool folder.

## Usage
```cmake
vcpkg_copy_tool_dependencies(<${CURRENT_PACKAGES_DIR}/tools/${PORT}>)
vcpkg_copy_tool_dependencies(
<${CURRENT_PACKAGES_DIR}/tools/${PORT}>
[DEPENDENCIES <dep1>...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation suggests that the function uses named arguments but the implementation appears to use positional arguments.

Why can't the yasm port issue the right file(COPY calls itself rather than modifying a shared helper like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yasm example shows that there are still other ports that use the same method (load_library) to depend on other libraries, which cann't be analysis by dumpbin.
So this is a common change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, there are ports that do that, yes, but I'm not seeing what's made clearer about this vs. just issuing the file(COPYs, and doing it like this creates the problems I listed below about mixing positional and named parameters.

)
```
## Parameters
The path to the directory containing the tools.
## tool_dir
The path to the directory containing the tools. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.

## DEPENDENCIES
A list of dynamic libraries a tool is likely to load at runtime, such as plugins,
or other Run-Time Dynamic Linking mechanisms like LoadLibrary or dlopen.
These libraries will be copied into the same directory as the tool
even if they are not statically determined as dependencies from inspection of their import tables.

## Notes
This command should always be called by portfiles after they have finished rearranging the binary output, if they have any tools.
Expand All @@ -19,13 +28,26 @@ This command should always be called by portfiles after they have finished rearr
* [fltk](https://github.com/Microsoft/vcpkg/blob/master/ports/fltk/portfile.cmake)
#]===]

function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search dependencies)
if(DEFINED Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT)
set(count ${Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT})
else()
set(count 0)
endif()

file(GLOB tools "${tool_dir}/*.exe" "${tool_dir}/*.dll" "${tool_dir}/*.pyd")
if (dependencies)
foreach (SEARCH_ITEM IN_LIST dependencies)
if (EXISTS "${CURRENT_PACKAGES_DIR}/bin/${SEARCH_ITEM}")
debug_message("Copying file ${CURRENT_PACKAGES_DIR}/bin/${SEARCH_ITEM} to ${TOOL_DIR}")
file(COPY "${CURRENT_PACKAGES_DIR}/bin/${SEARCH_ITEM}" DESTINATION "${TOOL_DIR}")
vcpkg_list(APPEND tools "${TOOL_DIR}/${SEARCH_ITEM}")
else()
message(WARNING "Dynamic dependency ${SEARCH_ITEM} not found in ${CURRENT_PACKAGES_DIR}/bin.")
endif()
endforeach()
endif()

foreach(tool IN LISTS tools)
vcpkg_execute_required_process(
COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -nologo
Expand All @@ -42,7 +64,8 @@ function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
endfunction()

function(vcpkg_copy_tool_dependencies tool_dir)
if(ARGC GREATER 1)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "DEPENDENCIES")
if(ARGC GREATER 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARGC is going to be greater than 2 if tool_dir and DEPENDENCIES are both used; I don't think we should be mixing up positional and named parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tool_dir should only be passed one value. what is your opinion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this response. tool_dir is only passed one value, but given

vcpkg_copy_tool_dependencies("C:/this/is/tool_dir" DEPENDENCIES "foo.dll")

ARGC is 3 so we're going to print that warning, which seems unintended.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

These can't be correct

message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${ARGN}")
endif()

Expand All @@ -56,11 +79,11 @@ function(vcpkg_copy_tool_dependencies tool_dir)
OUTPUT_VARIABLE relative_tool_dir
)
if(relative_tool_dir MATCHES "/debug/")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/debug/bin")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/debug/bin")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/debug/bin" "${arg_DEPENDENCIES}")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/debug/bin" "${arg_DEPENDENCIES}")
else()
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/bin")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/bin")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/bin" "${arg_DEPENDENCIES}")
z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/bin" "${arg_DEPENDENCIES}")
endif()
endif()
endfunction()
11 changes: 9 additions & 2 deletions scripts/cmake/vcpkg_copy_tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vcpkg_copy_tools(
TOOL_NAMES <tool1>...
[SEARCH_DIR <${CURRENT_PACKAGES_DIR}/bin>]
[DESTINATION <${CURRENT_PACKAGES_DIR}/tools/${PORT}>]
[DEPENDENCIES <dep1>...]
[AUTO_CLEAN]
)
```
Expand All @@ -22,6 +23,12 @@ The path to the directory containing the tools. This will be set to `${CURRENT_P
### DESTINATION
Destination to copy the tools to. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.

### DEPENDENCIES
A list of dynamic libraries a tool is likely to load at runtime, such as plugins,
or other Run-Time Dynamic Linking mechanisms like LoadLibrary or dlopen.
These libraries will be copied into the same directory as the tool
even if they are not statically determined as dependencies from inspection of their import tables.

### AUTO_CLEAN
Auto clean the copied executables from `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`.

Expand All @@ -33,7 +40,7 @@ Auto clean the copied executables from `${CURRENT_PACKAGES_DIR}/bin` and `${CURR
#]===]

function(vcpkg_copy_tools)
cmake_parse_arguments(PARSE_ARGV 0 arg "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES")
cmake_parse_arguments(PARSE_ARGV 0 arg "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES;DEPENDENCIES")

if(DEFINED arg_UNPARSED_ARGUMENTS)
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
Expand Down Expand Up @@ -79,5 +86,5 @@ function(vcpkg_copy_tools)
vcpkg_clean_executables_in_bin(FILE_NAMES ${arg_TOOL_NAMES})
endif()

vcpkg_copy_tool_dependencies("${arg_DESTINATION}")
vcpkg_copy_tool_dependencies("${arg_DESTINATION}" DEPENDENCIES "${arg_DEPENDENCIES}")
endfunction()
8 changes: 4 additions & 4 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@
},
"gmp": {
"baseline": "6.2.1",
"port-version": 7
"port-version": 8
},
"google-cloud-cpp": {
"baseline": "1.34.1",
Expand Down Expand Up @@ -7398,15 +7398,15 @@
},
"yasm": {
"baseline": "1.3.0",
"port-version": 2
"port-version": 3
},
"yasm-tool": {
"baseline": "1.3.0",
"baseline": "2021-12-14",
"port-version": 0
},
"yasm-tool-helper": {
"baseline": "2020-03-11",
"port-version": 0
"port-version": 1
},
"yato": {
"baseline": "1.0",
Expand Down
Loading