Skip to content

Commit

Permalink
[ryu] Add support for uwp, arm, x86
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrajchuk committed Apr 19, 2023
1 parent eb8e75b commit b056a04
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
46 changes: 25 additions & 21 deletions ports/ryu/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
function(prepare_bazel_opts flags opts switch)
string(STRIP ${${flags}} ${flags})
if (${flags})
string(REGEX REPLACE "[ ]+-" ";-" ${flags} ${${flags}})
foreach (OPT IN LISTS ${flags})
if (${opts})
string(REGEX REPLACE "^([^ ]+)[ ]+\"?([^\"]+)\"?$" \\1\\2 OPT ${OPT})
set(${opts} ${${opts}};${switch}=${OPT})
else ()
set(${opts} ${switch}=${OPT})
endif ()
endforeach ()
set(${opts} ${${opts}} PARENT_SCOPE)
endif ()
endfunction()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ulfjack/ryu
Expand All @@ -15,39 +31,27 @@ vcpkg_cmake_get_vars(cmake_vars_file)
include(${cmake_vars_file})

if (CMAKE_HOST_WIN32)
set(ENV{BAZEL_VS} $ENV{VSInstallDir})
set(ENV{BAZEL_VC} $ENV{VCInstallDir})
if (VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR STREQUAL x86)
set(BAZEL_CPU --cpu=x64_x86_windows)
elseif (VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR STREQUAL ARM)
set(BAZEL_CPU --cpu=x64_arm_windows)
elseif (VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64)
set(BAZEL_CPU --cpu=x64_arm64_windows)
endif ()
endif ()

if (VCPKG_DETECTED_CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(ENV{SDKROOT} ${VCPKG_DETECTED_CMAKE_OSX_SYSROOT})
endif ()

function(prepare_bazel_opts flags opts switch)
string(STRIP ${${flags}} ${flags})
if (${flags})
string(REGEX REPLACE "[ ]+-" ";-" ${flags} ${${flags}})
foreach (OPT IN LISTS ${flags})
if (${opts})
string(REGEX REPLACE "^([^ ]+)[ ]+\"?([^\"]+)\"?$" \\1\\2 OPT ${OPT})
set(${opts} ${${opts}};${switch}=${OPT})
else ()
set(${opts} ${switch}=${OPT})
endif ()
endforeach ()
set(${opts} ${${opts}} PARENT_SCOPE)
endif ()
endfunction()

prepare_bazel_opts(VCPKG_COMBINED_C_FLAGS_RELEASE CONLY_OPTS_RELEASE --conlyopt)
prepare_bazel_opts(VCPKG_COMBINED_C_FLAGS_DEBUG CONLY_OPTS_DEBUG --conlyopt)
prepare_bazel_opts(VCPKG_COMBINED_CXX_FLAGS_RELEASE CXX_OPTS_RELEASE --cxxopt)
prepare_bazel_opts(VCPKG_COMBINED_CXX_FLAGS_DEBUG CXX_OPTS_DEBUG --cxxopt)
prepare_bazel_opts(VCPKG_COMBINED_STATIC_LINKER_FLAGS_RELEASE LINK_OPTS_RELEASE --linkopt)
prepare_bazel_opts(VCPKG_COMBINED_STATIC_LINKER_FLAGS_DEBUG LINK_OPTS_DEBUG --linkopt)

vcpkg_execute_build_process(
COMMAND ${BAZEL} --batch build ${CONLY_OPTS_RELEASE} ${CXX_OPTS_RELEASE} ${LINK_OPTS_RELEASE} --verbose_failures --strategy=CppCompile=standalone //ryu //ryu:ryu_printf
COMMAND ${BAZEL} --batch build ${BAZEL_CPU} ${CONLY_OPTS_RELEASE} ${LINK_OPTS_RELEASE} --verbose_failures --strategy=CppCompile=standalone //ryu //ryu:ryu_printf
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-rel
)
Expand All @@ -61,7 +65,7 @@ else ()
endif ()

vcpkg_execute_build_process(
COMMAND ${BAZEL} --batch build ${CONLY_OPTS_DEBUG} ${CXX_OPTS_DEBUG} ${LINK_OPTS_DEBUG} --verbose_failures --strategy=CppCompile=standalone //ryu //ryu:ryu_printf
COMMAND ${BAZEL} --batch build ${BAZEL_CPU} ${CONLY_OPTS_DEBUG} ${LINK_OPTS_DEBUG} --verbose_failures --strategy=CppCompile=standalone //ryu //ryu:ryu_printf
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-dbg
)
Expand Down
3 changes: 1 addition & 2 deletions ports/ryu/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "ryu",
"version": "2.0",
"port-version": 7,
"port-version": 8,
"description": "Ryu generates the shortest decimal representation of a floating point number that maintains round-trip safety.",
"homepage": "https://github.com/ulfjack/ryu",
"supports": "!(uwp | arm | x86)",
"dependencies": [
{
"name": "vcpkg-cmake-get-vars",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7098,7 +7098,7 @@
},
"ryu": {
"baseline": "2.0",
"port-version": 7
"port-version": 8
},
"s2geometry": {
"baseline": "0.10.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/r-/ryu.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "660ffa1a7a15e75dbcff064ac704f53b8a2da880",
"version": "2.0",
"port-version": 8
},
{
"git-tree": "9eef3ab0a0bafea6db1a02920f60b756c3eeabfc",
"version": "2.0",
Expand Down

0 comments on commit b056a04

Please sign in to comment.