-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 gperftools package #4572
add gperftools package #4572
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"2.8.1": | ||
sha256: 12f07a8ba447f12a3ae15e6e3a6ad74de35163b787c0c7b76288d7395f2f74e0 | ||
url: https://github.com/gperftools/gperftools/releases/download/gperftools-2.8.1/gperftools-2.8.1.tar.gz |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,83 @@ | ||||||||||||||||
from conans import ConanFile, AutoToolsBuildEnvironment, tools | ||||||||||||||||
from conans.errors import ConanInvalidConfiguration | ||||||||||||||||
import os | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
class GperftoolsConan(ConanFile): | ||||||||||||||||
name = "gperftools" | ||||||||||||||||
|
||||||||||||||||
description = "Google Performance Tools" | ||||||||||||||||
topics = ("conan", "gperftools", "tcmalloc", "cpu/heap profiler") | ||||||||||||||||
url = "https://github.com/conan-io/conan-center-index" | ||||||||||||||||
homepage = "https://github.com/gperftools/gperftools" | ||||||||||||||||
license = ["BSD-3-Clause License"] | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
settings = "os", "arch", "compiler", "build_type" | ||||||||||||||||
options = { | ||||||||||||||||
"shared": [True, False], | ||||||||||||||||
"fPIC": [True, False], | ||||||||||||||||
} | ||||||||||||||||
default_options = { | ||||||||||||||||
"shared": False, | ||||||||||||||||
"fPIC": True, | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
_autotools = None | ||||||||||||||||
|
||||||||||||||||
@property | ||||||||||||||||
def _source_subfolder(self): | ||||||||||||||||
return "source_subfolder" | ||||||||||||||||
|
||||||||||||||||
def config_options(self): | ||||||||||||||||
if self.settings.os == "Windows": | ||||||||||||||||
del self.options.fPIC | ||||||||||||||||
|
||||||||||||||||
def configure(self): | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
del self.settings.compiler.libcxx | ||||||||||||||||
del self.settings.compiler.cppstd | ||||||||||||||||
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": | ||||||||||||||||
raise ConanInvalidConfiguration("gperftools is not supported by Visual Studio") | ||||||||||||||||
if self.settings.os == "Windows" and self.options.shared: | ||||||||||||||||
# libtool: error: can't build i686-pc-mingw32 shared library unless -no-undefined is specified | ||||||||||||||||
raise ConanInvalidConfiguration("gperftools can't be built as shared on Windows") | ||||||||||||||||
Comment on lines
+37
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try with CMakeLists? It could avoid msys2 build requirement (autotools are slow as hell on windows) and allow to build with Visual Studio. |
||||||||||||||||
|
||||||||||||||||
def source(self): | ||||||||||||||||
tools.get(**self.conan_data["sources"][self.version]) | ||||||||||||||||
extracted_folder = "gperftools-{0}".format(self.version) | ||||||||||||||||
os.rename(extracted_folder, self._source_subfolder) | ||||||||||||||||
|
||||||||||||||||
def build_requirements(self): | ||||||||||||||||
if tools.os_info.is_windows and not os.environ.get("CONAN_BASH_PATH"): | ||||||||||||||||
self.build_requires("msys2/20190524") | ||||||||||||||||
|
||||||||||||||||
def _configure_autotools(self): | ||||||||||||||||
if self._autotools: | ||||||||||||||||
return self._autotools | ||||||||||||||||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||||||||||||||||
args = [] | ||||||||||||||||
if self.options.shared: | ||||||||||||||||
args.extend(['--disable-static', '--enable-shared']) | ||||||||||||||||
else: | ||||||||||||||||
args.extend(['--disable-shared', '--enable-static']) | ||||||||||||||||
self._autotools.configure(configure_dir=self._source_subfolder, args=args) | ||||||||||||||||
return self._autotools | ||||||||||||||||
|
||||||||||||||||
def build(self): | ||||||||||||||||
autotools = self._configure_autotools() | ||||||||||||||||
autotools.make() | ||||||||||||||||
|
||||||||||||||||
def package(self): | ||||||||||||||||
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) | ||||||||||||||||
autotools = self._configure_autotools() | ||||||||||||||||
autotools.install() | ||||||||||||||||
|
||||||||||||||||
tools.rmdir(os.path.join(self.package_folder, 'share')) | ||||||||||||||||
tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libprofiler.la")) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libtcmalloc.la")) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libtcmalloc_and_profiler.la")) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libtcmalloc_debug.la")) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libtcmalloc_minimal.la")) | ||||||||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "libtcmalloc_minimal_debug.la")) | ||||||||||||||||
Comment on lines
+75
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
def package_info(self): | ||||||||||||||||
self.cpp_info.libs = ["tcmalloc_and_profiler"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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 not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <assert.h> | ||
#include <gperftools/tcmalloc.h> | ||
|
||
int main() | ||
{ | ||
void *p1 = tc_malloc(10); | ||
assert(p1 != NULL); | ||
|
||
tc_free(p1); | ||
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2.8.1": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.