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

CI: Add MSVC #500

Merged
merged 22 commits into from
Oct 21, 2024
Merged
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
3 changes: 2 additions & 1 deletion .github/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ runs:
run: |
# https://github.com/DiligentGraphics/github-action/commit/d2f7990b16def1efa337e5cc2fc8fa22b6fae55d
PATH="/c/mingw64/bin:$PATH"
ctest --output-on-failure -j"$(nproc)"
# --build-config is only needed for MSVC, but it doesn't bother Linux builds.
ctest --output-on-failure --parallel "$(nproc)" --build-config Debug
shell: bash
22 changes: 18 additions & 4 deletions .github/actions/cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ runs:
export SystemDrive="$SYSTEMDRIVE"
export SystemRoot="$SYSTEMROOT"
export windir="$WINDIR"
vcpkg install doctest:x64-mingw-dynamic trompeloeil:x64-mingw-dynamic
echo cmake_extra_args="'-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake' '-DMINGW=ON' '-G MinGW Makefiles'" >> "$GITHUB_ENV"
CMAKE_EXTRA_ARGS="'-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake'" >> "$GITHUB_ENV"
if [[ ${{ inputs.qt_arch }} = win64_mingw ]]; then
vcpkg install doctest:x64-mingw-dynamic trompeloeil:x64-mingw-dynamic
CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} '-DMINGW=ON' '-G MinGW Makefiles'"
else
vcpkg install doctest trompeloeil
fi

echo cmake_extra_args="${CMAKE_EXTRA_ARGS}" >> "$GITHUB_ENV"
shell: bash

# Qt
Expand Down Expand Up @@ -76,10 +83,17 @@ runs:
echo CMAKE_BIN="${Qt6_DIR}/bin/qt-cmake" >> "$GITHUB_ENV"
shell: bash

- name: Add Werror
if: inputs.qt_arch != 'win64_msvc2019_64'
run: |
echo CFLAGS="-Werror ${CFLAGS}" >> "$GITHUB_ENV"
echo CXXFLAGS="-Werror ${CXXFLAGS}" >> "$GITHUB_ENV"
shell: bash

- name: Configure CMake
run: |
CFLAGS="-Werror ${CFLAGS}" \
CXXFLAGS="-Werror ${CXXFLAGS}" \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
"${CMAKE_BIN:-cmake}" \
-S '${{github.workspace}}' \
-B '${{github.workspace}}/build' \
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jobs:
- name: Build and test
uses: ./.github/actions/build-and-test

windows:
name: Qt 6.5.3 / Windows
windows-mingw:
name: Qt 6.5.3 / Windows MinGW
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
Expand All @@ -100,6 +100,30 @@ jobs:
- name: Build and test
uses: ./.github/actions/build-and-test

windows-msvc:
name: Qt 6.5.3 / Windows MSVC
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_version: 6.5.3
qt_arch: win64_msvc2019_64
use_qt6: ON
modules: qtserialport qtwebsockets
# Need to get all binaries in the same directory, otherwise the tests can't find the dlls.
additional_cmake_args: |
-DLIBSHV_WITH_LDAP=OFF \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY='${{github.workspace}}/build/bin' \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY='${{github.workspace}}/build/bin'

- name: Build and test
uses: ./.github/actions/build-and-test

android:
name: Qt 6.7.3 / Android
runs-on: ubuntu-22.04
Expand Down
2 changes: 2 additions & 0 deletions cmake/qt_moc_disable_warnings.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wuseless-cast"
#endif

8 changes: 4 additions & 4 deletions libshvbroker/include/shv/broker/appclioptions.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "shvbrokerglobal.h"
#include <shv/broker/shvbrokerglobal.h>

