Skip to content

packaging: update conan and vcpkg #40

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ a.out
reports/
.venv/
packaging/conan/test_package/build/
packaging/conan/test_package/CMakeUserPresets.json
packaging/conan/test_package/CMakeUserPresets.json
*.pyc
9 changes: 3 additions & 6 deletions packaging/conan/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
sources:
"1.0.1":
url: "https://github.com/lucocozz/cargs/archive/refs/tags/v1.0.1.tar.gz"
sha256: "d709ab4d3d338693a1ba5c3e685fa5ee2d2ef37bb92a1038c03a11f2d6d3dcd8"
"1.0.0":
url: "https://github.com/lucocozz/cargs/archive/refs/tags/v1.0.0.tar.gz"
sha256: "387315fe54f7ce51f4c7176fce4e65e4876a58893a8e516ad1d58209136cde19"
"1.0.2":
url: "https://github.com/lucocozz/cargs/archive/refs/tags/v1.0.2.tar.gz"
sha256: "15c64c271a109030538e3cb88a6fade49021a05f99bc372edd40fba2ec4cf0b5"
23 changes: 15 additions & 8 deletions packaging/conan/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from conan.tools.layout import basic_layout
import os

class LibcargsConan(ConanFile):
name = "libcargs"
version = "1.0.1"
class LucocozzCargsConan(ConanFile):
name = "lucocozz-cargs"
version = "1.0.2"
description = "Modern C library for command-line argument parsing with an elegant, macro-based API"
topics = ("conan", "cargs", "libcargs", "command-line", "arguments", "parser", "cli", "argparse")
topics = ("conan", "cargs", "lucocozz-cargs", "command-line", "arguments", "parser", "cli", "argparse")
url = "https://github.com/lucocozz/cargs"
homepage = "https://github.com/lucocozz/cargs"
license = "MIT"
Expand Down Expand Up @@ -39,7 +39,7 @@ def layout(self):

def requirements(self):
if not self.options.disable_regex:
self.requires("pcre2/10.42")
self.requires("pcre2/[>=10.40]")

def build_requirements(self):
self.tool_requires("meson/[>=1.0.0]")
Expand All @@ -51,7 +51,7 @@ def source(self):
def generate(self):
tc = MesonToolchain(self)
tc.project_options["buildtype"] = str(self.settings.build_type).lower()
tc.project_options["disable_regex"] = self.options.disable_regex
tc.project_options["disable_regex"] = bool(self.options.disable_regex)
tc.project_options["tests"] = False
tc.project_options["examples"] = False
tc.project_options["benchmarks"] = False
Expand All @@ -70,12 +70,19 @@ def package(self):
meson.install()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "libcargs")
self.cpp_info.set_property("cmake_target_name", "libcargs::libcargs")
self.cpp_info.set_property("cmake_file_name", "lucocozz-cargs")
self.cpp_info.set_property("cmake_target_name", "lucocozz-cargs::lucocozz-cargs")
self.cpp_info.libs = ["cargs"]

if not self.options.disable_regex:
# Make sure PCRE2 is linked correctly
self.cpp_info.requires = ["pcre2::pcre2"]

if self.options.disable_regex:
self.cpp_info.defines.append("CARGS_NO_REGEX")

if self.settings.os == "Linux":
self.cpp_info.system_libs.append("m")

self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("pkg_config_name", "cargs")
4 changes: 2 additions & 2 deletions packaging/conan/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package C)

find_package(libcargs REQUIRED)
find_package(lucocozz-cargs REQUIRED)

add_executable(test_package test_package.c)
target_link_libraries(test_package libcargs::libcargs)
target_link_libraries(test_package lucocozz-cargs::lucocozz-cargs)
4 changes: 2 additions & 2 deletions packaging/conan/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout

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

Expand All @@ -22,5 +22,5 @@ def test(self):
if self.settings.os == "Windows":
return
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "test_package")
cmd = os.path.join(self.build_folder, "test_package")
self.run(f"{cmd} -v", env="conanrun")
2 changes: 1 addition & 1 deletion packaging/conan/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char **argv)
printf("Test package ran successfully!\n");
printf(" Verbose: %s\n", verbose ? "yes" : "no");
printf(" Output: %s\n", output);

