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

infoware: added recipe #10945

Closed
wants to merge 6 commits into from
Closed
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
7 changes: 7 additions & 0 deletions recipes/infoware/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.6.0)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/infoware/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.6.0":
url: "https://github.com/ThePhD/infoware/archive/refs/tags/v0.6.0.tar.gz"
sha256: "466242836722ace03b8766ad6bd01ff4088d0360a73916834708c9133ce169b7"
61 changes: 61 additions & 0 deletions recipes/infoware/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from conans import ConanFile, CMake, tools
import os.path
import shutil

required_conan_version = ">=1.33.0"


class InfowareConan(ConanFile):
name = "infoware"
license = "CC0 1.0 Universal"
url = "https://github.com/conan-io/conan-center-index"
topics = ("infoware", "hardware")
homepage = "https://github.com/ThePhD/infoware"
description = "C++ Library for pulling system and hardware information, without hitting the command line."
settings = "os", "compiler", "build_type", "arch"
options = {
"fPIC": [True, False],
"shared": [True, False]
}
default_options = {"fPIC": True, "shared": False}
exports_sources = ["CMakeLists.txt"]
generators = ["cmake", "cmake_find_package", "cmake_find_package_multi"]

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

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

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

def _configure_cmake(self):
if self._cmake:
return self._cmake

self._cmake = CMake(self)
self._cmake.configure()

return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake.install()

self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
shutil.rmtree(os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libs.append(self.name + ("d" if self.settings.build_type == "Debug" else ""))

self.cpp_info.names["cmake_find_package"] = self.name
self.cpp_info.names["cmake_find_package_multi"] = self.name
8 changes: 8 additions & 0 deletions recipes/infoware/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/infoware/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class InfowareTestConan(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)
113 changes: 113 additions & 0 deletions recipes/infoware/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include <iostream>

#include <infoware/system.hpp>
#include <infoware/cpu.hpp>

static const char* kernel_variant_name(iware::system::kernel_t variant) noexcept {
switch(variant) {
case iware::system::kernel_t::windows_nt:
return "Windows NT";
case iware::system::kernel_t::linux:
return "Linux";
case iware::system::kernel_t::darwin:
return "Darwin";
default:
return "Unknown";
}
}

void infoware_system() {
{
std::cout << "\n"
" Connected HIDs:\n"
<< " Mice : " << iware::system::mouse_amount() << '\n'
<< " Keyboards: " << iware::system::keyboard_amount() << '\n'
<< " Other : " << iware::system::other_HID_amount() << '\n';
}

{
const auto memory = iware::system::memory();
std::cout << "\n"
" Memory:\n"
" Physical:\n"
<< " Available: " << memory.physical_available << "B\n"
<< " Total : " << memory.physical_total << "B\n"
<< " Virtual:\n"
<< " Available: " << memory.virtual_available << "B\n"
<< " Total : " << memory.virtual_total << "B\n";
}

{
const auto kernel_info = iware::system::kernel_info();
std::cout << "\n"
" Kernel:\n"
<< " Variant: " << kernel_variant_name(kernel_info.variant) << '\n'
<< " Version: " << kernel_info.major << '.' << kernel_info.minor << '.' << kernel_info.patch << " build " << kernel_info.build_number << '\n';
}

{
const auto OS_info = iware::system::OS_info();
std::cout << "\n"
" OS:\n"
<< " Name : " << OS_info.name << '\n'
<< " Full name: " << OS_info.full_name << '\n'
<< " Version : " << OS_info.major << '.' << OS_info.minor << '.' << OS_info.patch << " build " << OS_info.build_number << '\n';
}

{
const auto displays = iware::system::displays();
std::cout << "\n"
" Displays:\n";
if(displays.empty())
std::cout << " None connected or no detection method enabled\n";
else
for(auto i = 0u; i < displays.size(); ++i) {
const auto& display = displays[i];
std::cout << " #" << (i + 1) << ":\n"
<< " Resolution : " << display.width << 'x' << display.height << '\n'
<< " DPI : " << display.dpi << '\n'
<< " Colour depth: " << display.bpp << "b\n"
<< " Refresh rate: " << display.refresh_rate << "Hz\n";
}
}

{
const auto configs = iware::system::available_display_configurations();
std::cout << "\n"
" Display configurations:\n";
if(configs.empty())
std::cout << " No displays connected, no detection method enabled, or not supported\n";
else
for(auto i = 0u; i < configs.size(); ++i) {
const auto& display_configs = configs[i];
std::cout << " Display #" << (i + 1) << ":\n";

for(auto j = 0u; j < display_configs.size(); ++j) {
const auto& config = display_configs[j];
std::cout << " #" << (j + 1) << ":\n"
<< " Resolution : " << config.width << 'x' << config.height << '\n'
<< " Refresh rates: ";

bool first = true;
for(auto rate : config.refresh_rates) {
if(first)
first = false;
else
std::cout << ", ";

std::cout << rate << "Hz";
}

std::cout << '\n';
}
}
}

std::cout << '\n';
}

int main() {
infoware_system();

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