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 10 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
1 change: 0 additions & 1 deletion recipes/libbacktrace/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sources:
"1.0":
url: "https://github.com/ianlancetaylor/libbacktrace.git"
revision: "master"
15 changes: 14 additions & 1 deletion recipes/libbacktrace/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from conans import AutoToolsBuildEnvironment, ConanFile
import os

from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conans.errors import ConanInvalidConfiguration


class LibbacktraceConan(ConanFile):
Expand All @@ -13,13 +16,19 @@ class LibbacktraceConan(ConanFile):
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

build_requires = "autoconf/2.69", "libtool/2.4.6"

__autotools = None

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

def configure(self):
if self.settings.compiler == "Visual Studio":
raise ConanInvalidConfiguration(
"libbacktrace doesn't support compiler: {} on OS: {}.".format(
self.settings.compiler, self.settings.os))
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
Expand All @@ -35,6 +44,7 @@ def scm(self):
def _autotools(self):
if self.__autotools:
return self.__autotools
self.run("autoreconf -fiv", run_environment=True)
self.__autotools = AutoToolsBuildEnvironment(self)
if self.options.shared:
args = ["--enable-shared", "--disable-static"]
Expand All @@ -49,6 +59,9 @@ def build(self):
def package(self):
self._autotools.install()
self.copy("LICENSE", dst="licenses")
la = os.path.join(self.package_folder, "lib", "libbacktrace.la")
if os.path.exists(la):
os.unlink(la)

def package_info(self):
self.cpp_info.libs = ["backtrace"]
15 changes: 11 additions & 4 deletions recipes/libbacktrace/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <unistd.h>

void
error_callback_create(void* data, const char* msg, int errnum)
error_callback(void* data, const char* msg, int errnum)
{
fprintf(stderr, "%s", msg);
if (errnum > 0)
Expand All @@ -15,14 +15,21 @@ error_callback_create(void* data, const char* msg, int errnum)
exit(EXIT_FAILURE);
}

int
simple_callback(void* data, uintptr_t pc)
{
printf("0x%016lx\n", pc);
return 0;
}

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);
state = backtrace_create_state(argv[0], BACKTRACE_SUPPORTS_THREADS, error_callback, NULL);
printf("Simple backtrace:\n");
backtrace_simple(state, 0, simple_callback, error_callback, NULL);

return 0;
}