-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[faker-cxx] add new port #38583
Draft
mostsignificant
wants to merge
19
commits into
microsoft:master
Choose a base branch
from
mostsignificant:faker-cxx
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−0
Draft
[faker-cxx] add new port #38583
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7840156
Added faker-cxx library as port
748f2e1
Formatting vcpkg manifest
7c1be00
version database
0f0cfe5
added missing version database file
0dcc29f
android build fix
e945d75
include fmt in CMakeLists.txt on Android build
64afeae
fixed CMakeLists.txt patch
2fad384
Apply suggestions from code review
mostsignificant f234052
android build clang++ ranges fix
07a4553
Apply suggestions from code review
mostsignificant 70c136b
fixed patch file
67448a6
CMakeLists.txt.patch fixes for master ref
6e102e9
fixed git-tree hash
3e1d4ea
removed android build, cleared -Werror flag
7bb39ff
fixed git-tree
06426c6
format version file
ba4c1ac
x-add-version formatted manifest
29e252f
vcpkg_cmake_config_fixup clean, patch files references without quotes…
f0eda75
update version file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index c0c1473..72e6244 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -13,7 +13,7 @@ if (MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /permissive- /bigobj") | ||
else () | ||
set(CMAKE_CXX_FLAGS | ||
- "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion -Wformat -Werror" | ||
+ "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion -Wformat" | ||
) | ||
endif () | ||
|
||
@@ -130,9 +130,8 @@ install(EXPORT ${LIBRARY_NAME}-targets | ||
if (APPLE OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION | ||
VERSION_LESS 12)) | ||
|
||
- add_subdirectory(externals/fmt) | ||
- set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include") | ||
- target_link_libraries(${LIBRARY_NAME} PRIVATE fmt) | ||
+ find_package(fmt CONFIG REQUIRED) | ||
+ target_link_libraries(${LIBRARY_NAME} PRIVATE fmt::fmt) | ||
endif () | ||
|
||
if (BUILD_FAKER_TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/src/common/FormatHelper.h b/src/common/FormatHelper.h | ||
index 6356ee9..8541469 100644 | ||
--- a/src/common/FormatHelper.h | ||
+++ b/src/common/FormatHelper.h | ||
@@ -5,7 +5,7 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
-#if defined(__APPLE__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) | ||
+#if defined(__APPLE__) || defined(__ANDROID__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) | ||
#include <fmt/format.h> | ||
#else | ||
#include <format> | ||
@@ -16,7 +16,7 @@ namespace faker | ||
class FormatHelper | ||
{ | ||
public: | ||
-#if defined(__APPLE__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) | ||
+#if defined(__APPLE__) || defined(__ANDROID__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) | ||
template <typename... Args> | ||
static std::string format(fmt::format_string<Args...> fmt, Args&&... args) | ||
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/include/faker-cxx/Helper.h b/include/faker-cxx/Helper.h | ||
index 51d5eab..c17e41c 100644 | ||
--- a/include/faker-cxx/Helper.h | ||
+++ b/include/faker-cxx/Helper.h | ||
@@ -89,7 +89,7 @@ public: | ||
{ | ||
throw std::invalid_argument{"Data is empty."}; | ||
} | ||
- T item; | ||
+ T item{}; | ||
std::sample(data.begin(), data.end(), &item, 1, pseudoRandomGenerator); | ||
return item; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
if(VCPKG_TARGET_IS_WINDOWS) | ||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) | ||
endif() | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO cieslarmichal/faker-cxx | ||
REF "v${VERSION}" | ||
SHA512 0ad3550d45df2adda70ad64fc1afffc2d39f6644e46029b6b3f0fd42eed071b55daeee9da7456b8b75e1da566bd0d1605518722b2831dba31bf9787506ecfa9d | ||
HEAD_REF master | ||
PATCHES | ||
CMakeLists.txt.patch | ||
FormatHelper.h.patch | ||
Helper.h.patch | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
-DBUILD_FAKER_TESTS=OFF | ||
) | ||
|
||
vcpkg_cmake_install() | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/faker-cxx) | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
faker-cxx provides CMake targets: | ||
|
||
find_package(faker-cxx CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE faker-cxx::faker-cxx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "faker-cxx", | ||
"version-string": "v1.0.0", | ||
"description": "C++ Faker library for generating fake (but realistic) data.", | ||
"homepage": "https://github.com/cieslarmichal/faker-cxx", | ||
"license": "MIT", | ||
"supports": "!android", | ||
"dependencies": [ | ||
"fmt", | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "572cbf1a47f1b4bf14d0ef9b2ae2f06b241e7ffe", | ||
"version-string": "v1.0.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require
find_dependency
in exported config. Is it present?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I am that proficient in CMake - for Apple clang builds, fmt will be included via vcpkg, too. But can you give me an example from another project on what I might be missing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this means.
It is hard to find a minimal example but maybe soci comes close enough.
Making soci use
unofficial::sqlite3::sqlite3
here:vcpkg/ports/soci/dependencies.diff
Lines 43 to 52 in f4456c1
makes
$<LINK_ONLY:unofficial::sqlite3::sqlite3>
appearing in theINTERFACE_LINK_LIBRARIES
of the exported CMake config, so downstream usage will need to know what this target means. And that's why the same patch carries a change to the config file template:vcpkg/ports/soci/dependencies.diff
Lines 55 to 68 in f4456c1