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/scripts] Add a way to get cmake compiler settings/flags #12936

Merged
merged 46 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0673870
add function get_cmake_vars
Neumann-A Aug 16, 2020
b5f28f7
fine tuning.
Neumann-A Aug 16, 2020
deae3fe
apply to make based ports.
Neumann-A Aug 16, 2020
d4d7e21
add log suffix on not windows platforms
Neumann-A Aug 16, 2020
d47399d
fix c&p error
Neumann-A Aug 16, 2020
6ccbae5
add previous LINK env
Neumann-A Aug 16, 2020
0f2004b
setup env on windows and extract cpp flags correctly.
Neumann-A Aug 16, 2020
f811525
Apply suggestions from code review
Neumann-A Aug 17, 2020
eb2ef40
commit changes from fontconfig PR
Neumann-A Aug 20, 2020
3d2ba81
Merge branch 'add_get_cmake_vars' of https://github.com/Neumann-A/vcp…
Neumann-A Aug 20, 2020
74ca7a3
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Aug 20, 2020
b26f186
Apply suggestions from code review
Neumann-A Aug 20, 2020
ec357c2
cleanup docs
Neumann-A Aug 20, 2020
7c440bd
add conversion from somelib.lib to -lsomelib
Neumann-A Aug 21, 2020
8b20a58
add missing ar-lib wrapper
Neumann-A Aug 22, 2020
8e27695
small but important regex correction
Neumann-A Aug 22, 2020
7b40bf3
add latest changes from update_fontconfig PR
Neumann-A Aug 24, 2020
7ff721b
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Sep 3, 2020
2a70444
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Sep 14, 2020
c70ed33
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Sep 24, 2020
c249d19
Apply suggestions from code review
Neumann-A Oct 2, 2020
b457f4a
Apply suggestions from code review
Neumann-A Oct 2, 2020
9f8efbe
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Oct 12, 2020
7b28101
[x264] set env AS
Neumann-A Oct 13, 2020
3a9a28c
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Oct 15, 2020
c040246
fix bugs due to refactor
Neumann-A Oct 15, 2020
28a4b38
use subpath everywhere
Neumann-A Oct 15, 2020
ae93df4
apply changes from CR
Neumann-A Oct 15, 2020
fead091
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Oct 16, 2020
bb12126
remove unnecessary lines 41 & 44
Neumann-A Oct 16, 2020
65e71b1
remove flag transformation
Neumann-A Oct 18, 2020
723b9d7
reintroduce the flag / to - transformation for MSVC
Neumann-A Oct 18, 2020
afb500b
Apply suggestions from code review
Neumann-A Oct 23, 2020
0c5c993
rename the function
Neumann-A Oct 23, 2020
ade6596
rename function/variables
Neumann-A Oct 23, 2020
d484980
transform flags list
Neumann-A Oct 23, 2020
c5e9724
Apply suggestions from code review
Neumann-A Oct 23, 2020
2ac0ca2
fix vcpkg_build_make due to the variable name change
Neumann-A Oct 23, 2020
cebc141
Merge branch 'add_get_cmake_vars' of https://github.com/Neumann-A/vcp…
Neumann-A Oct 23, 2020
a40e9a4
fix another case of function renaming regressions
Neumann-A Oct 23, 2020
acc8810
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Oct 23, 2020
d857367
only rename config.log if it exists
Neumann-A Oct 23, 2020
a6213b3
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Nov 2, 2020
7e24707
actually add the script after vcpkg_common_functions was deleted.
Neumann-A Nov 2, 2020
cf144ce
Merge remote-tracking branch 'upstream/master' into add_get_cmake_vars
Neumann-A Nov 9, 2020
21d09b9
remove setting of ldflags if path contains spaces
Neumann-A Nov 9, 2020
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
2 changes: 1 addition & 1 deletion ports/x264/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: x264
Version: 157-303c484ec828ed0
Port-Version: 12
Port-Version: 13
Homepage: https://github.com/mirror/x264
Description: x264 is a free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format
Build-Depends: pthread (linux&osx)
1 change: 1 addition & 0 deletions ports/x264/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
_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}")
endif()

if(VCPKG_TARGET_IS_UWP)
Expand Down
130 changes: 130 additions & 0 deletions scripts/buildsystems/make_wrapper/windres-rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#! /bin/sh
# Wrapper for windres to rc which do not understand '-i -o --output-format'.
# cvtres is invoked by the linker
scriptversion=2020-08-17.03; # UTC


nl='
'

# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"

file_conv=

# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/* | msys/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}

