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

[scripts-audit] Make buildsystem #20165

Merged
merged 29 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions docs/maintainers/portfile-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [vcpkg\_acquire\_msys](vcpkg_acquire_msys.md)
- [vcpkg\_add\_to\_path](vcpkg_add_to_path.md)
- [vcpkg\_apply\_patches](vcpkg_apply_patches.md) (deprecated)
- [vcpkg\_backup\_restore\_env\_vars](vcpkg_backup_restore_env_vars.md)
- [vcpkg\_build\_cmake](vcpkg_build_cmake.md) (deprecated, use [vcpkg\_cmake\_build](ports/vcpkg-cmake/vcpkg_cmake_build.md))
- [vcpkg\_build\_make](vcpkg_build_make.md)
- [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md)
Expand Down
27 changes: 27 additions & 0 deletions docs/maintainers/vcpkg_backup_restore_env_vars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# vcpkg_backup_restore_env_vars

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

Backup or restore the environment variables

## Usage:
```cmake
vcpkg_backup_env_variables(VARS <ENV_VARS>)
```

```cmake
vcpkg_restore_env_variables(VARS <ENV_VARS>)
```

### ENV_VARS
The target passed to the make build command (`./make <target>`). If not specified, the 'all' target will
be passed.
And the backup variable is `z_vcpkg_env_backup_${ENV_VARS}`.

## Notes:
This command should be preceded by a call to [`vcpkg_backup_env_variables()`](vcpkg_backup_env_variables.md) or
[`vcpkg_restore_env_variables()`](vcpkg_restore_env_variables.md).


## Source
[scripts/cmake/vcpkg\_backup\_restore\_env\_vars.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_backup_restore_env_vars.cmake)
4 changes: 2 additions & 2 deletions ports/x264/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
vcpkg_add_to_path(${NASM_EXE_PATH})

if(VCPKG_TARGET_IS_WINDOWS)
_vcpkg_determine_autotools_host_cpu(BUILD_ARCH)
_vcpkg_determine_autotools_target_cpu(HOST_ARCH)
z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH)
z_vcpkg_determine_autotools_target_cpu(HOST_ARCH)
list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32)
list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32)
set(ENV{AS} "${NASM}")
Expand Down
2 changes: 1 addition & 1 deletion ports/x264/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "x264",
"version-string": "157-303c484ec828ed0",
"port-version": 15,
"port-version": 16,
"description": "x264 is a free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format",
"homepage": "https://github.com/mirror/x264",
"supports": "!arm",
Expand Down
62 changes: 62 additions & 0 deletions scripts/cmake/vcpkg_backup_restore_env_vars.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#[===[.md:
# vcpkg_backup_restore_env_vars

Backup or restore the environment variables

## Usage:
```cmake
vcpkg_backup_env_variables(VARS <ENV_VARS>)
```

```cmake
vcpkg_restore_env_variables(VARS <ENV_VARS>)
```

### ENV_VARS
The target passed to the make build command (`./make <target>`). If not specified, the 'all' target will
be passed.
And the backup variable is `z_vcpkg_env_backup_${ENV_VARS}`.

## Notes:
This command should be preceded by a call to [`vcpkg_backup_env_variables()`](vcpkg_backup_env_variables.md) or
[`vcpkg_restore_env_variables()`](vcpkg_restore_env_variables.md).

#]===]

function(vcpkg_backup_env_variables)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
if(NOT DEFINED arg_VARS)
message(FATAL_ERROR "VARS must be defined.")
endif()
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

foreach(envvar IN LISTS arg_VARS)
if(DEFINED ENV{${envvar}})
debug_message("backup ENV\{${envvar}\} to z_vcpkg_env_backup_${envvar}")
set("z_vcpkg_env_backup_${envvar}" "$ENV{${envvar}}" PARENT_SCOPE)
else()
unset(z_vcpkg_env_backup_${envvar})
endif()
endforeach()
endfunction()

function(vcpkg_restore_env_variables)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
if(NOT DEFINED arg_VARS)
message(FATAL_ERROR "VARS must be defined.")
endif()
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

foreach(envvar IN LISTS arg_VARS)
if(DEFINED z_vcpkg_env_backup_${envvar})
debug_message("restore ENV\{${envvar}\} from z_vcpkg_env_backup_${envvar}")
set(ENV{${envvar}} "${z_vcpkg_env_backup_${envvar}}")
else()
unset(ENV{${envvar}})
endif()
endforeach()
endfunction()
203 changes: 96 additions & 107 deletions scripts/cmake/vcpkg_build_make.cmake

Large diffs are not rendered by default.

Loading