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

[openxlsx] Add new port #41150

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
119 changes: 119 additions & 0 deletions ports/openxlsx/compilation_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
diff --git a/OpenXLSX/headers/XLSheet.hpp b/OpenXLSX/headers/XLSheet.hpp
index 2f33dd4..0024408 100644
--- a/OpenXLSX/headers/XLSheet.hpp
+++ b/OpenXLSX/headers/XLSheet.hpp
@@ -137,8 +137,8 @@ namespace OpenXLSX
XLSheetState visibility() const
{
XLQuery query(XLQueryType::QuerySheetVisibility);
- query.template setParam("sheetID", relationshipID());
- auto state = parentDoc().execQuery(query).template result<std::string>();
+ query.setParam("sheetID", relationshipID());
+ auto state = parentDoc().execQuery(query).result<std::string>();
auto result = XLSheetState::Visible;

if (state == "visible" || state.empty()) {
@@ -185,19 +185,13 @@ namespace OpenXLSX
* @return
* @todo To be implemented.
*/
- XLColor color() const
- {
- return XLColor();
- }
+ XLColor color() const { return XLColor(); }
Comment on lines +20 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch has several such sections which are not needed to fix problems.
Either let the portfile download the original raw patch from upstream's repo,
or create a minimal patch of necessary changes.


/**
* @brief
* @param color
*/
- void setColor(const XLColor& color)
- {
- static_cast<T&>(*this).setColor_impl(color);
- }
+ void setColor(const XLColor& color) { static_cast<T&>(*this).setColor_impl(color); }

/**
* @brief
@@ -205,11 +199,12 @@ namespace OpenXLSX
*/
uint16_t index() const
{
-// return uint16_t(std::stoi(parentDoc().execQuery(R"({ "query": "QuerySheetIndex", "sheetID": ")" + relationshipID() + "\"}")));
+ // return uint16_t(std::stoi(parentDoc().execQuery(R"({ "query": "QuerySheetIndex", "sheetID": ")" + relationshipID()
+ // + "\"}")));

XLQuery query(XLQueryType::QuerySheetIndex);
- query.template setParam("sheetID", relationshipID());
- return uint16_t(std::stoi(parentDoc().execQuery(query).template result<std::string>()));
+ query.setParam("sheetID", relationshipID());
+ return uint16_t(std::stoi(parentDoc().execQuery(query).result<std::string>()));
}

/**
@@ -218,9 +213,8 @@ namespace OpenXLSX
*/
void setIndex(uint16_t index)
{
- parentDoc().execCommand(XLCommand(XLCommandType::SetSheetIndex)
- .setParam("sheetID", relationshipID())
- .setParam("sheetIndex", index));
+ parentDoc().execCommand(
+ XLCommand(XLCommandType::SetSheetIndex).setParam("sheetID", relationshipID()).setParam("sheetIndex", index));
}

/**
@@ -250,37 +244,25 @@ namespace OpenXLSX
* @brief
* @return
*/
- bool isSelected() const
- {
- return static_cast<const T&>(*this).isSelected_impl();
- }
+ bool isSelected() const { return static_cast<const T&>(*this).isSelected_impl(); }

/**
* @brief
* @param selected
*/
- void setSelected(bool selected)
- {
- static_cast<T&>(*this).setSelected_impl(selected);
- }
+ void setSelected(bool selected) { static_cast<T&>(*this).setSelected_impl(selected); }

/**
* @brief
* @return
*/
- bool isActive() const
- {
- return static_cast<const T&>(*this).isActive_impl();
- }
+ bool isActive() const { return static_cast<const T&>(*this).isActive_impl(); }

/**
* @brief
* @param active
*/
- void setActive()
- {
- static_cast<T&>(*this).setActive_impl();
- }
+ void setActive() { static_cast<T&>(*this).setActive_impl(); }

/**
* @brief Method for cloning the sheet.
@@ -290,9 +272,8 @@ namespace OpenXLSX
*/
void clone(const std::string& newName)
{
- parentDoc().execCommand(XLCommand(XLCommandType::CloneSheet)
- .setParam("sheetID", relationshipID())
- .setParam("cloneName", newName));
+ parentDoc().execCommand(
+ XLCommand(XLCommandType::CloneSheet).setParam("sheetID", relationshipID()).setParam("cloneName", newName));
}
};

31 changes: 31 additions & 0 deletions ports/openxlsx/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Header-only library
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO troldal/OpenXLSX
REF "v${VERSION}"
SHA512 52205b394383d45c0fb16599ab96453d8a5b9b5cd596096848cc888f47565b2713d9edded06b2ecd7b67736622badf136e4b1becc57bfa5bbdcb1e063a347084
HEAD_REF master
PATCHES
compilation_fix.patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit-pick:

Suggested change
compilation_fix.patch
compilation_fix.patch

)
set(CMAKE_CXX_STANDARD 17)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PREFER_NINJA

Default.

OPTIONS
-DOPENXLSX_BUILD_TESTS=OFF
)
Comment on lines +11 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(CMAKE_CXX_STANDARD 17)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DOPENXLSX_BUILD_TESTS=OFF
)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCMAKE_CXX_STANDARD=17
-DOPENXLSX_BUILD_TESTS=OFF
)

Portfiles run in script mode. CMAKE_CXX_STANDARD has no effect.
https://learn.microsoft.com/en-us/vcpkg/contributing/maintainer-guide#portfiles-are-run-in-script-mode

vcpkg_cmake_install(DISABLE_PARALLEL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why DISABLE_PARALLEL?

vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/OpenXLSX)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(COPY "${SOURCE_PATH}/OpenXLSX/external" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(COPY "${SOURCE_PATH}/OpenXLSX/headers/XLException.hpp" DESTINATION "${CURRENT_PACKAGES_DIR}/include")


vcpkg_copy_pdbs()


# Handle copyright
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
3 changes: 3 additions & 0 deletions ports/openxlsx/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
find_package(OpenXLSX CONFIG REQUIRED)
target_link_libraries(main PRIVATE OpenXLSX::OpenXLSX)

Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No red (-) at the end, please.

Suggested change
find_package(OpenXLSX CONFIG REQUIRED)
target_link_libraries(main PRIVATE OpenXLSX::OpenXLSX)
openxlsx provides CMake targets:
find_package(OpenXLSX CONFIG REQUIRED)
target_link_libraries(main PRIVATE OpenXLSX::OpenXLSX)

17 changes: 17 additions & 0 deletions ports/openxlsx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "openxlsx",
"version": "0.3.2",
"description": "OpenXLSX is a C++ library for reading, writing, creating and modifying Microsoft Excel® files, with the .xlsx format.",
"homepage": "https://github.com/troldal/OpenXLSX",
"license": "BSD-3-Clause",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6744,6 +6744,10 @@
"baseline": "2.5.1",
"port-version": 0
},
"openxlsx": {
"baseline": "0.3.2",
"port-version": 0
},
"openxr-loader": {
"baseline": "1.0.31",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/o-/openxlsx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "4f8a34466c10ff2a6a4b991d3fe0fc3823073a49",
"version": "0.3.2",
"port-version": 0
}
]
}
Loading