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 xmlsec/1.2.30 #3314

Merged
merged 28 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5d4d631
Folder structure and recipe for xmlsec 1.2.30
steinerthomas Oct 25, 2020
60822fe
Add option with_xslt
steinerthomas Oct 25, 2020
1a162cf
Trigger build
steinerthomas Oct 26, 2020
352a8dd
Remove fpic option for Windows
steinerthomas Oct 26, 2020
8682819
Add support for Windows builds
steinerthomas Oct 26, 2020
925dfb8
Remove fPIC if shared
steinerthomas Oct 26, 2020
4f4480f
Bump openssl version
steinerthomas Oct 26, 2020
8cc4e16
Append standard includedirs instead of overwriting
steinerthomas Oct 26, 2020
0e4e49a
Clean configure_args
steinerthomas Oct 26, 2020
e250b0a
Only run tests if not cross-compiling
steinerthomas Oct 26, 2020
9d328dc
Use remove_files_by_mask instead of glob
steinerthomas Oct 26, 2020
0a21f4b
Remove comma
steinerthomas Oct 26, 2020
4bc104a
Fix Windows build
steinerthomas Oct 26, 2020
e724117
Fix Windows build
steinerthomas Oct 26, 2020
4d4a38a
MSVC build
steinerthomas Oct 30, 2020
64d47dc
Fix debug MSVC build
steinerthomas Oct 31, 2020
bc8f273
xmlsec: add components + double quotes + crypto engine option
madebr Nov 1, 2020
bfca3ae
Merge pull request #1 from madebr/pr_xmlsec
steinerthomas Nov 1, 2020
d4b7e77
Comment fix for mingw
steinerthomas Nov 1, 2020
c59b9b8
Initialize autotools.libs
steinerthomas Nov 1, 2020
3ff9e41
Use msvc property
steinerthomas Nov 2, 2020
a8adef6
Use format for string concat
steinerthomas Nov 2, 2020
f1e6e1e
Docs always no
steinerthomas Nov 2, 2020
aaf0df6
Initialize autotools.libs with syslib pthread (fix build)
steinerthomas Nov 2, 2020
f771c97
Initialize autotools.libs with syslib pthread (fix build) - only for …
steinerthomas Nov 2, 2020
40cbcd2
Use whit_openssl option, remove pthread syslib
steinerthomas Nov 3, 2020
77cd57e
Better check for CONAN_BASH_PATH
steinerthomas Nov 3, 2020
8ef237a
Fix openssl component
steinerthomas Nov 4, 2020
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/xmlsec/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.2.30":
url: "https://github.com/lsh123/xmlsec/archive/xmlsec-1_2_30.tar.gz"
sha256: "57f6a5f3b9f2d17859a5583dc0b23f47130cc1c909ed6caf596ab0cd388237ec"
213 changes: 213 additions & 0 deletions recipes/xmlsec/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment
from conans.errors import ConanInvalidConfiguration
from contextlib import contextmanager
import os

class XmlSecConan(ConanFile):
name = "xmlsec"
description = "XML Security Library is a C library based on LibXML2. The library supports major XML security standards."
license = ("MIT", "MPL-1.1")
steinerthomas marked this conversation as resolved.
Show resolved Hide resolved
homepage = "https://github.com/lsh123/xmlsec"
url = "https://github.com/conan-io/conan-center-index"
generators = "pkg_config"
settings = "os", "compiler", "arch", "build_type"
topics = ("xml", "signature", "encryption")
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_openssl": [True, False],
"with_xslt": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_openssl": True,
"with_xslt": False
}

_autotools = None

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

def requirements(self):
self.requires("libxml2/2.9.10")
if self.options.with_openssl:
self.requires("openssl/1.1.1h")
if self.options.with_xslt:
self.requires("libxslt/1.1.34")

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

def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.os == "Windows" and not self._is_msvc:
raise ConanInvalidConfiguration("Shared mingw builds are not supported (due to libtool blocking static dependencies)")
if not self.options.with_openssl:
raise ConanInvalidConfiguration("At least one crypto engine needs to be enabled")
steinerthomas marked this conversation as resolved.
Show resolved Hide resolved
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def build_requirements(self):
if not self._is_msvc and tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/20200517")
self.build_requires("libtool/2.4.6")
self.build_requires("pkgconf/1.7.3")

@property
def _is_msvc(self):
return self.settings.compiler == "Visual Studio"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_folder = "xmlsec-xmlsec-{}".format(self.version.replace(".", "_"))
os.rename(extracted_folder, self._source_subfolder)

