-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
nspr: bump + modernize + no tools.os_info in build_requirements
#7212
Changes from all commits
b04e1c8
57db0cd
3265175
d25fdb1
0a8b084
fa4eeef
7d8fc29
1ec6211
1da5e4d
a048ad6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
sources: | ||
"4.24": | ||
sha256: 90a59a0df6a11528749647fe18401cc7e03881e3e63c309f8c520ce06dd413d0 | ||
url: https://ftp.mozilla.org/pub/nspr/releases/v4.24/src/nspr-4.24.tar.gz | ||
"4.27": | ||
sha256: 6d495192b6ab00a3c28db053492cf794329f7c0351a5728db198111a1816e89b | ||
url: https://ftp.mozilla.org/pub/nspr/releases/v4.27/src/nspr-4.27.tar.gz | ||
"4.29": | ||
sha256: 22286bdb8059d74632cc7c2865c139e63953ecfb33bf4362ab58827e86e92582 | ||
url: https://ftp.mozilla.org/pub/nspr/releases/v4.29/src/nspr-4.29.tar.gz | ||
"4.32": | ||
sha256: bb6bf4f534b9559cf123dcdc6f9cd8167de950314a90a88b2a329c16836e7f6c | ||
url: https://ftp.mozilla.org/pub/nspr/releases/v4.32/src/nspr-4.32.tar.gz | ||
"4.27": | ||
url: "https://ftp.mozilla.org/pub/nspr/releases/v4.27/src/nspr-4.27.tar.gz" | ||
sha256: "6d495192b6ab00a3c28db053492cf794329f7c0351a5728db198111a1816e89b" | ||
"4.24": | ||
url: "https://ftp.mozilla.org/pub/nspr/releases/v4.24/src/nspr-4.24.tar.gz" | ||
sha256: "90a59a0df6a11528749647fe18401cc7e03881e3e63c309f8c520ce06dd413d0" |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,35 +1,39 @@ | ||||||||||
from conans import ConanFile, tools, AutoToolsBuildEnvironment | ||||||||||
from conans.errors import ConanInvalidConfiguration | ||||||||||
import conan.tools.files | ||||||||||
from contextlib import contextmanager | ||||||||||
import os | ||||||||||
import contextlib | ||||||||||
|
||||||||||
required_conan_version = ">=1.33" | ||||||||||
required_conan_version = ">=1.33.0" | ||||||||||
|
||||||||||
class NsprConan(ConanFile): | ||||||||||
name = "nspr" | ||||||||||
homepage = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR" | ||||||||||
description = "Netscape Portable Runtime (NSPR) provides a platform-neutral API for system level and libc-like functions." | ||||||||||
topics = ("conan", "nspr", "libc") | ||||||||||
topics = ("nspr", "libc") | ||||||||||
url = "https://github.com/conan-io/conan-center-index" | ||||||||||
settings = "os", "compiler", "arch", "build_type" | ||||||||||
license = "MPL-2.0" | ||||||||||
settings = "os", "arch", "compiler", "build_type" | ||||||||||
options = { | ||||||||||
"shared": [True, False], | ||||||||||
"fPIC": [True, False], | ||||||||||
"with_mozilla": [True, False], | ||||||||||
"win32_target": ["winnt", "win95"] | ||||||||||
"win32_target": ["winnt", "win95"], | ||||||||||
} | ||||||||||
default_options = { | ||||||||||
"shared": False, | ||||||||||
"fPIC": True, | ||||||||||
"with_mozilla": True, | ||||||||||
"win32_target": "winnt", | ||||||||||
} | ||||||||||
|
||||||||||
generators = "cmake" | ||||||||||
|
||||||||||
_autotools = None | ||||||||||
|
||||||||||
@property | ||||||||||
def _is_msvc(self): | ||||||||||
return self.settings.compiler in ["Visual Studio", "msvc"] | ||||||||||
|
||||||||||
@property | ||||||||||
def _source_subfolder(self): | ||||||||||
return "source_subfolder" | ||||||||||
|
@@ -45,10 +49,10 @@ def config_options(self): | |||||||||
del self.options.win32_target | ||||||||||
|
||||||||||
def configure(self): | ||||||||||
del self.settings.compiler.cppstd | ||||||||||
del self.settings.compiler.libcxx | ||||||||||
if self.options.shared: | ||||||||||
del self.options.fPIC | ||||||||||
del self.settings.compiler.cppstd | ||||||||||
del self.settings.compiler.libcxx | ||||||||||
|
||||||||||
def validate(self): | ||||||||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1658671 | ||||||||||
|
@@ -58,19 +62,20 @@ def validate(self): | |||||||||
|
||||||||||
def source(self): | ||||||||||
tools.get(**self.conan_data["sources"][self.version], | ||||||||||
strip_root=True) | ||||||||||
conan.tools.files.rename(self, "nspr", self._source_subfolder) | ||||||||||
destination="tmp", strip_root=True) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feature request? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It worth an issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fill a feature request to conan client |
||||||||||
os.rename(os.path.join("tmp", "nspr"), self._source_subfolder) | ||||||||||
tools.rmdir("tmp") | ||||||||||
|
||||||||||
def build_requirements(self): | ||||||||||
if self._settings_build.os == "Windows" : | ||||||||||
if self._settings_build.os == "Windows": | ||||||||||
self.build_requires("mozilla-build/3.3") | ||||||||||
if not tools.get_env("CONAN_BASH_PATH"): | ||||||||||
self.build_requires("msys2/cci.latest") | ||||||||||
|
||||||||||
@contextmanager | ||||||||||
@contextlib.contextmanager | ||||||||||
def _build_context(self): | ||||||||||
if self.settings.compiler == "Visual Studio": | ||||||||||
with tools.vcvars(self.settings): | ||||||||||
if self._is_msvc: | ||||||||||
with tools.vcvars(self): | ||||||||||
with tools.environment_append({"CC": "cl", "CXX": "cl", "LD": "link"}): | ||||||||||
yield | ||||||||||
else: | ||||||||||
|
@@ -79,30 +84,34 @@ def _build_context(self): | |||||||||
def _configure_autotools(self): | ||||||||||
if self._autotools: | ||||||||||
return self._autotools | ||||||||||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||||||||||
yes_no = lambda v: "yes" if v else "no" | ||||||||||
conf_args = [ | ||||||||||
"--with-mozilla" if self.options.with_mozilla else "--without-mozilla", | ||||||||||
"--with-mozilla={}".format(yes_no(self.options.with_mozilla)), | ||||||||||
"--enable-64bit={}".format(yes_no(self.settings.arch in ("armv8", "x86_64", "mips64", "ppc64", "ppc64le"))), | ||||||||||
"--enable-strip={}".format(yes_no(self.settings.build_type not in ("Debug", "RelWithDebInfo"))), | ||||||||||
"--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), | ||||||||||
"--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), | ||||||||||
"--disable-cplus", | ||||||||||
"--enable-64bit" if self.settings.arch in ("armv8", "x86_64") else "--disable-64bit", | ||||||||||
"--disable-strip" if self.settings.build_type == "RelWithDebInfo" else "--enable-strip", | ||||||||||
"--enable-debug" if self.settings.build_type == "Debug" else "--disable-debug", | ||||||||||
] | ||||||||||
Comment on lines
+90
to
99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are dupicated opions here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be a merge artifact |
||||||||||
if self.settings.compiler == "Visual Studio": | ||||||||||
if self._is_msvc: | ||||||||||
conf_args.extend([ | ||||||||||
"{}-pc-mingw32".format("x86_64" if self.settings.arch == "x86_64" else "x86"), | ||||||||||
"--enable-static-rtl" if "MT" in str(self.settings.compiler.runtime) else "--disable-static-rtl", | ||||||||||
"--enable-debug-rtl" if "d" in str(self.settings.compiler.runtime) else "--disable-debug-rtl", | ||||||||||
"--enable-static-rtl={}".format(yes_no("MT" in self.settings.compiler.runtime)), | ||||||||||
"--enable-debug-rtl={}".format(yes_no("d" in self.settings.compiler.runtime)), | ||||||||||
SSE4 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+103
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
]) | ||||||||||
elif self.settings.os == "Android": | ||||||||||
conf_args.extend([ | ||||||||||
"--with-android-ndk={}".format(os.environ["NDK_ROOT"]), | ||||||||||
"--with-android-ndk={}".format(tools.get_env(["NDK_ROOT"])), | ||||||||||
"--with-android-version={}".format(self.settings.os.api_level), | ||||||||||
"--with-android-platform={}".format(os.environ["ANDROID_PLATFORM"]), | ||||||||||
"--with-android-toolchain={}".format(os.environ["ANDROID_TOOLCHAIN"]), | ||||||||||
"--with-android-platform={}".format(tools.get_env("ANDROID_PLATFORM")), | ||||||||||
"--with-android-toolchain={}".format(tools.get_env("ANDROID_TOOLCHAIN")), | ||||||||||
]) | ||||||||||
elif self.settings.os == "Windows": | ||||||||||
conf_args.append("--enable-win32-target={}".format(self.options.win32_target)) | ||||||||||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||||||||||
|
||||||||||
env = self._autotools.vars | ||||||||||
if self.settings.os == "Macos": | ||||||||||
if self.settings.arch == "armv8": | ||||||||||
|
@@ -132,8 +141,8 @@ def package(self): | |||||||||
if self.options.shared: | ||||||||||
os.mkdir(os.path.join(self.package_folder, "bin")) | ||||||||||
for lib in self._library_names: | ||||||||||
libsuffix = "lib" if self.settings.compiler == "Visual Studio" else "a" | ||||||||||
libprefix = "" if self.settings.compiler == "Visual Studio" else "lib" | ||||||||||
libsuffix = "lib" if self._is_msvc else "a" | ||||||||||
libprefix = "" if self._is_msvc else "lib" | ||||||||||
if self.options.shared: | ||||||||||
os.unlink(os.path.join(self.package_folder, "lib", "{}{}_s.{}".format(libprefix, lib, libsuffix))) | ||||||||||
os.rename(os.path.join(self.package_folder, "lib", "{}.dll".format(lib)), | ||||||||||
|
@@ -184,3 +193,9 @@ def package_info(self): | |||||||||
self.cpp_info.system_libs.extend(["dl", "pthread"]) | ||||||||||
elif self.settings.os == "Windows": | ||||||||||
self.cpp_info.system_libs.extend(["winmm", "ws2_32"]) | ||||||||||
|
||||||||||
aclocal = tools.unix_path(os.path.join(self.package_folder, "res", "aclocal")) | ||||||||||
self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment variable: {}".format(aclocal)) | ||||||||||
self.env_info.AUTOMAKE_CONAN_INCLUDES.append(aclocal) | ||||||||||
|
||||||||||
self.cpp_info.resdirs = ["res"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
project(test_package C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(nspr REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE nspr::nspr) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <nspr.h> | ||
|
||
#include <stdio.h> | ||
|
||
static int primordial(int argc, char *argv[]) { | ||
if (PR_Initialized() != PR_TRUE) { | ||
fprintf(stderr, "NSPR not initialized!\n"); | ||
return 1; | ||
} | ||
fprintf(stderr, "Inside primordial function\n"); | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
int versionOk = PR_VersionCheck(PR_VERSION); | ||
if (versionOk == 0) { | ||
fprintf(stderr, "PR_VersionCheck() failed\n"); | ||
return 1; | ||
} | ||
printf(PR_NAME " version %s\n", PR_GetVersion()); | ||
PR_Initialize(primordial, argc, argv, 0); | ||
|
||
PR_ProcessExit(0); | ||
fprintf(stderr, "PR_ProcessExit failed\n"); | ||
return 1; | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
versions: | ||
"4.24": | ||
folder: all | ||
"4.27": | ||
"4.32": | ||
folder: all | ||
"4.29": | ||
folder: all | ||
"4.32": | ||
"4.27": | ||
folder: all | ||
"4.24": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.