Skip to content

Commit 9906aae

Browse files
AiyionPrimebingmann
andcommitted
stacktrace: add version 1.0.0
Co-authored-by: Timo Bingmann <[email protected]>
1 parent 36b98c4 commit 9906aae

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-0
lines changed

recipes/stacktrace/all/conanfile.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
3+
from conan import ConanFile
4+
from conan.errors import ConanInvalidConfiguration
5+
from conan.tools.build import check_min_cppstd
6+
from conan.tools.files import copy, download
7+
from conan.tools.layout import basic_layout
8+
9+
required_conan_version = ">=2.0"
10+
11+
12+
class PackageConan(ConanFile):
13+
name = "stacktrace"
14+
version = "1.0"
15+
description = "Print stack backtrace programmatically with demangled function names"
16+
license = "WTFPL"
17+
url = "https://github.com/conan-io/conan-center-index"
18+
homepage = "https://panthema.net/2008/0901-stacktrace-demangled/"
19+
topics = ("stacktrace", "backtrace", "backtrace_symbols", "demangle", "header-only")
20+
package_type = "header-library"
21+
settings = "os", "arch", "compiler", "build_type"
22+
no_copy_source = True
23+
24+
def source(self):
25+
download(
26+
self,
27+
url="https://panthema.net/2008/0901-stacktrace-demangled/stacktrace.h",
28+
filename="stacktrace.h",
29+
sha256="f850b0b859595f26121ccc9c8b9a82d9ed9acfe35fdea01554b257e95301310b",
30+
)
31+
32+
def export_sources(self):
33+
copy(self, "stacktrace.h", self.recipe_folder, self.export_sources_folder)
34+
35+
def package_id(self):
36+
self.info.clear()
37+
38+
def validate(self):
39+
check_min_cppstd(self, 98)
40+
if str(self.settings.compiler) not in ["gcc", "clang"]:
41+
raise ConanInvalidConfiguration(
42+
f"{self.ref} does only demangle gcc and clang properly."
43+
)
44+
if self.settings.os == "Windows":
45+
raise ConanInvalidConfiguration(f"{self.ref} might not compile on Windows.")
46+
47+
def build(self):
48+
pass
49+
50+
def package(self):
51+
copy(
52+
self,
53+
"stacktrace.h",
54+
self.source_folder,
55+
os.path.join(self.package_folder, "include"),
56+
)
57+
58+
def package_info(self):
59+
self.cpp_info.bindirs = []
60+
self.cpp_info.libdirs = []
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(test_package LANGUAGES CXX)
3+
4+
find_package(stacktrace REQUIRED CONFIG)
5+
6+
add_executable(${PROJECT_NAME} test_package.cpp)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE stacktrace::stacktrace)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
4+
import os
5+
6+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "arch", "compiler", "build_type"
9+
generators = "CMakeDeps", "CMakeToolchain"
10+
11+
def layout(self):
12+
cmake_layout(self)
13+
14+
def requirements(self):
15+
self.requires(self.tested_reference_str)
16+
17+
def build(self):
18+
cmake = CMake(self)
19+
cmake.configure()
20+
cmake.build()
21+
22+
def test(self):
23+
if can_run(self):
24+
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
25+
self.run(bin_path, env="conanrun")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "stacktrace.h"
2+
#include <map>
3+
4+
namespace Nu {
5+
6+
template<typename Type>
7+
struct Alpha {
8+
struct Beta {
9+
void func() {
10+
print_stacktrace();
11+
}
12+
void func(Type) {
13+
print_stacktrace();
14+
}
15+
};
16+
};
17+
18+
struct Gamma {
19+
template <int N>
20+
void unroll(double d) {
21+
unroll<N-1>(d);
22+
}
23+
};
24+
25+
template<>
26+
void Gamma::unroll<0>(double) {
27+
print_stacktrace();
28+
}
29+
30+
} // namespace Nu
31+
32+
int main(void) {
33+
Nu::Alpha<int>::Beta().func(42);
34+
Nu::Alpha<char*>::Beta().func("42");
35+
Nu::Alpha< Nu::Alpha< std::map<int, double> > >::Beta().func();
36+
Nu::Gamma().unroll<5>(42.0);
37+
return EXIT_SUCCESS;
38+
}

recipes/stacktrace/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"1.0.0":
3+
folder: all

0 commit comments

Comments
 (0)