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

[APR] Support for cross-building using cache file #17609

Closed
wants to merge 6 commits into from
Closed
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
29 changes: 27 additions & 2 deletions recipes/apr/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"fPIC": True,
"force_apr_uuid": True,
}
exports_sources = "cross_build/*"

@property
def _settings_build(self):
Expand Down Expand Up @@ -69,7 +70,26 @@

def validate_build(self):
if cross_building(self) and not is_msvc(self):
raise ConanInvalidConfiguration("apr recipe doesn't support cross-build yet due to runtime checks in autoconf")
""" The APR configure.in script makes extensive (30 instances) use

Check warning on line 73 in recipes/apr/all/conanfile.py

View workflow job for this annotation

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

String statement has no effect
of AC_TRY_RUN (to determine system capabilities) and checks for /dev/zero.
These runtime checks only work when run on the host so
the configure script will fail when cross compiling
unless the relevant configuration variables
are provided in a cache file or on the command line or in an environment variable.
The configuration variable values are most easily determined by running the configure script on a host system using:
./configure --cache-file={gnu_host_triplet}.cache
and then removing the 'precious' autoconf variables:
ac_cv_env_*
The generated cache file can be repeatedly used to cross-compile to the targeted host system
by including it with the recipe data.
The default targeted host system name can be overriden in the profile using (for example).
[conf]
tools.gnu:host_triplet=arm-linux-gnueabihf
This recipe assumes the generated cache file is stored in the 'cross_build' directory.
"""
gnu_host_triplet = self.conf.get("tools.gnu:host_triplet", check_type=str)
if not gnu_host_triplet:
raise ConanInvalidConfiguration("apr cross-build requires a [conf] tools.gnu:host_triplet=XXXXX profile entry and a cross_build/XXXXX.cache file")

Check warning on line 92 in recipes/apr/all/conanfile.py

View workflow job for this annotation

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

Bad indentation. Found 17 spaces, expected 16

def build_requirements(self):
if not is_msvc(self):
Expand All @@ -95,7 +115,12 @@
tc = AutotoolsToolchain(self)
tc.configure_args.append("--with-installbuilddir=${prefix}/res/build-1")
if cross_building(self):
tc.configure_args.append("apr_cv_mutex_robust_shared=yes")
gnu_host_triplet = self.conf.get("tools.gnu:host_triplet", check_type=str)
if gnu_host_triplet:
cacheFile = os.path.join(os.path.dirname(self.source_folder), "cross_build", os.path.basename(gnu_host_triplet + ".cache"))
if not os.path.exists(cacheFile):
raise ConanInvalidConfiguration(f"apr cross-building requires {gnu_host_triplet}.cache file in the 'cross_build' folder")
tc.configure_args.append(f"--cache-file={cacheFile}")
tc.generate()

def _patch_sources(self):
Expand Down Expand Up @@ -131,12 +156,12 @@
fix_apple_shared_install_name(self)

apr_rules_mk = os.path.join(self.package_folder, "res", "build-1", "apr_rules.mk")
apr_rules_cnt = open(apr_rules_mk).read()

Check warning on line 159 in recipes/apr/all/conanfile.py

View workflow job for this annotation

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

Using open without explicitly specifying an encoding
for key in ("apr_builddir", "apr_builders", "top_builddir"):
apr_rules_cnt, nb = re.subn(f"^{key}=[^\n]*\n", f"{key}=$(_APR_BUILDDIR)\n", apr_rules_cnt, flags=re.MULTILINE)
if nb == 0:
raise ConanException(f"Could not find/replace {key} in {apr_rules_mk}")
open(apr_rules_mk, "w").write(apr_rules_cnt)

Check warning on line 164 in recipes/apr/all/conanfile.py

View workflow job for this annotation

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

Using open without explicitly specifying an encoding

def package_info(self):
self.cpp_info.set_property("pkg_config_name", "apr-1")
Expand All @@ -152,4 +177,4 @@

# TODO: to remove in conan v2
self.env_info.APR_ROOT = self.package_folder
self.env_info._APR_BUILDDIR = os.path.join(self.package_folder, "res", "build-1")

Check warning on line 180 in recipes/apr/all/conanfile.py

View workflow job for this annotation

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

Access to a protected member _APR_BUILDDIR of a client class
Loading
Loading