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

gnu-getopt: new recipe #23537

Open
wants to merge 6 commits into
base: master
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
4 changes: 4 additions & 0 deletions recipes/gnu-getopt/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.40":
url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.40/util-linux-2.40.tar.xz"
sha256: "d57a626081f9ead02fa44c63a6af162ec19c58f53e993f206ab7c3a6641c2cd7"
76 changes: 76 additions & 0 deletions recipes/gnu-getopt/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.54.0"


class GnuGetoptConan(ConanFile):
name = "gnu-getopt"
description = "GNU getopt(1) command-line utility"
license = "GPL-2.0-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://frodo.looijaard.name/project/getopt"
topics = ("gnu", "getopt", "utility", "command-line", "parsing")

package_type = "application"
settings = "os", "arch", "compiler", "build_type"

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def layout(self):
basic_layout(self, src_folder="src")

def package_id(self):
del self.info.settings.compiler

def validate(self):
if is_msvc(self):
# Requires POSIX headers and libs
raise ConanInvalidConfiguration("MSVC is not supported. Consider using MSYS2 instead.")

def build_requirements(self):
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")

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

def generate(self):
env = VirtualBuildEnv(self)
env.generate()

tc = AutotoolsToolchain(self)
# liblastlog support requires sqlite3
valgur marked this conversation as resolved.
Show resolved Hide resolved
tc.configure_args.append("--disable-liblastlog2")
# Python is not used here, disable the check
tc.configure_args.append("--without-python")
tc.generate()

def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make(target="getopt")

def package(self):
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "getopt*", self.build_folder, os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.frameworkdirs = []
21 changes: 21 additions & 0 deletions recipes/gnu-getopt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os

Check warning on line 1 in recipes/gnu-getopt/all/test_package/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed test_package/conanfile.py (v2 migration)

Unused import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.layout import basic_layout


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "VirtualBuildEnv"
test_type = "explicit"

def layout(self):
basic_layout(self)

def build_requirements(self):
self.tool_requires(self.tested_reference_str)

def test(self):
if can_run(self):
self.run("getopt co: -c test.c -o test")
3 changes: 3 additions & 0 deletions recipes/gnu-getopt/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.40":
folder: all
Loading