Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Add vcpkg_install_copyright() portfile function #25239

Merged
merged 29 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4fe6358
[vcpkg tool] Add vcpkg_install_copyright
Thomas1664 Jun 14, 2022
f14e4b1
Make sure FILE_LIST is provided
Thomas1664 Jun 14, 2022
f7ea603
relative to ${SOURCE_PATH}
Thomas1664 Jun 21, 2022
4788f6d
Add documentation
Thomas1664 Jun 21, 2022
121c887
Add to table of contents
Thomas1664 Jun 21, 2022
d431c26
Relative paths was a bad idea.
Thomas1664 Jun 22, 2022
752c91b
Tell users to use the correct way
Thomas1664 Jun 22, 2022
fecaf1c
Fix docs
Thomas1664 Jun 22, 2022
72ff376
Add parameter COMMENT
Thomas1664 Jun 23, 2022
f2fa4fa
Merge branch 'chartdir-ci' of https://github.com/Thomas1664/vcpkg int…
Thomas1664 Jun 23, 2022
838ead7
Merge branch 'master' of https://github.com/microsoft/vcpkg into inst…
Thomas1664 Jun 30, 2022
6ce9152
Rename to vcpkg_concat_copyright
Thomas1664 Jun 30, 2022
53f1636
Fix escape
Thomas1664 Jun 30, 2022
1bf3ee6
Revert "Fix escape"
Thomas1664 Jun 30, 2022
33fe92b
Revert "Rename to vcpkg_concat_copyright"
Thomas1664 Jun 30, 2022
357300f
Fix escape
Thomas1664 Jun 30, 2022
837844f
Add support for single copyright file
Thomas1664 Jun 30, 2022
b8306f4
Merge branch 'microsoft:master' into chartdir-ci
Thomas1664 Jul 1, 2022
0d16516
Update docs
Thomas1664 Jul 1, 2022
ba83327
Merge branch 'chartdir-ci' of https://github.com/Thomas1664/vcpkg int…
Thomas1664 Jul 1, 2022
1eebade
Merge branch 'microsoft:master' into chartdir-ci
Thomas1664 Jul 1, 2022
3794de7
Merge branch 'microsoft:master' into chartdir-ci
Thomas1664 Jul 4, 2022
1ad0b9c
Make comment less confusing
Thomas1664 Jul 6, 2022
fc02ce2
[ci skip] Billy CR
Thomas1664 Jul 6, 2022
034b8ec
[ci skip] Format
Thomas1664 Jul 6, 2022
925ffce
Remove explicit checks for STREQUAL ""
Thomas1664 Jul 7, 2022
5fab7d2
Merge branch 'master' of https://github.com/microsoft/vcpkg into inst…
Thomas1664 Jul 11, 2022
e2268b4
Add error msg if file doesn't exist
Thomas1664 Jul 11, 2022
0f78c1c
Merge branch 'microsoft:master' into chartdir-ci
Thomas1664 Jul 12, 2022
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
12 changes: 12 additions & 0 deletions docs/maintainers/maintainer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ This means that the user should see:
Examples:
* [`brotli`](https://github.com/microsoft/vcpkg/blob/4f0a640e4c5b74166b759a862d7527c930eff32e/ports/brotli/install.patch) creates the `unofficial-brotli` package, producing target `unofficial::brotli::brotli`.

### Install copyright file

Each port has to provide a file named `copyright` in the folder `${CURRENT_PACKAGES_DIR}/share/${PORT}`. You can install the copyright file using the following code:

```cmake
file(INSTALL "${SOURCE_PATH}LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
```

Replace `LICENSE` with the actual file name.

If there are multiple license files, use [`vcpkg_install_copyright()`](vcpkg_install_copyright.md) instead.

## Features

### Do not use features to implement alternatives
Expand Down
1 change: 1 addition & 0 deletions docs/maintainers/portfile-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [vcpkg\_host\_path\_list](vcpkg_host_path_list.md)
- [vcpkg\_install\_cmake](vcpkg_install_cmake.md) (deprecated, use [vcpkg\_cmake\_install](ports/vcpkg-cmake/vcpkg_cmake_install.md))
- [vcpkg\_install\_gn](vcpkg_install_gn.md) (deprecated, use [vcpkg\_gn\_install](ports/vcpkg-gn/vcpkg_gn_install.md))
- [vcpkg_install_copyright](vcpkg_install_copyright.md)
- [vcpkg\_install\_make](vcpkg_install_make.md)
- [vcpkg\_install\_meson](vcpkg_install_meson.md)
- [vcpkg\_install\_msbuild](vcpkg_install_msbuild.md)
Expand Down
39 changes: 39 additions & 0 deletions docs/maintainers/vcpkg_install_copyright.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# vcpkg_install_copyright
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved

The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_install_copyright.md).

Merges multiple copyright files into a single file and install it.

## Usage:

```cmake
vcpkg_install_copyright(FILE_LIST <license.md> <license_gpl.md>...)
```

## Parameters:

### FILE_LIST

Specifies a list of license files relative to `${SOURCE_PATH}`. You must provide at least 2 files.

If you want to install just a single license file, please use

```cmake
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
```

## Notes

This function concatinates the contents of multiple copyright files to a single file.
Thomas1664 marked this conversation as resolved.
Show resolved Hide resolved

The resulting `copyright` file looks similar to this:

```
LICENSE-LGPL2.txt:

Lorem ipsum dolor...

LICENSE-MIT.txt:

Lorem ipsum dolor sit amet...
```
33 changes: 33 additions & 0 deletions scripts/cmake/vcpkg_install_copyright.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function(vcpkg_install_copyright)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "FILE_LIST")

if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

if(NOT DEFINED arg_FILE_LIST)
message(FATAL_ERROR "FILE_LIST must be specified")
endif()

list(LENGTH arg_FILE_LIST FILE_LIST_LENGTH)
if(FILE_LIST_LENGTH LESS_EQUAL 1)
message(FATAL_ERROR "Don't use ${CMAKE_CURRENT_FUNCTION} to install a single license file.")
Thomas1664 marked this conversation as resolved.
Show resolved Hide resolved
endif()

set(out_string "")

foreach(file_item IN LISTS arg_FILE_LIST)
string(PREPEND file_item "${SOURCE_PATH}/")

if(NOT EXISTS "${file_item}" OR IS_DIRECTORY "${file_item}")
message(FATAL_ERROR "The file ${file_item} does not exist or is a directory.")
endif()

get_filename_component(file_name ${file_item} NAME)
file(READ "${file_item}" file_contents)

string(APPEND out_string "${file_name}:\n\n${file_contents}\n\n")
endforeach()

file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "${out_string}")
endfunction()
1 change: 1 addition & 0 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ include("${SCRIPTS}/cmake/vcpkg_get_program_files_platform_bitness.cmake")
include("${SCRIPTS}/cmake/vcpkg_get_windows_sdk.cmake")
include("${SCRIPTS}/cmake/vcpkg_host_path_list.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_cmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_copyright.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_gn.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_make.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_meson.cmake")
Expand Down