Skip to content

Commit

Permalink
add tllist library
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebedo committed Dec 30, 2021
1 parent 5d5347b commit 682ad99
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
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
56 changes: 56 additions & 0 deletions recipes/tllist/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os

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

required_conan_version = ">=1.33.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")
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]", "meson/[>=0.60.3]")

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()
16 changes: 16 additions & 0 deletions recipes/tllist/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, Meson, tools
import os


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

def build(self):
meson = Meson(self)
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"

0 comments on commit 682ad99

Please sign in to comment.