forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ohNet * Add ohNet test package * Add rsync dependency * Update conanfile.py * Update conanfile.py * Update conanfile.py * Add system libraries * Fix v1 package * Fix clang usage * Fix empty flags * Fix libc++ on Linux * Fix CMake configuration for both versions * Revert test_package * Update test_v1_package * Add source file to nmake * Add system_libs for Windows * Fix Windows builds * Use new import * Update conanfile.py * Update conanfile.py * Simplify tests * Compatibility with older Clang * Add builddirs * Remove test_v1_package * Add new ohNet version * Update version * Update the patches * Update recipes/ohnet/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> * Update recipes/ohnet/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> --------- Co-authored-by: Uilian Ries <[email protected]>
- Loading branch information
1 parent
a824b11
commit b6094c2
Showing
7 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"1.36.5182": | ||
url: "https://github.com/openhome/ohNet/archive/refs/tags/ohNet_1.36.5182.tar.gz" | ||
sha256: "1489407b9bae13affa8f933a81fb5a43f16b29f5bf8048b68ea645afc0e53ced" | ||
patches: | ||
"1.36.5182": | ||
- patch_file: "patches/0001-makefile-universal.patch" | ||
patch_description: "Reduce gcc-centricity in Makefile" | ||
patch_type: "conan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
from conan import ConanFile | ||
from conan.tools.files import get, chdir, copy, mkdir, export_conandata_patches, apply_conandata_patches | ||
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain | ||
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, NMakeToolchain | ||
from conan.tools.layout import basic_layout | ||
from conan.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class OhNetConan(ConanFile): | ||
name = "ohnet" | ||
description = "OpenHome Networking (ohNet) is a modern, cross platform, multi-language UPnP stack" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/openhome/ohNet" | ||
topics = ("openhome", "ohnet", "upnp") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
short_paths = True | ||
|
||
def _get_openhome_architecture(self, args): | ||
if is_apple_os(self): | ||
if str(self.settings.arch).startswith("armv8"): | ||
openhome_architecture = "arm64" | ||
args.extend([f"openhome_architecture={openhome_architecture}", f"detected_openhome_architecture={openhome_architecture}"]) | ||
return args | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if is_msvc(self) and (self.options.shared or msvc_runtime_flag(self).startswith('MD')): | ||
raise ConanInvalidConfiguration(f"{self.ref} doesn't support shared builds with Visual Studio yet") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def generate(self): | ||
if is_msvc(self): | ||
tc = NMakeToolchain(self) | ||
tc.generate() | ||
else: | ||
tc = AutotoolsToolchain(self) | ||
tc.make_args.append("-j1") | ||
tc.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
targets = "ohNetDll TestsNative proxies devices" | ||
additional_options="" | ||
|
||
with chdir(self, self.source_folder): | ||
if is_msvc(self): | ||
if self.settings.build_type == "Debug": | ||
additional_options += " debug=1" | ||
self.run(f"nmake /f OhNet.mak {targets} {additional_options}") | ||
else: | ||
args = [] | ||
args = self._get_openhome_architecture(args) | ||
args.append("rsync=no") | ||
if str(self.settings.compiler.libcxx) == "libc++": | ||
args.extend(["CPPFLAGS=-stdlib=libc++", "LDFLAGS=-stdlib=libc++"]) | ||
autotools = Autotools(self) | ||
autotools.make(args=args, target=targets) | ||
|
||
def package(self): | ||
installlibdir = os.path.join(self.package_folder, "lib") | ||
installincludedir = os.path.join(self.package_folder, "include") | ||
additional_options="" | ||
|
||
copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) | ||
|
||
copy(self, "*", src=os.path.join(self.source_folder, "OpenHome", "Net", "ServiceGen"), dst=os.path.join(self.package_folder, "lib", "ServiceGen")) | ||
mkdir(self, os.path.join(self.package_folder, "lib", "t4")) | ||
|
||
with chdir(self, self.source_folder): | ||
if is_msvc(self): | ||
if self.settings.build_type == "Debug": | ||
additional_options += " debug=1" | ||
self.run(f"nmake /f OhNet.mak install installdir={self.package_folder} installlibdir={installlibdir} installincludedir={installincludedir} {additional_options}") | ||
else: | ||
args = [f"prefix={self.package_folder}", f"installlibdir={installlibdir}", f"installincludedir={installincludedir}", "rsync=no"] | ||
args = self._get_openhome_architecture(args) | ||
autotools = Autotools(self) | ||
autotools.make(args=args, target="install-libs install-includes") | ||
if is_apple_os(self): | ||
fix_apple_shared_install_name(self) | ||
|
||
def package_info(self): | ||
self.cpp_info.components["ohNet"].libs = ["ohNet"] | ||
self.cpp_info.components["ohNet"].builddirs = [os.path.join("lib", "ServiceGen")] | ||
self.cpp_info.components["ohNet"].set_property("cmake_target_name", "ohNet") | ||
self.cpp_info.components["ohNet"].defines.extend(["DEFINE_LITTLE_ENDIAN"]) | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.components["ohNet"].system_libs.extend(["pthread", "m"]) | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.components["ohNet"].system_libs.extend(["iphlpapi", "ws2_32", "dbghelp"]) | ||
|
||
self.cpp_info.components["ohNetCore"].libs = ["ohNetCore"] | ||
self.cpp_info.components["ohNetCore"].builddirs = [os.path.join("lib", "ServiceGen")] | ||
self.cpp_info.components["ohNetCore"].set_property("cmake_target_name", "ohNetCore") | ||
self.cpp_info.components["ohNetCore"].defines.extend(["DEFINE_LITTLE_ENDIAN"]) | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.components["ohNetCore"].system_libs.extend(["pthread", "m"]) | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.components["ohNetCore"].system_libs.extend(["iphlpapi", "ws2_32", "dbghelp"]) | ||
elif self.settings.os == "Macos": | ||
self.cpp_info.components["ohNetCore"].frameworks.extend(["CoreFoundation", "IOKit", "SystemConfiguration"]) | ||
|
||
self.cpp_info.components["ohNetDevices"].libs = ["ohNetDevices"] | ||
self.cpp_info.components["ohNetDevices"].set_property("cmake_target_name", "ohNetDevices") | ||
|
||
self.cpp_info.components["ohNetProxies"].libs = ["ohNetProxies"] | ||
self.cpp_info.components["ohNetProxies"].set_property("cmake_target_name", "ohNetProxies") | ||
|
||
self.cpp_info.components["TestFramework"].libs = ["TestFramework"] | ||
self.cpp_info.components["TestFramework"].set_property("cmake_target_name", "TestFramework") | ||
self.cpp_info.components["TestFramework"].requires = ["ohNetCore"] | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package* generators removed | ||
self.cpp_info.names["cmake_find_package"] = "ohNet" | ||
self.cpp_info.names["cmake_find_package_multi"] = "ohNet" | ||
self.cpp_info.names["pkg_config"] = "ohNet" | ||
for component in ["ohNetCore", "OhNetDevices", "ohNetProxies", "TestFramework"]: | ||
self.cpp_info.components[component].names["cmake_find_package"] = component | ||
self.cpp_info.components[component].names["cmake_find_package_multi"] = component | ||
self.cpp_info.components[component].set_property("cmake_target_name", component) |
220 changes: 220 additions & 0 deletions
220
recipes/ohnet/all/patches/0001-makefile-universal.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
diff --git a/Common.mak b/Common.mak | ||
index a479b12a..82e5db60 100644 | ||
--- a/Common.mak | ||
+++ b/Common.mak | ||
@@ -386,7 +386,7 @@ $(objdir)dnssd_clientshim.$(objext) : $(mDNSdir)/dnssd_clientshim.c $(headers) | ||
$(objdir)dnssd_clientlib.$(objext) : $(mDNSdir)/dnssd_clientlib.c $(headers) | ||
$(compiler)dnssd_clientlib.$(objext) -c $(cflags_third_party) $(includes) $(mDNSdir)/dnssd_clientlib.c | ||
$(objdir)MdnsPlatform.$(objext) : OpenHome/Net/Device/Bonjour/MdnsPlatform.cpp $(headers) | ||
- $(compiler)MdnsPlatform.$(objext) -c $(cflags_third_party) $(includes) OpenHome/Net/Device/Bonjour/MdnsPlatform.cpp | ||
+ $(compiler)MdnsPlatform.$(objext) -c $(cppflags) $(cflags_third_party) $(includes) OpenHome/Net/Device/Bonjour/MdnsPlatform.cpp | ||
$(objdir)MdnsProvider.$(objext) : OpenHome/Net/Device/Bonjour/MdnsProvider.cpp $(headers) | ||
$(compiler)MdnsProvider.$(objext) -c $(cppflags) $(includes) OpenHome/Net/Device/Bonjour/MdnsProvider.cpp | ||
$(objdir)Md5.$(objext) : OpenHome/md5.c $(headers) | ||
diff --git a/Makefile b/Makefile | ||
index 2f0cb07c..7b73494d 100644 | ||
--- a/Makefile | ||
+++ b/Makefile | ||
@@ -6,7 +6,7 @@ rsync ?= yes | ||
ifeq ($(rsync),yes) | ||
cp = rsync -u | ||
else | ||
-cp = cp -u | ||
+cp = cp | ||
endif | ||
|
||
ifeq ($(debug),1) | ||
@@ -27,11 +27,11 @@ endif | ||
|
||
# Figure out platform, openhome_system and openhome_architecture | ||
|
||
-gcc_machine = $(shell ${CROSS_COMPILE}gcc -dumpmachine) | ||
+cc_machine = $(shell ${CROSS_COMPILE}$(CC) -dumpmachine) | ||
MACHINE = $(shell uname -s) | ||
|
||
$(info CROSS_COMPILE: ${CROSS_COMPILE}) | ||
-$(info Machine reported by compiler is: ${gcc_machine}) | ||
+$(info Machine reported by compiler is: ${cc_machine}) | ||
$(info Machine reported by uname is: ${MACHINE}) | ||
$(info PLATFORM: ${PLATFORM}) | ||
|
||
@@ -57,7 +57,7 @@ ifeq ($(MACHINE),Darwin) | ||
detected_openhome_architecture = x64 | ||
endif | ||
endif | ||
-else ifneq (, $(findstring powerpc, $(gcc_machine))) | ||
+else ifneq (, $(findstring powerpc, $(cc_machine))) | ||
platform = Core-ppc32 | ||
detected_openhome_system = Core | ||
detected_openhome_architecture = ppc32 | ||
@@ -69,11 +69,11 @@ else ifeq ($(freebsd), 1) | ||
platform = FreeBSD | ||
detected_openhome_system = FreeBSD | ||
detected_openhome_architecture = x86 | ||
- compiler = gcc -o $(objdir) | ||
- link = ${CROSS_COMPILE}g++ $(platform_linkflags) | ||
+ compiler = $(CC) -o $(objdir) | ||
+ link = ${CROSS_COMPILE}$(CXX) $(platform_linkflags) | ||
ar = ${CROSS_COMPILE}ar rc $(objdir) | ||
else ifneq (,$(findstring Linux-x86,${PLATFORM})) | ||
- ifneq (,$(findstring x86_64,$(gcc_machine))) | ||
+ ifneq (,$(findstring x86_64,$(cc_machine))) | ||
platform = Vanilla | ||
detected_openhome_system = Linux | ||
detected_openhome_architecture = x86 | ||
@@ -85,11 +85,11 @@ else | ||
platform ?= Vanilla | ||
ifneq (,$(findstring Qnap,$(platform))) | ||
detected_openhome_system = Qnap | ||
- else ifneq (,$(findstring linux,$(gcc_machine))) | ||
+ else ifneq (,$(findstring linux,$(cc_machine))) | ||
detected_openhome_system = Linux | ||
endif | ||
- ifneq (,$(findstring arm,$(gcc_machine))) | ||
- ifneq (,$(findstring linux-gnueabihf,$(gcc_machine))) | ||
+ ifneq (,$(findstring arm,$(cc_machine))) | ||
+ ifneq (,$(findstring linux-gnueabihf,$(cc_machine))) | ||
detected_openhome_architecture = armhf | ||
else ifeq (${detected_openhome_system},Qnap) | ||
detected_openhome_architecture = x19 | ||
@@ -97,34 +97,34 @@ else | ||
detected_openhome_architecture = armel | ||
endif | ||
endif | ||
- ifneq (,$(findstring i686,$(gcc_machine))) | ||
+ ifneq (,$(findstring i686,$(cc_machine))) | ||
detected_openhome_architecture = x86 | ||
endif | ||
- ifneq (,$(findstring i586,$(gcc_machine))) | ||
+ ifneq (,$(findstring i586,$(cc_machine))) | ||
detected_openhome_architecture = x86 | ||
endif | ||
- ifneq (,$(findstring i486,$(gcc_machine))) | ||
+ ifneq (,$(findstring i486,$(cc_machine))) | ||
detected_openhome_architecture = x86 | ||
endif | ||
- ifneq (,$(findstring i386,$(gcc_machine))) | ||
+ ifneq (,$(findstring i386,$(cc_machine))) | ||
detected_openhome_architecture = x86 | ||
endif | ||
- ifneq (,$(findstring amd64,$(gcc_machine))) | ||
+ ifneq (,$(findstring amd64,$(cc_machine))) | ||
detected_openhome_architecture = x64 | ||
endif | ||
- ifneq (,$(findstring x86_64,$(gcc_machine))) | ||
+ ifneq (,$(findstring x86_64,$(cc_machine))) | ||
detected_openhome_architecture = x64 | ||
endif | ||
- ifneq (,$(findstring mipsel,$(gcc_machine))) | ||
+ ifneq (,$(findstring mipsel,$(cc_machine))) | ||
detected_openhome_architecture = mipsel | ||
endif | ||
- ifneq (,$(findstring mips,$(gcc_machine))) | ||
+ ifneq (,$(findstring mips,$(cc_machine))) | ||
detected_openhome_architecture = mipsel | ||
endif | ||
- ifneq (,$(findstring aarch64,$(gcc_machine))) | ||
+ ifneq (,$(findstring aarch64,$(cc_machine))) | ||
detected_openhome_architecture = arm64 | ||
endif | ||
- ifneq (,$(findstring riscv64,$(gcc_machine))) | ||
+ ifneq (,$(findstring riscv64,$(cc_machine))) | ||
detected_openhome_architecture = riscv64 | ||
endif | ||
endif | ||
@@ -215,7 +215,7 @@ ifeq ($(platform),Mac) | ||
endif | ||
|
||
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/ | ||
- compiler = clang -fPIC -stdlib=libc++ -o $(objdir) | ||
+ compiler = clang -fPIC -Qunused-arguments -stdlib=libc++ -o $(objdir) | ||
link = clang++ -pthread -stdlib=libc++ $(platform_linkflags) | ||
ar = ar rc $(objdir) | ||
openhome_system = Mac | ||
@@ -235,8 +235,8 @@ ifeq ($(platform), Core-ppc32) | ||
osbuilddir = Core-ppc32 | ||
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/ | ||
native_only = yes | ||
- compiler = ${CROSS_COMPILE}gcc -o $(objdir) | ||
- link = ${CROSS_COMPILE}g++ $(platform_linkflags) | ||
+ compiler = ${CROSS_COMPILE}$(CC) -o $(objdir) | ||
+ link = ${CROSS_COMPILE}$(CXX) $(platform_linkflags) | ||
ar = ${CROSS_COMPILE}ar rc $(objdir) | ||
endif | ||
|
||
@@ -252,8 +252,8 @@ ifeq ($(platform), Core-armv6) | ||
osbuilddir = Core-armv6 | ||
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/ | ||
native_only = yes | ||
- compiler = ${CROSS_COMPILE}gcc -o $(objdir) | ||
- link = ${CROSS_COMPILE}g++ $(platform_linkflags) | ||
+ compiler = ${CROSS_COMPILE}$(CC) -o $(objdir) | ||
+ link = ${CROSS_COMPILE}$(CXX) $(platform_linkflags) | ||
ar = ${CROSS_COMPILE}ar rc $(objdir) | ||
endif | ||
|
||
@@ -263,8 +263,14 @@ ifneq (,$(findstring $(platform),Vanilla Qnap-x86 Qnap-x19 Linux-ppc32)) | ||
version_specific_cflags_third_party = -Wno-non-virtual-dtor | ||
version_specific_java_cflags = -Wstrict-aliasing=0 | ||
else | ||
- gcc_min_ver = $(shell ${CROSS_COMPILE}gcc -dumpversion | cut -f2 -d'.') | ||
- version_specific_cflags = $(shell if [ $(gcc_min_ver) -ge 6 ]; then echo '-Wno-psabi'; fi) | ||
+ version_specific_cflags = | ||
+ ifeq ($(CC), gcc) | ||
+ gcc_min_ver = $(shell ${CROSS_COMPILE}gcc -dumpversion | cut -f2 -d'.') | ||
+ gcc_ge_6 = $(shell if [ $(gcc_min_ver) -ge 6 ]; then echo 'yes'; fi) | ||
+ ifeq ($(gcc_ge_6), yes) | ||
+ version_specific_cflags = '-Wno-psabi' | ||
+ endif | ||
+ endif | ||
version_specific_cflags += ${CROSS_COMPILE_CFLAGS} | ||
version_specific_cflags_third_party = | ||
version_specific_java_cflags = | ||
@@ -276,8 +282,8 @@ ifneq (,$(findstring $(platform),Vanilla Qnap-x86 Qnap-x19 Linux-ppc32)) | ||
|
||
# Continuing with the non-Darwin settings... | ||
objdir = Build/Obj/$(osdir)/$(build_dir)/ | ||
- compiler = ${CROSS_COMPILE}gcc -o $(objdir) | ||
- link = $(version_specific_library_path) ${CROSS_COMPILE}g++ $(platform_linkflags) | ||
+ compiler = ${CROSS_COMPILE}$(CC) -o $(objdir) | ||
+ link = $(version_specific_library_path) ${CROSS_COMPILE}$(CXX) $(platform_linkflags) | ||
ar = $(version_specific_library_path) ${CROSS_COMPILE}ar rc $(objdir) | ||
endif | ||
|
||
@@ -358,11 +364,11 @@ endian ?= LITTLE | ||
cflags_base = $(CFLAGS) -fexceptions -Wall $(version_specific_cflags_third_party) -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_$(endian)_ENDIAN -DDEFINE_TRACE $(debug_specific_cflags) -fvisibility=hidden $(platform_cflags) | ||
cflags_third_party = $(cflags_base) -Wno-int-to-pointer-cast | ||
ifeq ($(nocpp11), yes) | ||
- cppflags = $(cflags_base) -Werror | ||
+ cppflags = $(CPPFLAGS) $(cflags_base) -Werror | ||
else ifeq ($(platform),Mac) | ||
- cppflags = $(cflags_base) -std=c++11 -Werror | ||
+ cppflags = $(CPPFLAGS) $(cflags_base) -std=c++11 -Werror | ||
else | ||
- cppflags = $(cflags_base) -std=c++0x -Werror | ||
+ cppflags = $(CPPFLAGS) $(cflags_base) -std=c++0x -Werror | ||
endif | ||
cflags = $(cflags_base) -Werror | ||
inc_build = Build/Include | ||
@@ -390,7 +396,7 @@ else ifeq ($(MACHINE), Darwin) | ||
link_dll = $(version_specific_library_path) clang++ -pthread $(platform_linkflags) -shared -stdlib=libc++ | ||
else | ||
CROSS_COMPILE_LIBGCC ?= -shared-libgcc | ||
- link_dll = $(version_specific_library_path) ${CROSS_COMPILE}g++ -pthread $(platform_linkflags) -shared ${CROSS_COMPILE_LIBGCC} | ||
+ link_dll = $(version_specific_library_path) ${CROSS_COMPILE}$(CXX) -pthread $(platform_linkflags) -shared ${CROSS_COMPILE_LIBGCC} | ||
endif | ||
|
||
csharp = mcs /nologo $(debug_csharp) | ||
@@ -416,10 +422,10 @@ else | ||
ifeq ($(platform), Linux-ppc32) | ||
libjvm_dir ?= $(JAVA_HOME)/jre/lib/ppc/server | ||
else | ||
- ifneq (,$(findstring arm,$(gcc_machine))) | ||
+ ifneq (,$(findstring arm,$(cc_machine))) | ||
libjvm_dir ?= $(JAVA_HOME)/jre/lib/arm/server | ||
else | ||
- ifneq (,$(findstring x64,$(gcc_machine))) | ||
+ ifneq (,$(findstring x64,$(cc_machine))) | ||
libjvm_dir ?= $(JAVA_HOME)/jre/lib/amd64/server | ||
else | ||
libjvm_dir ?= $(JAVA_HOME)/jre/lib/i386/server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_package CXX) | ||
|
||
find_package(ohNet REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ohNetCore) |
Oops, something went wrong.