Skip to content

stacktrace: add version 1.0.0 #26599

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions recipes/stacktrace/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, download

required_conan_version = ">=2.0"


class PackageConan(ConanFile):
name = "stacktrace"
description = "Print stack backtrace programmatically with demangled function names"
license = "WTFPL"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://panthema.net/2008/0901-stacktrace-demangled/"
topics = ("stacktrace", "backtrace", "backtrace_symbols", "demangle", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

def source(self):
download(
self,
url="https://panthema.net/2008/0901-stacktrace-demangled/stacktrace.h",
filename="stacktrace.h",
sha256="f850b0b859595f26121ccc9c8b9a82d9ed9acfe35fdea01554b257e95301310b",
)

def export_sources(self):
copy(self, "stacktrace.h", self.recipe_folder, self.export_sources_folder)

def package_id(self):
self.info.clear()

def validate(self):
check_min_cppstd(self, 98)
if str(self.settings.compiler) not in ["gcc", "clang"]:
raise ConanInvalidConfiguration(
f"{self.ref} does only demangle gcc and clang properly."
)
if self.settings.os == "Windows":
raise ConanInvalidConfiguration(f"{self.ref} might not compile on Windows.")

def build(self):
pass

def package(self):
copy(
self,
"stacktrace.h",
self.source_folder,
os.path.join(self.package_folder, "include"),
)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
7 changes: 7 additions & 0 deletions recipes/stacktrace/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(stacktrace REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE stacktrace::stacktrace)
25 changes: 25 additions & 0 deletions recipes/stacktrace/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


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

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

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

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
38 changes: 38 additions & 0 deletions recipes/stacktrace/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "stacktrace.h"
#include <map>

namespace Nu {

template<typename Type>
struct Alpha {
struct Beta {
void func() {
print_stacktrace();
}
void func(Type) {
print_stacktrace();
}
};
};

struct Gamma {
template <int N>
void unroll(double d) {
unroll<N-1>(d);
}
};

template<>
void Gamma::unroll<0>(double) {
print_stacktrace();
}

} // namespace Nu

int main(void) {
Nu::Alpha<int>::Beta().func(42);
Nu::Alpha<char*>::Beta().func("42");
Nu::Alpha< Nu::Alpha< std::map<int, double> > >::Beta().func();
Nu::Gamma().unroll<5>(42.0);
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/stacktrace/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.0.0":
folder: all