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

Libjwt #26459

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions recipes/libjwt/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources:
"1.18.3":
url: "https://github.com/benmcollins/libjwt/archive/refs/tags/v1.18.3.zip"
82 changes: 82 additions & 0 deletions recipes/libjwt/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from conan import ConanFile, conan_version
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import get
from conan.tools.system import package_manager
from conan.tools.scm import Version


class libjwtRecipe(ConanFile):
name = "libjwt"
package_type = "library"

# Optional metadata
license = "Mozilla Public License Version 2.0"
author = "Ben Collins"
url = "https://github.com/benmcollins/libjwt"
description = "The C JSON Web Token Library +JWK +JWKS"
topics = ("json", "jwt", "jwt-token")

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

def source(self):
get(self, self.conan_data["sources"][self.version]["url"], strip_root=True)

def requirements(self):
self.requires("openssl/3.3.2")
self.requires("jansson/2.14")

def system_requirements(self):
apt = package_manager.Apt(self)
apt.install(["libjansson-dev"], update=True, check=True)

yum = package_manager.Yum(self)
yum.install(["jansson-devel"], update=True, check=True)

dnf = package_manager.Dnf(self)
dnf.install(["jansson-devel"], update=True, check=True)

zypper = package_manager.Zypper(self)
zypper.install(["libjansson-devel"], update=True, check=True)

pacman = package_manager.PacMan(self)
pacman.install(["jansson"], update=True, check=True)

pkg = package_manager.Pkg(self)
pkg.install(["jansson"], update=True, check=True)

if Version(conan_version) >= "2.0.10":
alpine = package_manager.Apk(self)
alpine.install(["jansson"], update=True, check=True)

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self)

def generate(self):
cmakeDeps = CMakeDeps(self)
cmakeDeps.generate()

tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["jwt"]
9 changes: 9 additions & 0 deletions recipes/libjwt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

find_package(libjwt CONFIG REQUIRED)



add_executable(example src/example.cpp)
target_link_libraries(example libjwt::libjwt)
26 changes: 26 additions & 0 deletions recipes/libjwt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run


class libjwtTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
13 changes: 13 additions & 0 deletions recipes/libjwt/all/test_package/src/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "jwt.h"

int main() {

jwt_t *jwt = NULL;
int ret = 0;

ret = jwt_new(&jwt);

jwt_free(jwt);

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