diff --git a/recipes/gperftools/all/conandata.yml b/recipes/gperftools/all/conandata.yml new file mode 100644 index 0000000000000..1a1c4422d90c8 --- /dev/null +++ b/recipes/gperftools/all/conandata.yml @@ -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 diff --git a/recipes/gperftools/all/conanfile.py b/recipes/gperftools/all/conanfile.py new file mode 100644 index 0000000000000..0106f695c7e2d --- /dev/null +++ b/recipes/gperftools/all/conanfile.py @@ -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"] + 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): + 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") + + 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")) + + def package_info(self): + self.cpp_info.libs = ["tcmalloc_and_profiler"] diff --git a/recipes/gperftools/all/test_package/CMakeLists.txt b/recipes/gperftools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34af13462f44f --- /dev/null +++ b/recipes/gperftools/all/test_package/CMakeLists.txt @@ -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}) diff --git a/recipes/gperftools/all/test_package/conanfile.py b/recipes/gperftools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..bd7165a553cf4 --- /dev/null +++ b/recipes/gperftools/all/test_package/conanfile.py @@ -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) diff --git a/recipes/gperftools/all/test_package/test_package.c b/recipes/gperftools/all/test_package/test_package.c new file mode 100644 index 0000000000000..078dc16ecfcae --- /dev/null +++ b/recipes/gperftools/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include +#include + +int main() +{ + void *p1 = tc_malloc(10); + assert(p1 != NULL); + + tc_free(p1); + + return 0; +} + diff --git a/recipes/gperftools/config.yml b/recipes/gperftools/config.yml new file mode 100644 index 0000000000000..bfdd25761a483 --- /dev/null +++ b/recipes/gperftools/config.yml @@ -0,0 +1,3 @@ +versions: + "2.8.1": + folder: all