cargs_free(&cargs);
return 0;
}
9 changes: 0 additions & 9 deletions packaging/vcpkg/libcargs.json

This file was deleted.

9 changes: 9 additions & 0 deletions packaging/vcpkg/lucocozz-cargs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "2b016c569e19d960bd2d26aefe695c69c57192a8",
"version": "1.0.2",
"port-version": 0
}
]
}
2 changes: 1 addition & 1 deletion packaging/vcpkg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO lucocozz/cargs
REF v${VERSION}
SHA512 74bb7eebb1f328d3b27c51c2cec74f87b0a11fd7c801bb3d2d4b56b8ed7448461043f8f01b68f69cee67c2c73217ebb8b641a5e76a632052910ddb13b750045f
SHA512 40780e98a72fa225bdde62d45b349f558bfd32171f65393fdd8eb0da1566cb0c0083adbea620452a8bf8ff960898e216674612b94b2a556b07498a8fd7dd10d3
HEAD_REF main
)

Expand Down
4 changes: 2 additions & 2 deletions packaging/vcpkg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libcargs",
"version": "1.0.1",
"name": "lucocozz-cargs",
"version": "1.0.2",
"description": "Modern C library for command-line argument parsing with an elegant, macro-based API",
"homepage": "https://github.com/lucocozz/cargs",
"license": "MIT",
Expand Down
82 changes: 82 additions & 0 deletions tools/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env python3
"""
version.py - Modern version management for the cargs library
"""

import argparse
import os
import sys
from typing import Optional

from version_core import Version, VersionBump, VersionManager


def main():
"""Parse command line arguments and execute requested actions"""
parser = argparse.ArgumentParser(description="cargs version management tool")

parser.add_argument("--dry-run", action="store_true", help="Show what would be done without making changes")
parser.add_argument("-v", "--verbose", action="store_true", help="Show detailed output")

subparsers = parser.add_subparsers(dest="command", required=True)

get_parser = subparsers.add_parser("get", help="Get the current version")

bump_parser = subparsers.add_parser("bump", help="Bump the version")
bump_parser.add_argument("type", choices=["major", "minor", "patch"], help="Type of version bump")

set_parser = subparsers.add_parser("set", help="Set a specific version")
set_parser.add_argument("version", help="New version (X.Y.Z)")

release_parser = subparsers.add_parser("release", help="Perform a complete release")
version_group = release_parser.add_mutually_exclusive_group(required=True)
version_group.add_argument("--bump", choices=["major", "minor", "patch"], help="Bump version by major, minor, or patch")
version_group.add_argument("--version", help="Set specific version (X.Y.Z)")

release_parser.add_argument("--skip-tag", action="store_true", help="Skip creating git tag")
release_parser.add_argument("--skip-packages", action="store_true", help="Skip updating package managers")
release_parser.add_argument("--skip-changelog", action="store_true", help="Skip updating changelog")
release_parser.add_argument("--skip-github-release", action="store_true", help="Skip creating GitHub release")
release_parser.add_argument("--conan-path", help="Path to conan-center-index repository")
release_parser.add_argument("--vcpkg-path", help="Path to vcpkg repository")

args = parser.parse_args()

# Initialize version manager
version_manager = VersionManager(dry_run=args.dry_run, verbose=args.verbose)

# Execute command
if args.command == "get":
print(f"Current version: {version_manager.current_version}")

elif args.command == "bump":
bump_type = VersionBump(args.type)
new_version = version_manager.current_version.bump(bump_type)
version_manager.update_version(new_version)

elif args.command == "set":
new_version = Version.from_string(args.version)
version_manager.update_version(new_version)

elif args.command == "release":
# Determine the new version
if args.version:
new_version = Version.from_string(args.version)
else:
bump_type = VersionBump(args.bump)
new_version = None

version_manager.release(
new_version=new_version,
bump_type=bump_type if args.bump else None,
skip_tag=args.skip_tag,
skip_packages=args.skip_packages,
skip_changelog=args.skip_changelog,
skip_github_release=args.skip_github_release,
conan_index_path=args.conan_path,
vcpkg_path=args.vcpkg_path
)


if __name__ == "__main__":
main()
Loading
Loading