@contextmanager
def _msvc_build_environment(self):
with tools.chdir(os.path.join(self._source_subfolder, 'win32')):
with tools.vcvars(self.settings):
with tools.environment_append(VisualStudioBuildEnvironment(self).vars):
yield

def _build_msvc(self):
yes_no = lambda v: "yes" if v else "no"
with self._msvc_build_environment():
crypto_engines = []
if self.options.with_openssl:
ov = tools.Version(self.deps_cpp_info["openssl"].version)
crypto_engines.append("openssl={}{}0".format(ov.major, ov.minor))
args = [
"cscript",
"configure.js",
"prefix={}".format(self.package_folder),
"cruntime=/{}".format(self.settings.compiler.runtime),
"debug={}".format(yes_no(self.settings.build_type == "Debug")),
"static={}".format(yes_no(not self.options.shared)),
"include=\"{}\"".format(";".join(self.deps_cpp_info.include_paths)),
"lib=\"{}\"".format(";".join(self.deps_cpp_info.lib_paths)),
"with-dl=no",
"xslt={}".format(yes_no(self.options.with_xslt)),
"iconv={}".format(yes_no(False)),
"crypto={}".format(",".join(crypto_engines)),
]

configure_command = " ".join(args)
self.output.info(configure_command)
self.run(configure_command)

# Fix library names
def format_libs(package):
libs = []
for lib in self.deps_cpp_info[package].libs:
libname = lib
if not libname.endswith(".lib"):
libname += ".lib"
libs.append(libname)
for lib in self.deps_cpp_info[package].system_libs:
libname = lib
if not libname.endswith(".lib"):
libname += ".lib"
libs.append(libname)
return " ".join(libs)

tools.replace_in_file("Makefile.msvc", "libxml2.lib", format_libs("libxml2"))
tools.replace_in_file("Makefile.msvc", "libxml2_a.lib", format_libs("libxml2"))
if self.options.with_xslt:
tools.replace_in_file("Makefile.msvc", "libxslt.lib", format_libs("libxslt"))
tools.replace_in_file("Makefile.msvc", "libxslt_a.lib", format_libs("libxslt"))

if self.settings.build_type == "Debug":
tools.replace_in_file("Makefile.msvc", "libcrypto.lib", "libcryptod.lib")

self.run("nmake /f Makefile.msvc")

def _package_msvc(self):
with self._msvc_build_environment():
self.run("nmake /f Makefile.msvc install")

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
if not self.options.shared:
self._autotools.defines.append("XMLSEC_STATIC")
yes_no = lambda v: "yes" if v else "no"
configure_args = [
"--enable-crypto-dl={}".format(yes_no(False)),
"--enable-apps-crypto-dl={}".format(yes_no(False)),
"--with-libxslt={}".format(yes_no(self.options.with_xslt)),
"--with-openssl={}".format(yes_no(self.options.with_openssl)),
"--enable-mscrypto={}".format(yes_no(False)), # Built on mingw
"--enable-mscng={}".format(yes_no(False)), # Build on mingw
"--enable-docs=no",
"--enable-mans=no",
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
]
self._autotools.libs = []
self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder)
return self._autotools

def build(self):
if self._is_msvc:
self._build_msvc()
else:
# FIXME: conan is missing a feature to change the join character on lists of environment variables (fix for mingw on Windows)
# e.g. self.env_info.AUTOMAKE_CONAN_INCLUDES.joiner = ":"
with tools.environment_append({"AUTOMAKE_CONAN_INCLUDES": tools.get_env("AUTOMAKE_CONAN_INCLUDES", "").replace(";", ":")}):
with tools.chdir(self._source_subfolder):
self.run("autoreconf -fiv", run_environment=True, win_bash=tools.os_info.is_windows)
autotools = self._configure_autotools()
autotools.make()

def package(self):
self.copy("Copyright", src=self._source_subfolder, dst="licenses")

if self._is_msvc:
self._package_msvc()
if not self.options.shared:
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.dll")
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb")
os.unlink(os.path.join(self.package_folder, "lib", "libxmlsec-openssl_a.lib" if self.options.shared else "libxmlsec-openssl.lib"))
os.unlink(os.path.join(self.package_folder, "lib", "libxmlsec_a.lib" if self.options.shared else "libxmlsec.lib"))
else:
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
os.remove(os.path.join(self.package_folder, "lib", "xmlsec1Conf.sh"))

