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

[mocknetworkaccessmanager] add recipe for 0.12.0 #21892

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd0331e
[mocknetworkaccessmanager] add recipe for 0.12.0
MartinDelille Dec 25, 2023
0c7efb8
Check the C++ standard version is at least C++11
MartinDelille Dec 26, 2023
1ce23a6
Change package_type from header-only to library
MartinDelille Dec 27, 2023
c197ca4
Add link to patch source
MartinDelille Dec 27, 2023
541cf76
Add a check for the OS, only Macos is supported for now.
MartinDelille Dec 27, 2023
da8837c
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Dec 31, 2023
8bf0bd2
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Jan 8, 2024
08bd4d3
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Jan 18, 2024
e8a870b
Disable shared builds
MartinDelille Jan 18, 2024
b5bec55
Reenable other platforms
MartinDelille Jan 19, 2024
ce7d0da
Remove Linux support for now
MartinDelille Jan 19, 2024
06b2446
Fix Linux build
MartinDelille Jan 19, 2024
45c183a
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Jan 23, 2024
ee59c13
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Jan 26, 2024
e0fe037
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Jan 31, 2024
34b04ac
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Feb 8, 2024
01d4fe4
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Feb 13, 2024
981d330
Increase the minimum C++ standard to 17
MartinDelille Feb 14, 2024
77fc9f4
Apply suggestions from code review
MartinDelille Feb 14, 2024
a21fd19
Apply suggestions from code review
MartinDelille Feb 14, 2024
a05670c
Update recipes/mocknetworkaccessmanager/all/conanfile.py
MartinDelille Feb 14, 2024
4a32377
Apply suggestions from code review
MartinDelille Feb 15, 2024
06e06b4
Fix requires for qt6
MartinDelille Feb 15, 2024
0a1f23a
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Feb 26, 2024
f0170d2
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Mar 3, 2024
031299d
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Mar 4, 2024
4a1d57b
Remove whenGet() from test_package.cpp
MartinDelille Mar 5, 2024
f140b85
Merge branch 'master' into add-mocknetworkaccessmanager
MartinDelille Mar 8, 2024
2e0be31
Revert "Remove whenGet() from test_package.cpp"
MartinDelille Mar 21, 2024
70bccdc
Use QCoreApplication
MartinDelille Mar 21, 2024
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
14 changes: 14 additions & 0 deletions recipes/mocknetworkaccessmanager/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sources:
"0.12.0":
url: "https://gitlab.com/julrich/MockNetworkAccessManager/-/archive/0.12.0/MockNetworkAccessManager-0.12.0.tar.gz"
sha256: "ac9ffb5e6e5ccdc1b7c76da7a92b5d845ec12eb48a39b0423005da4f6431b09f"
patches:
"0.12.0":
- patch_file: "patches/0.12.0-0001-add-install-step.patch"
patch_description: "Add install step"
patch_type: "conan"
patch_source: "https://gitlab.com/julrich/MockNetworkAccessManager/-/merge_requests/75"
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
- patch_file: "patches/0.12.0-0002-fix-target-without-location.patch"
patch_description: "Fix target without location"
patch_type: "conan"
patch_source: "https://gitlab.com/julrich/MockNetworkAccessManager/-/merge_requests/75"
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
72 changes: 72 additions & 0 deletions recipes/mocknetworkaccessmanager/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get
import os


required_conan_version = ">=1.52.0"


class MockNetworkAccessManagerConan(ConanFile):
name = "mocknetworkaccessmanager"
description = "Mocking network communication for Qt applications"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.com/julrich/MockNetworkAccessManager"
topics = ("qt", "mock", "network", "QNetworkAccessManager", "unit test", "test")
package_type = "static-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
"with_qt": [5, 6],
}
default_options = {
"fPIC": True,
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
"with_qt": 5,
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.with_qt == 5:
self.requires("qt/5.15.12", transitive_headers=True)
else:
self.requires("qt/6.6.1", transitive_headers=True)

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, "11")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_TESTING"] = False
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
tc.variables["FORCE_QT5"] = self.options.with_qt == 5
tc.generate()
tc = CMakeDeps(self)
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["MockNetworkAccessManager"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61ed3ed..6d0de20 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,3 +107,10 @@ add_library( MockNetworkAccessManager STATIC EXCLUDE_FROM_ALL "MockNetworkAccess
target_include_directories( MockNetworkAccessManager PUBLIC "${PROJECT_SOURCE_DIR}" )
target_link_libraries( MockNetworkAccessManager Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network )

+install(TARGETS MockNetworkAccessManager
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+install(FILES "${PROJECT_SOURCE_DIR}/MockNetworkAccessManager.hpp"
+ DESTINATION include)
+
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
commit e28d1f3868db8c7f5ff654a205d80d5d7ed203c4
Author: Martin Delille <[email protected]>
Date: Fri Jan 19 18:06:56 2024 +0100

Fix target without LOCATION property

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d0de20..dbfbed3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,8 +26,7 @@ if( NOT Qt5_FOUND OR NOT Qt6_FOUND )
find_package( Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network )
endif()

-get_target_property( QTCORE_LOCATION Qt${QT_VERSION_MAJOR}::Core LOCATION )
-get_filename_component( QT_BIN_DIR ${QTCORE_LOCATION} DIRECTORY )
+get_filename_component(QT_BIN_DIR "$<TARGET_FILE_DIR:Qt${QT_VERSION_MAJOR}::Core>" ABSOLUTE)
set( CMAKE_MSVCIDE_RUN_PATH ${QT_BIN_DIR} )
set_property( DIRECTORY "." APPEND PROPERTY COMPILE_DEFINITIONS "QT_DEPRECATED_WARNINGS" )

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(mocknetworkaccessmanager REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE mocknetworkaccessmanager::mocknetworkaccessmanager)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
26 changes: 26 additions & 0 deletions recipes/mocknetworkaccessmanager/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
15 changes: 15 additions & 0 deletions recipes/mocknetworkaccessmanager/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <QCoreApplication>

#include "MockNetworkAccessManager.hpp"

int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
MockNetworkAccess::Manager< QNetworkAccessManager > mnam;

mnam.whenGet( QUrl( "http://example.com/hello" ) )
.has( MockNetworkAccess::Predicates::HeaderMatching( QNetworkRequest::UserAgentHeader,
QRegularExpression( ".*MyNetworkClient/.*" ) ) )
.reply().withBody( QJsonDocument::fromJson( "{\"hello\":\"world\"}" ) );
uilianries marked this conversation as resolved.
Show resolved Hide resolved

return 0;
}
3 changes: 3 additions & 0 deletions recipes/mocknetworkaccessmanager/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.12.0":
folder: all
Loading