#include <shv/chainpack/rpcvalue.h>
#include <shv/core/utils/clioptions.h>
Expand Down Expand Up @@ -41,8 +41,8 @@ class SHVBROKER_DECL_EXPORT AppCliOptions : public shv::core::utils::ConfigCLIOp
CLIOPTION_GETTER_SETTER2(std::string, "ldap.password", l, setL, dapPassword)
CLIOPTION_GETTER_SETTER2(std::string, "ldap.hostname", l, setL, dapHostname)
CLIOPTION_GETTER_SETTER2(std::string, "ldap.searchBaseDN", l, setL, dapSearchBaseDN)
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "ldap.searchAttrs", l, setL, dapSearchAttrs)
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "ldap.groupMapping", l, setL, dapGroupMapping)
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "azure.groupMapping", a, setA, zureGroupMapping)
CLIOPTION_GETTER_SETTER2(chainpack::RpcList, "ldap.searchAttrs", l, setL, dapSearchAttrs)
CLIOPTION_GETTER_SETTER2(chainpack::RpcList, "ldap.groupMapping", l, setL, dapGroupMapping)
CLIOPTION_GETTER_SETTER2(chainpack::RpcList, "azure.groupMapping", a, setA, zureGroupMapping)
};
}
2 changes: 1 addition & 1 deletion libshvbroker/include/shv/broker/azureconfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "groupmapping.h"
#include <shv/broker/groupmapping.h>

#include <string>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion libshvbroker/include/shv/broker/brokerapp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "shv/chainpack/rpcdriver.h"
#include <shv/chainpack/rpcdriver.h>
#ifdef USE_SHV_PATHS_GRANTS_CACHE
#include <string>

Expand Down
1 change: 0 additions & 1 deletion libshvbroker/src/aclmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <shv/broker/aclmanager.h>
#include <shv/broker/brokerapp.h>
//#include "currentclientshvnode.h"

#include <shv/chainpack/utils.h>
#include <shv/chainpack/cponreader.h>
Expand Down
1 change: 1 addition & 0 deletions libshvbroker/src/aclmanagersqlite.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "aclmanagersqlite.h"
#include <shv/core/shvcoreglobal.h>
#include <shv/broker/brokerapp.h>

