Skip to content

Commit

Permalink
cmock: add new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-igonet-at-exotrail committed Dec 24, 2024
1 parent 4622ac8 commit 57cc9ab
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/cmock/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.5.3":
url: "https://github.com/ThrowTheSwitch/CMock/archive/refs/tags/v2.5.3.tar.gz"
sha256: "d30724405b527f2b1d2894b27a1600af3ccb4aad12e63e48ba4f0ea8ae88fe9c"
60 changes: 60 additions & 0 deletions recipes/cmock/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir
import os

required_conan_version = ">=1.53.0"


class UnityConan(ConanFile):
name = "cmock"
description = "CMock is a mock and stub generator and runtime for unit testing C. It's been designed to work smoothly with Unity Test,"
topics = ("mock", "unit-test", "testing")
license = "MIT"
homepage = "http://www.throwtheswitch.org"
url = "https://github.com/conan-io/conan-center-index"
package_type = "static-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"fixture_extension": [True, False],
"memory_extension": [True, False],
}
default_options = {
"fPIC": True,
"fixture_extension": False,
"memory_extension": False,
}

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

def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

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

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

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

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

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

def package_info(self):
self.cpp_info.libs = ["cmock"]
self.cpp_info.includedirs = ["include", "include/cmock"]
8 changes: 8 additions & 0 deletions recipes/cmock/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(cmock LANGUAGES C)

find_package(cmock REQUIRED CONFIG)

add_executable(${PROJECT_NAME} cmock.c)
target_link_libraries(${PROJECT_NAME} PRIVATE cmock::cmock)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)
6 changes: 6 additions & 0 deletions recipes/cmock/all/test_package/conan.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <cmock.h>

int main(void)
{
return 0
}
25 changes: 25 additions & 0 deletions recipes/cmock/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
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):
self.run(os.path.join(self.cpp.build.bindirs[0], "cmock"), env="conanrun")
3 changes: 3 additions & 0 deletions recipes/cmock/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.5.3":
folder: all

0 comments on commit 57cc9ab

Please sign in to comment.