Repository: conan-io/conan-center-index

Issue:
[request] log.c/0.1.0
### Package Details
  * Package Name/Version: **log.c/0.1.0**
  * Source code: **https://github.com/rxi/log.c**


### Description Of The Library / Tool
A simple logging library implemented in C99


Discussion:

Resolving patch:
diff --git a/recipes/log.c/all/conanfile.py b/recipes/log.c/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/log.c/all/conanfile.py
@@ -0,0 +1,65 @@
+from conans import ConanFile, CMake, tools
+import glob
+
+
+class logcConan(ConanFile):
+    name = "log.c"
+    license = "MIT"
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://github.com/rxi/log.c"
+    description = "A simple logging library implemented in C99"
+    topics = ("logging", "log", "logging-library", "conan", "logc", "purec", "c99")
+    settings = "os", "compiler", "build_type", "arch"
+    options = {"shared": [True, False],
+               "fPIC": [True, False],
+               "color": [True, False]}
+    default_options = {"shared": False,
+                       "fPIC": True,
+                       "color": True}
+    generators = "cmake"
+    exports_sources = ["CMakeLists.txt",
+                       "patches/*"]
+
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        tools.rename(glob.glob(self.name + "-*/")[0], self._source_subfolder)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["COLOR"] = self.options.color
+        self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        cmake = self._configure_cmake()
+        cmake.install()
+
+    def package_info(self):
+        self.cpp_info.libs = tools.collect_libs(self)
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+        del self.settings.compiler.cppstd
+        del self.settings.compiler.libcxx
+


Test patch:
diff --git a/recipes/log.c/all/test_package/CMakeLists.txt b/recipes/log.c/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/log.c/all/test_package/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package C)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(${PROJECT_NAME} example.c)
+
+conan_target_link_libraries(${PROJECT_NAME})
+
diff --git a/recipes/log.c/all/test_package/conanfile.py b/recipes/log.c/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/log.c/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class LogCTestConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/log.c/all/test_package/example.c b/recipes/log.c/all/test_package/example.c
new file mode 100644
--- /dev/null
+++ b/recipes/log.c/all/test_package/example.c
@@ -0,0 +1,6 @@
+#include <log.h>
+
+int main() {
+    log_trace("Hello %s", "world");
+	log_trace(log_level_string(0));
+}