Skip to content

Commit

Permalink
(conan-io#5240) add panzi/portable_endian.h
Browse files Browse the repository at this point in the history
* 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
3 people authored Apr 24, 2021
1 parent 849da23 commit 4c258ca
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/panzi-portable-endian/all/conandata.yml
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"
34 changes: 34 additions & 0 deletions recipes/panzi-portable-endian/all/conanfile.py
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 recipes/panzi-portable-endian/all/test_package/CMakeLists.txt
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 recipes/panzi-portable-endian/all/test_package/conanfile.py
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)
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);
}
3 changes: 3 additions & 0 deletions recipes/panzi-portable-endian/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20150416":
folder: all

0 comments on commit 4c258ca

Please sign in to comment.