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

Add libbacktrace/1.0 #4431

Merged
merged 20 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions recipes/libbacktrace/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.0":
url: "https://github.com/ianlancetaylor/libbacktrace.git"
revision: "master"
54 changes: 54 additions & 0 deletions recipes/libbacktrace/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from conans import AutoToolsBuildEnvironment, ConanFile


class LibbacktraceConan(ConanFile):
name = "libbacktrace"
description = "A C library that may be linked into a C/C++ program to produce symbolic backtraces."
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ianlancetaylor/libbacktrace"
license = "BSD-3-Clause"
topics = ("conan", "backtrace", "stack-trace")

settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

__autotools = None

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

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

@property
def scm(self):
source = {"type": "git"}
source.update(**self.conan_data["sources"][self.version])
return source

@property
def _autotools(self):
if self.__autotools:
return self.__autotools
self.__autotools = AutoToolsBuildEnvironment(self)
if self.options.shared:
args = ["--enable-shared", "--disable-static"]
else:
args = ["--disable-shared", "--enable-static"]
self.__autotools.configure(args=args)
return self.__autotools

def build(self):
self._autotools.make()

def package(self):
self._autotools.install()
self.copy("LICENSE", dst="licenses")

def package_info(self):
self.cpp_info.libs = ["backtrace"]
8 changes: 8 additions & 0 deletions recipes/libbacktrace/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 C)

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

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


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 tools.cross_building(self.settings):
return
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
28 changes: 28 additions & 0 deletions recipes/libbacktrace/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <backtrace-supported.h>
#include <backtrace.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void
error_callback_create(void* data, const char* msg, int errnum)
{
fprintf(stderr, "%s", msg);
if (errnum > 0)
fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n");
exit(EXIT_FAILURE);
}

int
main(int argc, char** argv)
{
void* state;

state = backtrace_create_state(argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
backtrace_print(state, 0, stdout);

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