# func_windres_wrapper rc args...
# Adjust compile command to suit rc instead of windres
func_windres_wrapper ()
{
echo "FROM WINDRESWRAPPER FUNCTION:$@"
echo "RCFLAGS:$(RCFLAGS)"
# Assume a capable shell
in=
out=

for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
eat=1
func_file_conv "$2"
out="$file"
echo "OUTPUT:$file"
set x "$@"
shift
;;
*.obj)
func_file_conv "$1"
out="$file"
echo "OUTPUT:$file"
set x "$@"
shift
;;
--output-format=*)
set x "$@"
shift
;;
-i)
eat=1
func_file_conv "$2" mingw
in="$file"
echo "INPUT:$file"
set x "$@"
shift
;;
-*)
set x "$@" "${1//\\\"/\"}"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
echo "$@" -fo "$out" "$in"
exec "$@" -fo "$out" "$in"
exit 1
}

eat=

func_windres_wrapper "$@"


# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
87 changes: 50 additions & 37 deletions scripts/cmake/vcpkg_build_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
## ### DISABLE_PARALLEL
## The underlying buildsystem will be instructed to not parallelize
##
## ### SUBPATH
## Additional subdir to invoke make in. Useful if only parts of a port should be built.
##
## ## Notes:
## This command should be preceeded by a call to [`vcpkg_configure_make()`](vcpkg_configure_make.md).
## You can use the alias [`vcpkg_install_make()`](vcpkg_configure_make.md) function if your CMake script supports the
Expand All @@ -39,7 +42,8 @@
## * [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake)
## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake)
function(vcpkg_build_make)
cmake_parse_arguments(_bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET" "" ${ARGN})
include("${CMAKE_VARS_FILE}")
cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET;SUBPATH" "")

if(NOT _bc_LOGFILE_ROOT)
set(_bc_LOGFILE_ROOT "build")
Expand Down Expand Up @@ -108,15 +112,38 @@ function(vcpkg_build_make)
set(PATH_SUFFIX "")
endif()

set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")

set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_SUBPATH}")
message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")

extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_BUILDTYPE})
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_STATIC_LINKERFLAGS_${CMAKE_BUILDTYPE}}")
else() # dynamic
set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${CMAKE_BUILDTYPE}}")
endif()
if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe")
set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link")
set(LINK_ENV_${CMAKE_BUILDTYPE} "$ENV{_LINK_} ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}")
else()
set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}")
endif()

# Setup environment
set(ENV{CPPFLAGS} "${CPPFLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{CFLAGS} "${CFLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{CXXFLAGS} "${CXXFLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{LDFLAGS} "${LDFLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{LIB} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIB_PATHLIKE_CONCAT}")
set(ENV{LIBPATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIBPATH_PATHLIKE_CONCAT}")
set(ENV{LIBRARY_PATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIBRARY_PATH_PATHLIKE_CONCAT}")
#set(ENV{LD_LIBRARY_PATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${BUILDTYPE}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${BUILDTYPE}}/lib/manual-link/${LD_LIBRARY_PATH_PATHLIKE_CONCAT}")

if(LINK_ENV_${_VAR_SUFFIX})
set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}")
set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}")
endif()

if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin")
Expand All @@ -129,62 +156,48 @@ function(vcpkg_build_make)
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS})
set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS})
endif()

if (_bc_DISABLE_PARALLEL)
vcpkg_execute_build_process(
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
)
else()
vcpkg_execute_build_process(
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE}
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
)
endif()

if(_bc_ADD_BIN_TO_PATH)
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
vcpkg_execute_build_process(
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE}
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
)
endif()
endif()
endforeach()

if (_bc_ENABLE_INSTALL)
foreach(BUILDTYPE "debug" "release")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE)
if(BUILDTYPE STREQUAL "debug")
# Skip debug generate
if (_VCPKG_NO_DEBUG)
continue()
endif()
set(SHORT_BUILDTYPE "-dbg")
else()
# In NO_DEBUG mode, we only use ${TARGET_TRIPLET} directory.
if (_VCPKG_NO_DEBUG)
set(SHORT_BUILDTYPE "")
else()
set(SHORT_BUILDTYPE "-rel")
endif()
endif()

if (_bc_ENABLE_INSTALL)
message(STATUS "Installing ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")

if(MAKE_BASH)
set(MAKE_CMD_LINE "${MAKE_COMMAND} ${INSTALL_OPTS}")
else()
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS})
endif()

set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
vcpkg_execute_build_process(
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
LOGNAME "install-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
)
endif()

if(_LINK_CONFIG_BACKUP)
set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}")
unset(_LINK_CONFIG_BACKUP)
endif()

if(_bc_ADD_BIN_TO_PATH)
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
endif()
endforeach()
endif()
endforeach()

if (_bc_ENABLE_INSTALL)
string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp")
file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp")
Expand Down
1 change: 1 addition & 0 deletions scripts/cmake/vcpkg_common_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ include(vcpkg_apply_patches)
include(vcpkg_copy_pdbs)
include(vcpkg_copy_tool_dependencies)
include(vcpkg_copy_tools)
include(vcpkg_get_cmake_vars)
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
include(vcpkg_get_program_files_platform_bitness)
include(vcpkg_get_windows_sdk)
include(vcpkg_replace_string)
Expand Down
Loading