def package_info(self):
prefix = "lib" if self._is_msvc else ""
infix = "" if self._is_msvc else str(tools.Version(self.version).major)
suffix = "_a" if self._is_msvc and not self.options.shared else ""

get_libname = lambda libname: prefix + "xmlsec" + infix + (("-" + libname) if libname else "") + suffix
steinerthomas marked this conversation as resolved.
Show resolved Hide resolved

self.cpp_info.components["libxmlsec"].libs = [get_libname(None)]
self.cpp_info.components["libxmlsec"].includedirs.append(os.path.join("include", "xmlsec{}".format(tools.Version(self.version).major)))
self.cpp_info.components["libxmlsec"].requires = ["libxml2::libxml2"]
self.cpp_info.components["libxmlsec"].names["pkg_config"] = "xmlsec{}".format(tools.Version(self.version).major)
if not self.options.shared:
self.cpp_info.components["libxmlsec"].defines.append("XMLSEC_STATIC")
if self.options.with_xslt:
self.cpp_info.components["libxmlsec"].requires.append("libxslt::libxslt")
else:
self.cpp_info.components["libxmlsec"].defines.append("XMLSEC_NO_XSLT=1")
self.cpp_info.components["libxmlsec"].defines.extend(["XMLSEC_NO_SIZE_T", "XMLSEC_NO_GOST=1", "XMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1"])
if self.settings.os == "Linux":
self.cpp_info.components["libxmlsec"].system_libs = ["m", "dl", "pthread"]
if self.settings.os == "Windows":
self.cpp_info.components["libxmlsec"].system_libs = ["crypt32", "ws2_32", "advapi32", "user32", "bcrypt"]

if self.options.with_openssl:
self.cpp_info.components["openssl"].libs = [get_libname("openssl")]
self.cpp_info.components["openssl"].requires = ["libxmlsec", "openssl::openssl"]
self.cpp_info.components["openssl"].defines = ["XMLSEC_CRYPTO_OPENSSL=1"]
self.cpp_info.components["libxmlsec"].names["pkg_config"] = "xmlsec{}-openssl".format(tools.Version(self.version).major)
steinerthomas marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions recipes/xmlsec/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
CONAN_BASIC_SETUP(TARGETS)

add_executable(${PROJECT_NAME} sign1.c)
target_link_libraries(${PROJECT_NAME} CONAN_PKG::xmlsec)
20 changes: 20 additions & 0 deletions recipes/xmlsec/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
arg_path1 = os.path.abspath(os.path.join(os.path.dirname(__file__), "sign1-tmpl.xml"))
arg_path2 = os.path.abspath(os.path.join(os.path.dirname(__file__), "rsakey.pem"))
bin_arg_path = "%s %s %s" % (bin_path, arg_path1, arg_path2)
self.run(bin_arg_path, run_environment=True)
9 changes: 9 additions & 0 deletions recipes/xmlsec/all/test_package/rsakey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBANPQbQ92nlbeg1Q5JNHSO1Yey46nZ7GJltLWw1ccSvp7pnvmfUm+
steinerthomas marked this conversation as resolved.
Show resolved Hide resolved
M521CpFpfr4EAE3UVBMoU9j/hqq3dFAc2H0CAwEAAQJBALFVCjmsAZyQ5jqZLO5N
qEfNuHZSSUol+xPBogFIOq3BWa269eNNcAK5or5g0XWWon7EPdyGT4qyDVH9KzXK
RLECIQDzm/Nj0epUGN51/rKJgRXWkXW/nfSCMO9fvQR6Ujoq3wIhAN6WeHK9vgWg
wBWqMdq5sR211+LlDH7rOUQ6rBpbsoQjAiEA7jzpfglgPPZFOOfo+oh/LuP6X3a+
FER/FQXpRyb7M8kCIETUrwZ8WkiPPxbz/Fqw1W5kjw/g2I5e2uSYaCP2eyuVAiEA
mOI6RhRyMqgxQyy0plJVjG1s4fdu92AWYy9AwYeyd/8=
-----END RSA PRIVATE KEY-----
26 changes: 26 additions & 0 deletions recipes/xmlsec/all/test_package/sign1-tmpl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
XML Security Library example: Simple signature template file for sign1 example.
-->
<Envelope xmlns="urn:envelope">
<Data>
Hello, World!
</Data>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue/>
<KeyInfo>
<KeyName/>
</KeyInfo>
</Signature>
</Envelope>
Loading