forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#5240) add panzi/portable_endian.h
* add panzi/portable_endian.h * fix test compiler error * Update recipes/panzi_portable_endian/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> * Update recipes/panzi_portable_endian/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> * rename panzi_portable_endian to panzi-portable-endian * use strip_root * Update recipes/panzi-portable-endian/all/test_package/conanfile.py Co-authored-by: Anonymous Maarten <[email protected]> * Update recipes/panzi-portable-endian/all/test_package/conanfile.py Co-authored-by: Anonymous Maarten <[email protected]> Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Anonymous Maarten <[email protected]>
- Loading branch information
1 parent
849da23
commit 4c258ca
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20150416": | ||
url: "https://gist.github.com/panzi/6856583/archive/1eca2ab34f2301b9641aa73d1016b951fff3fc39.zip" | ||
sha256: "488d5d08215f657e769b31764013ef845355832cc6f1d165e1809fa5fe168eeb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from conans import ConanFile, tools | ||
|
||
|
||
class PanziPortableEndian(ConanFile): | ||
name = "panzi-portable-endian" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://gist.github.com/panzi/6856583" | ||
description = "This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X" | ||
topics = ("conan", "endian") | ||
license = "Unlicense" | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def _extract_license(self): | ||
header = tools.load(os.path.join( | ||
self._source_subfolder, "portable_endian.h")) | ||
license_contents = header[0:(header.find("#ifndef", 1))] | ||
tools.save("LICENSE", license_contents) | ||
|
||
def package(self): | ||
self._extract_license() | ||
self.copy("LICENSE", dst="licenses") | ||
self.copy(pattern="*.h", dst="include", | ||
src=self._source_subfolder, keep_path=False) | ||
|
||
def package_id(self): | ||
self.info.header_only() |
9 changes: 9 additions & 0 deletions
9
recipes/panzi-portable-endian/all/test_package/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) |
17 changes: 17 additions & 0 deletions
17
recipes/panzi-portable-endian/all/test_package/conanfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class TestPackageConan(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.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
8 changes: 8 additions & 0 deletions
8
recipes/panzi-portable-endian/all/test_package/test_package.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <cstdint> | ||
|
||
#include <portable_endian.h> | ||
|
||
int main() { | ||
uint64_t num = 100; | ||
le64toh(num); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20150416": | ||
folder: all |