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

Conan Support #412

Closed
IronTony-Stark opened this issue Feb 16, 2023 · 4 comments
Closed

Conan Support #412

IronTony-Stark opened this issue Feb 16, 2023 · 4 comments

Comments

@IronTony-Stark
Copy link

Let me start by saying thank you :)

I've been using jsoncons in my several pet projects and so far it's been great. The only thing I wish it had at the moment is Conan support.

Describe the proposed feature

Conan is a C++ package and dependency manager similar to vcpkg. However, in my experience Conan is more powerful, thus I prefer it more.

Conan can be easily installed on any platform using pip install conan.

For more details on Conan usage, don't hesitate to ask me or refer to Conan's docs.

What other libraries (C++ or other) have this feature?

For example, Rapidjson supports Conan. Here are the links to JFrog ConanCenter and to conan-center-index

Include a code fragment with sample data that illustrates the use of this feature

I've created and tested locally the following conanfile.py.

# conanfile.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, tools
import os


class JsonconsConan(ConanFile):
    name = "jsoncons"
    version = "0.169.0"
    description = "A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON "
    homepage = "https://github.com/danielaparker/jsoncons"
    url = "https://github.com/danielaparker/jsoncons"
    author = "Daniel Parker danielaparker@yahoo.com"
    license = "Boost Software License"
    exports = ["LICENSE.md"]
    no_copy_source = True
    source_subfolder = "source_subfolder"

    def source(self):
        tools.get(f"https://github.com/danielaparker/jsoncons/archive/refs/tags/v{self.version}.tar.gz")
        extracted_dir = self.name + "-" + self.version
        os.rename(extracted_dir, self.source_subfolder)

    def package(self):
        include_folder = os.path.join(self.source_subfolder, "include")
        self.copy(pattern="LICENSE", dst="licenses", src=self.source_subfolder)
        self.copy(pattern="*", dst="include", src=include_folder)

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

Using the above-mentioned Conan recipe (conanfile.py), one can install jsoncons using the following commands:

# initial setup
conan install . jsoncons/<version>@
# download the sources
conan source .
# package the sources
conan package . --package-folder="package"
# export the package to conan cache so that it could be used by other projects
conan export-pkg . jsoncons/<version>@ --package-folder=package

What needs to be done

No changes in this repo are required to add Conan support. The only thing necessary is to upload the above-mentioned conanfile.py to conan-center-index.

Then everybody will be able to install jsoncons with just conan install jsoncons/<version>@ - as easy as that!

I'm willing to do everything necessary myself but before I start I wanted to ask for your permission first. This is the primary purpose of this feature request.

Don't hesitate to ask me should you have any questions. Thank you for your time :)

@economicseries
Copy link

@IronTony-Stark,

I would be happy for you to do everything yourself :-)

Best regards,
Daniel

@Wyverex42
Copy link

Hi @IronTony-Stark, is there an update on this? Having this available in Conan would be huge!

Thank you!

@IronTony-Stark
Copy link
Author

Hi @Wyverex42!
It's in progress. Unfortunately, I got caught up with my personal stuff and don't have much time at the moment. But I really hope to get it done next week, maybe we will need another week for approval.
You can monitor the progress here conan-io/conan-center-index#16256

@IronTony-Stark
Copy link
Author

@economicseries @Wyverex42 done 🥳

You should be able to install jsoncons with conan install jsoncons/0.169.0@

Note however that for every new version of jsoncons, you will have to update the package in conan-center-index as well. But that should be pretty trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants