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 tllist library #8588

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions recipes/tllist/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.0.5":
url: "https://codeberg.org/dnkl/tllist/archive/1.0.5.tar.gz"
sha256: b0f32c9b2c2015c8d8dd068fd4e8b586aa91ca1670badc274ec962559ee0aadd
62 changes: 62 additions & 0 deletions recipes/tllist/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os

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

required_conan_version = ">=1.43.0"


class TllistConan(ConanFile):
name = "tllist"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://codeberg.org/dnkl/tllist"
description = "A C header file only implementation of a typed linked list."
topics = ("list", "utils", "tllist")
generators = ("pkg_config")
settings = "os", "arch", "build_type"
no_copy_source = True
_meson = None

@property
def _source_subfolder(self):
return "source_subfolder"

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("Only Linux supported")

def build_requirements(self):
self.build_requires("pkgconf/[>=1.7.4]")
self.build_requires("meson/[>=0.60.0]")
self.build_requires("ninja/[>=1.10.0]")

Comment on lines +30 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use version ranges here

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_meson(self):
if self._meson:
return self._meson
self._meson = Meson(self)
self._meson.configure(source_folder=self._source_subfolder)
return self._meson

def build(self):
meson = self._configure_meson()
meson.build()
meson.test()

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
meson = self._configure_meson()
meson.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

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

def package_info(self):
self.cpp_info.includedirs.append(os.path.join("include"))

21 changes: 21 additions & 0 deletions recipes/tllist/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from conans import ConanFile, Meson, tools
import os


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

def build_requirements(self):
self.build_requires("pkgconf/[>=1.7.4]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use version ranges, but as it's a test_package, should be harmless?

self.build_requires("meson/[>=0.60.0]")
self.build_requires("ninja/[>=1.10.0]")

def build(self):
meson = Meson(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meson-based test package, something unusual, but still welcomed!

meson.configure()
meson.build()

def test(self):
bin_path = os.path.join(".", "test_package")
self.run(bin_path, run_environment=True)
4 changes: 4 additions & 0 deletions recipes/tllist/all/test_package/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project('test_package', 'c')
tllist = dependency('tllist')

executable('test_package', 'test_package.c', dependencies : tllist)
10 changes: 10 additions & 0 deletions recipes/tllist/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdlib.h>
#include <tllist.h>

int main(int argc, const char *const *argv) {
tll(int) l = tll_init();

tll_push_back(l, 43);

return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/tllist/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.0.5":
folder: "all"