Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Apr 10, 2020
2 parents 6a28ebb + 244bbaf commit 0372d1f
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 15 deletions.
26 changes: 26 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from conans import ConanFile, tools
class SpyConan(ConanFile):
name = "spy"
settings = "os", "compiler", "build_type", "arch"
version = "0.0.3"
license = "MIT"
author = "Joel FALCOU joel.falcou@compilaction.net"
url = "https://github.com/jfalcou/spy.git"
homepage = "https://jfalcou.github.io/spy/"
description = "C++ 17 for constexpr-proof detection and classification of informations about OS, compiler, etc..."
topics = ("c++17", "config", "metaprogramming")
no_copy_source = True
scm = {
"type": "git",
"url": "auto",
"revision": "auto"
}

def package(self):
self.copy("LICENSE", "licenses")
self.copy("*.hpp")

def package_id(self):
self.info.header_only()
30 changes: 15 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

int main()
{
std::cout << spy::os << std::endl;
std::cout << spy::operating_system << std::endl;
std::cout << spy::architecture << std::endl;
std::cout << spy::simd_instruction_set << std::endl;
std::cout << spy::compiler << std::endl;
Expand All @@ -67,7 +67,7 @@
SPY can detect:

- Architecture family via the `spy::architecture` object.
- OS vendor via the `spy::os` object.
- OS vendor via the `spy::operating_system` object.
- Compiler vendor and version (in the M.N.P format) via the `spy::compiler` object.
- libc vendor and version (in the M.N.P format) via the `spy::libc` object.
- stdlib vendor and version (in the M.N.P format) via the `spy::stdlib` object.
Expand All @@ -82,11 +82,11 @@

int main()
{
std::cout << spy::os << "\n";
std::cout << spy::architecture << "\n";
std::cout << spy::compiler << "\n";
std::cout << spy::stdlib << "\n";
std::cout << spy::libc << "\n";
std::cout << spy::operating_system << "\n";
std::cout << spy::architecture << "\n";
std::cout << spy::compiler << "\n";
std::cout << spy::stdlib << "\n";
std::cout << spy::libc << "\n";
}
~~~~~
</script>
Expand All @@ -96,13 +96,13 @@
so you can branch off your code based on this informations. Here is the list of each detected
vendor for each SPY objects.

| Detector | Supported vendor |
| ------------------- | ------------------------------------------------------------------------------ |
| `spy::architecture` | `x86_`, `amd64_`, `ppc_`, `arm_` |
| `spy::os` | `android_`, `bsd_`, `cygwin_`, `ios_`, `linux_`, `macos_`, `unix_`, `windows_` |
| `spy::compiler` | `clang_`, `gcc_`, `intel_`, `msvc_` |
| `spy::libc` | `cloudabi_`, `gnu_` `uc_`, `vms_`, `zos_` |
| `spy::stdlib` | `gnucpp_`, `libcpp_` |
| Detector | Supported vendor |
| ----------------------- | ------------------------------------------------------------------------------ |
| `spy::architecture` | `x86_`, `amd64_`, `ppc_`, `arm_` |
| `spy::operating_system` | `android_`, `bsd_`, `cygwin_`, `ios_`, `linux_`, `macos_`, `unix_`, `windows_` |
| `spy::compiler` | `clang_`, `gcc_`, `intel_`, `msvc_` |
| `spy::libc` | `cloudabi_`, `gnu_` `uc_`, `vms_`, `zos_` |
| `spy::stdlib` | `gnucpp_`, `libcpp_` |

Here is a sample code comparing some detectors to a specific vendor:

Expand All @@ -113,7 +113,7 @@

void f()
{
if constexpr( spy::os == spy::windows_ )
if constexpr( spy::operating_system == spy::windows_ )
{
std::cout << "This code is Windows only.\n";
}
Expand Down
17 changes: 17 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 2.8.12)
project(PackageTest CXX)

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

add_library(spy_config INTERFACE)
target_compile_features ( spy_config INTERFACE cxx_std_17 )

add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS} PUBLIC spy_config)

# CTest is a testing tool that can be used to test your project.
# enable_testing()
# add_test(NAME example
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# COMMAND example)
25 changes: 25 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os

from conans import ConanFile, CMake, tools


class SpyTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
# in "test_package"
cmake.configure()
cmake.build()

def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')

def test(self):
if not tools.cross_building(self.settings):
os.chdir("bin")
self.run(".%sexample" % os.sep)
12 changes: 12 additions & 0 deletions test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <spy/spy.hpp>

int main()
{
std::cout << spy::operating_system << std::endl;
std::cout << spy::architecture << std::endl;
std::cout << spy::simd_instruction_set << std::endl;
std::cout << spy::compiler << std::endl;
std::cout << spy::libc << std::endl;
std::cout << spy::stdlib << std::endl;
}

0 comments on commit 0372d1f

Please sign in to comment.