#include <shv/core/exception.h>
Expand Down
28 changes: 14 additions & 14 deletions libshvbroker/src/brokeraclnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ chainpack::RpcValue EtcAclRootNode::callMethod(const iotqt::node::ShvNode::Strin
{
if(shv_path.empty()) {
if(method == M_SAVE_TO_CONFIG_FILES) {
cp::RpcValue::List ret;
cp::RpcList ret;
for(auto *nd : findChildren<BrokerAclNode*>(QString(), Qt::FindDirectChildrenOnly))
ret.push_back(nd->saveConfigFile());
return ret;
Expand Down Expand Up @@ -222,11 +222,11 @@ chainpack::RpcValue MountsAclNode::callMethod(const iotqt::node::ShvNode::String
auto pn = shv_path.value(1);
if(pn == ACL_MOUNTS_DESCR) {
md.description = params.toString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{device_id, md.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{device_id, md.toRpcValue()}, user_id);
}
if(pn == ACL_MOUNTS_MOUNT_POINT) {
md.mountPoint = params.toString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{device_id, md.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{device_id, md.toRpcValue()}, user_id);
}
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ chainpack::RpcValue RolesAclNode::callMethod(const iotqt::node::ShvNode::StringV
acl::AclRole role_def = mng->role(role_name);
if(method == cp::Rpc::METH_GET) {
if(pn == ACL_ROLE_ROLES)
return shv::chainpack::RpcValue::List::fromStringList(role_def.roles);
return shv::chainpack::RpcList::fromStringList(role_def.roles);
if(pn == ACL_ROLE_PROFILE)
return role_def.profile;
}
Expand All @@ -312,11 +312,11 @@ chainpack::RpcValue RolesAclNode::callMethod(const iotqt::node::ShvNode::StringV
role_def.roles.clear();
for(const auto &rv : params.asList())
role_def.roles.push_back(rv.toString());
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{role_name, role_def.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{role_name, role_def.toRpcValue()}, user_id);
}
if(pn == ACL_ROLE_PROFILE) {
role_def.profile = params;
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{role_name, role_def.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{role_name, role_def.toRpcValue()}, user_id);
}
}
}
Expand Down Expand Up @@ -397,22 +397,22 @@ chainpack::RpcValue UsersAclNode::callMethod(const iotqt::node::ShvNode::StringV
if(pn == ACL_USER_PASSWORD_FORMAT)
return acl::AclPassword::formatToString(user_def.password.format);
if(pn == ACL_USER_ROLES)
return shv::chainpack::RpcValue::List::fromStringList(user_def.roles);
return shv::chainpack::RpcList::fromStringList(user_def.roles);
}
if(method == cp::Rpc::METH_SET) {
if(pn == ACL_USER_PASSWORD) {
user_def.password.password = params.toString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{user_name, user_def.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{user_name, user_def.toRpcValue()}, user_id);
}
if(pn == ACL_USER_PASSWORD_FORMAT) {
user_def.password.format = acl::AclPassword::formatFromString(params.asString());
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{user_name, user_def.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{user_name, user_def.toRpcValue()}, user_id);
}
if(pn == ACL_USER_ROLES) {
user_def.roles.clear();
for(const auto &rv : params.asList())
user_def.roles.push_back(rv.toString());
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{user_name, user_def.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{user_name, user_def.toRpcValue()}, user_id);
}
}
}
Expand Down Expand Up @@ -541,15 +541,15 @@ chainpack::RpcValue AccessAclNode::callMethod(const iotqt::node::ShvNode::String
using namespace shv::core;
if(method == M_SET_PATH_PATTERN) {
rule.path = params.toString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{rule_name, rule.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{rule_name, rule.toRpcValue()}, user_id);
}
if(method == M_SET_METHOD) {
rule.method = params.toString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{rule_name, rule.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{rule_name, rule.toRpcValue()}, user_id);
}
if(method == M_SET_GRANT) {
rule.access = params.asString();
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcValue::List{rule_name, rule.toRpcValue()}, user_id);
return callMethod(StringViewList{}, M_SET_VALUE, cp::RpcList{rule_name, rule.toRpcValue()}, user_id);
}
}
return Super::callMethod(shv_path, method, params, user_id);
Expand Down Expand Up @@ -588,7 +588,7 @@ unsigned AccessAclNode::keyToRuleIndex(const std::string &key)
if(std::regex_search(key, color_match, color_regex)) {
if (color_match.size() > 1) {
bool ok;
unsigned ix = static_cast<unsigned>(shv::core::String::toInt(color_match[1], &ok));
unsigned ix = static_cast<unsigned>(shv::core::string::toInt(color_match[1], &ok));
if(ok)
return ix;
}
Expand Down
12 changes: 8 additions & 4 deletions libshvbroker/src/brokerapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class MountsNode : public shv::iotqt::node::ShvNode
auto *nd = qobject_cast<ClientShvNode*>(nd1);
if(nd == nullptr)
SHV_EXCEPTION("Wrong node type on path: " + path + ", looking for ClientShvNode, found: " + nd1->metaObject()->className());
cp::RpcValue::List lst;
cp::RpcList lst;
for(rpc::ClientConnectionOnBroker *conn : nd->connections())
lst.push_back(conn->connectionId());
return cp::RpcValue{lst};
Expand Down Expand Up @@ -253,7 +253,7 @@ std::optional<AzureConfig> BrokerApp::azureConfig()
}

namespace {
auto transform_cli_group_mapping(const chainpack::RpcValue::List& cli_group_mapping)
auto transform_cli_group_mapping(const chainpack::RpcList& cli_group_mapping)
{
std::vector<GroupMapping> group_mapping;
std::transform(cli_group_mapping.begin(),
Expand All @@ -262,7 +262,11 @@ auto transform_cli_group_mapping(const chainpack::RpcValue::List& cli_group_mapp
[] (const auto& mapping) {
auto mapping_list = mapping.asList();
if (mapping_list.size() != 2) {
#ifdef _MSC_VER
SHV_EXCEPTION(__FUNCSIG__ + std::string{": group mapping isn't a pair."});
#else
SHV_EXCEPTION(__PRETTY_FUNCTION__ + std::string{": group mapping isn't a pair."});
#endif
}
return GroupMapping {
.nativeGroup = mapping.asList().at(0).asString(),
Expand Down Expand Up @@ -980,7 +984,7 @@ void BrokerApp::onClientLogin(int connection_id)

conn->setParent(client_app_node);
{
std::string mount_point = client_id_node->shvPath() + "/subscriptions";
std::string mount_point = client_id_node->shvPath().asString() + "/subscriptions";
auto *nd = new SubscriptionsNode(conn);
if(!m_nodesTree->mount(mount_point, nd))
SHV_EXCEPTION("Cannot mount connection subscription list to device tree, connection id: " + std::to_string(connection_id)
Expand All @@ -1006,7 +1010,7 @@ void BrokerApp::onClientLogin(int connection_id)
SHV_EXCEPTION("Cannot mount connection to device tree, connection id: " + std::to_string(connection_id));
connect(cli_nd, &ClientShvNode::destroyed, cli_nd->parentNode(), &shv::iotqt::node::ShvNode::deleteIfEmptyWithParents, Qt::QueuedConnection);
}
mount_point = cli_nd->shvPath();
mount_point = cli_nd->shvPath().asString();
QTimer::singleShot(0, this, [this, mount_point]() {
sendNotifyToSubscribers(mount_point, cp::Rpc::SIG_MOUNTED_CHANGED, "", true);
});
Expand Down
4 changes: 2 additions & 2 deletions libshvbroker/src/brokerrootnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ chainpack::RpcValue BrokerRootNode::callMethodRq(const chainpack::RpcRequest &rq
chainpack::RpcValue res = Super::callMethodRq(rq);
shvDebug() << "result:" << res.toCpon();
if (rq.metaData().hasKey(rpc::MasterBrokerConnection::ADD_LOCAL_TO_LS_RESULT_META_KEY)) {
chainpack::RpcValue::List res_list = res.asList();
chainpack::List res_list = res.asList();
if (res_list.size() && !res_list[0].isList()) {
res_list.push_back(rpc::MasterBrokerConnection::LOCAL_NODE);
}
else {
res_list.push_back(chainpack::RpcValue::List{ rpc::MasterBrokerConnection::LOCAL_NODE, true });
res_list.push_back(chainpack::List{ rpc::MasterBrokerConnection::LOCAL_NODE, true });
}
res = res_list;
}
Expand Down
2 changes: 1 addition & 1 deletion libshvbroker/src/clientconnectionnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ shv::chainpack::RpcValue ClientConnectionNode::callMethod(const shv::iotqt::node
const std::string user_name = cli->loggedUserName();
auto user_def = BrokerApp::instance()->aclManager()->user(user_name);
auto roles = BrokerApp::instance()->aclManager()->userFlattenRoles(user_name, user_def.roles);
cp::RpcValue::List ret;
cp::RpcList ret;
std::copy(roles.begin(), roles.end(), std::back_inserter(ret));
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions libshvbroker/src/currentclientshvnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ shv::chainpack::RpcValue CurrentClientShvNode::callMethodRq(const shv::chainpack
const string user_name = cli->userName();
auto user_def = shv::broker::BrokerApp::instance()->aclManager()->user(user_name);
auto roles = app->aclManager()->userFlattenRoles(user_name, user_def.roles);
cp::RpcValue::List ret;
cp::RpcList ret;
std::copy(roles.begin(), roles.end(), std::back_inserter(ret));
#if WITH_SHV_LDAP
auto ldap_roles = app->aclManager()->ldapUserFlattenRoles(user_name, user_def.roles);
Expand Down Expand Up @@ -140,7 +140,7 @@ shv::chainpack::RpcValue CurrentClientShvNode::callMethodRq(const shv::chainpack
if (!rq.params().isList()) {
throw_wrong_format();
}
const shv::chainpack::RpcValue::List &param_lst = params.asList();
const shv::chainpack::RpcList &param_lst = params.asList();
if (!param_lst[0].isString() || !param_lst[1].isString()) {
throw_wrong_format();
}
Expand Down
2 changes: 1 addition & 1 deletion libshvbroker/src/rpc/masterbrokerconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ std::string MasterBrokerConnection::masterExportedToLocalPath(const std::string
static const std::string DIR_BROKER = cp::Rpc::DIR_BROKER;
if(shv::core::utils::ShvPath::startsWithPath(master_path, DIR_BROKER))
return master_path;
return shv::core::utils::ShvPath(m_exportedShvPath).appendPath(master_path);
return shv::core::utils::ShvPath(m_exportedShvPath).appendPath(master_path).asString();
}

std::string MasterBrokerConnection::localPathToMasterExported(const std::string &local_path) const
Expand Down
Loading