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

add scdoc documentation tool #8598

Merged
merged 1 commit into from
Jan 12, 2022
Merged
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/scdoc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.11.12":
url: "https://git.sr.ht/~sircmpwn/scdoc/archive/1.11.2.tar.gz"
sha256: "e9ff9981b5854301789a6778ee64ef1f6d1e5f4829a9dd3e58a9a63eacc2e6f0"
79 changes: 79 additions & 0 deletions recipes/scdoc/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"


class ScdocInstallerConan(ConanFile):
name = "scdoc"
description = "scdoc is a simple man page generator for POSIX systems written in C99."
topics = ("manpage", "documentation", "posix")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://git.sr.ht/~sircmpwn/scdoc"
license = "MIT"
settings = "os", "arch", "compiler", "build_type"
_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

def build_requirements(self):
self.build_requires("make/4.3")

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

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

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

@staticmethod
def _chmod_plus_x(filename):
if os.name == "posix":
os.chmod(filename, os.stat(filename).st_mode | 0o111)

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self)
return self._autotools

def build(self):
autotools = self._configure_autotools()
with tools.chdir(self._source_subfolder):
autotools.make()

def package(self):
autotools = self._configure_autotools()
with tools.chdir(self._source_subfolder):
autotools.install(args=[f"PREFIX={self.package_folder}"])
self.copy(pattern="COPYING", dst="licenses",
src=self._source_subfolder)
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libdirs = []

scdoc_root = os.path.join(self.package_folder, "bin")
self.output.info(
"Appending PATH environment variable: {}".format(scdoc_root))
self.env_info.PATH.append(scdoc_root)
self._chmod_plus_x(os.path.join(scdoc_root, "scdoc"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do it when packaging, but I think you want to be sure the user will have permission to execute the binary.

pkgconfig_variables = {
'exec_prefix': '${prefix}/bin',
'scdoc': '${exec_prefix}/scdoc',
}
self.cpp_info.set_property(
"pkg_config_custom_content",
"\n".join("%s=%s" % (key, value) for key,value in pkgconfig_variables.items()))

def validate(self):
if self.settings.os in ["Macos", "Windows"]:
raise ConanInvalidConfiguration(
f"Builds aren't supported on {self.settings.os}")
10 changes: 10 additions & 0 deletions recipes/scdoc/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from conans import ConanFile, tools
import os


class TestPackageConan(ConanFile):

def test(self):
if not tools.cross_building(self):
self.run(
f"scdoc < {os.path.join(self.source_folder,'test_package.1.scd')}", run_environment=True)
9 changes: 9 additions & 0 deletions recipes/scdoc/all/test_package/test_package.1.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test_package(1)

# NAME

test_package - This is a test package for scdoc

# DESCRIPTION

This is a simple scd file for test_package.
3 changes: 3 additions & 0 deletions recipes/scdoc/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.11.12":
folder: all