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

bzip2 1.0.6 #6

Merged
merged 2 commits into from
Sep 3, 2019
Merged
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
62 changes: 62 additions & 0 deletions recipes/bzip2/1.0.6/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.1.2)
project(bzip2 C)

include(GNUInstallDirs)

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

if(MSVC OR MSVC90 OR MSVC10)
set(MSVC ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder)
set(BZ2_LIBRARY bz2)
set(BZ2_NAMESPACE BZip2)
set(BZ2_CONFIG ${BZ2_NAMESPACE}Config)

option(BZ2_BUILD_EXE OFF)

add_library(${BZ2_LIBRARY} ${SOURCE_SUBFOLDER}/blocksort.c
${SOURCE_SUBFOLDER}/bzlib.c
${SOURCE_SUBFOLDER}/compress.c
${SOURCE_SUBFOLDER}/crctable.c
${SOURCE_SUBFOLDER}/decompress.c
${SOURCE_SUBFOLDER}/huffman.c
${SOURCE_SUBFOLDER}/randtable.c
${SOURCE_SUBFOLDER}/bzlib.h
${SOURCE_SUBFOLDER}/bzlib_private.h)
target_include_directories(${BZ2_LIBRARY} PRIVATE ${SOURCE_SUBFOLDER})

if(BZ2_BUILD_EXE)
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_SUBFOLDER}/bzip2.c)
target_link_libraries(${CMAKE_PROJECT_NAME} ${BZ2_LIBRARY})
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${SOURCE_SUBFOLDER})
endif()

set_target_properties(${BZ2_LIBRARY} PROPERTIES VERSION ${BZ2_VERSION_STRING} SOVERSION ${BZ2_VERSION_MAJOR})

export(TARGETS ${BZ2_LIBRARY}
NAMESPACE ${BZ2_NAMESPACE}::
FILE "${CMAKE_CURRENT_BINARY_DIR}/${BZ2_CONFIG}.cmake")

install(TARGETS ${BZ2_LIBRARY}
EXPORT ${BZ2_CONFIG}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

if(BZ2_BUILD_EXE)
install(TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${BZ2_CONFIG}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()

install(FILES ${SOURCE_SUBFOLDER}/bzlib.h DESTINATION include)

install(EXPORT ${BZ2_CONFIG}
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"
NAMESPACE ${BZ2_LIBRARY}::)
5 changes: 5 additions & 0 deletions recipes/bzip2/1.0.6/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
1.0.6:
url: "https://bintray.com/conan/Sources/download_file?file_path=bzip2-1.0.6.tar.gz"
sha256: a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd
filename: bzip2-1.0.6.tar.gz
63 changes: 63 additions & 0 deletions recipes/bzip2/1.0.6/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from conans import ConanFile, CMake, tools


class Bzip2Conan(ConanFile):
name = "bzip2"
version = "1.0.6"
url = "https://github.com/conan-community/conan-bzip2"
homepage = "http://www.bzip.org"
author = "Conan Community"
license = "bzip2-1.0.6"
description = "bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm."
topics = ("conan", "bzip2", "data-compressor", "file-compression")
settings = "os", "compiler", "arch", "build_type"
options = {"shared": [True, False], "fPIC": [True, False], "build_executable": [True, False]}
default_options = {"shared": False, "fPIC": True, "build_executable": True}
exports = "LICENSE"
exports_sources = "CMakeLists.txt"
generators = "cmake"

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

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

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def source(self):
tools.get(**self.conan_data["sources"][self.version])
folder_name = "%s-%s" % (self.name, self.version)
os.rename(folder_name, self._source_subfolder)

def _configure_cmake(self):
major = self.version.split(".")[0]
cmake = CMake(self)
cmake.definitions["BZ2_VERSION_STRING"] = self.version
cmake.definitions["BZ2_VERSION_MAJOR"] = major
cmake.definitions["BZ2_BUILD_EXE"] = "ON" if self.options.build_executable else "OFF"
cmake.configure()
return cmake

def build(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "bzip2.c"), r"<sys\stat.h>", "<sys/stat.h>")
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))


def package_info(self):
self.cpp_info.libs = ['bz2']
8 changes: 8 additions & 0 deletions recipes/bzip2/1.0.6/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PROJECT(test_package C)
cmake_minimum_required(VERSION 2.8)

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

ADD_EXECUTABLE(test_package test_package.c)
target_link_libraries(test_package ${CONAN_LIBS})
24 changes: 24 additions & 0 deletions recipes/bzip2/1.0.6/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from conans import ConanFile, CMake, tools


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

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
assert os.path.isfile(os.path.join(self.deps_cpp_info["bzip2"].rootpath, "licenses", "LICENSE"))
if tools.cross_building(self.settings):
self.output.warn("Skipping run cross built package")
return

bin_path = os.path.join("bin", "test_package")
self.run("%s --help" % bin_path, run_environment=True)
Loading