Skip to content

Commit

Permalink
Fix BINDGEN_CFLAGS assignment place
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmo0920 committed Mar 29, 2018
1 parent 6b1d2e4 commit 8487ebc
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
From a8587e5936edac97d2aa73492904ca6a2b3f81de Mon Sep 17 00:00:00 2001
From: Hiroshi Hatake <[email protected]>
Date: Wed, 28 Mar 2018 17:01:25 +0900
Subject: [PATCH] Add generating cflags for bindgen mechanism

---
build/moz.configure/toolchain.configure | 73 +++++++++++++++++++++++++++++++--
1 file changed, 70 insertions(+), 3 deletions(-)

diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
index fa066d5a9e35..f5e53e21e5da 100755
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1070,6 +1070,13 @@ def check_have_64_bit(have_64_bit, compiler_have_64_bit):
configure_error('The target compiler does not agree with configure '
'about the target bitness.')

+option(env='BINDGEN_INCCPP',
+ nargs=1,
+ help='Options bindgen for headers should pass to the C/C++ parser')
+
+option(env='BINDGEN_LLVM_BASE',
+ nargs=1,
+ help='Options bindgen for llvm prefix should pass to the C/C++ parser')

option(env='BINDGEN_CFLAGS',
nargs=1,
@@ -1077,10 +1084,70 @@ option(env='BINDGEN_CFLAGS',
help='Options bindgen should pass to the C/C++ parser')


-@depends('BINDGEN_CFLAGS')
+@depends('BINDGEN_INCCPP')
+def bindgen_inccpp(inc_cpp):
+ return inc_cpp
+
+
+@depends('BINDGEN_LLVM_BASE')
+def bindgen_llvm_base(llvm_base):
+ return llvm_base
+
+
+@imports('os')
+@imports('string')
+@imports('re')
+@imports('glob')
+@imports(_from='__builtin__', _import='sorted')
+@imports(_from='__builtin__', _import='reversed')
+@imports(_from='__builtin__', _import='map')
+def bindgen_cflags_cross_compiling(value, inc_dir, llvm_base, target):
+ def path_ver_cmp(ver_path):
+ ver_path = os.path.abspath(ver_path)
+ parse = string.split(ver_path, "/")
+ var = []
+ var_pattern = re.compile(r"\bv?(\d+(?:.\d+)*)$")
+ for seg in reversed(parse): #Find version no from the bottom of the path
+ var_seg = var_pattern.findall(seg)
+ if len(var_seg) > 0:
+ var = map(int, var_seg[len(var_seg) - 1].split("."))
+ break
+
+ return (var, os.path.dirname(ver_path), os.path.basename(ver_path))
+
+
+ def search_path(pattern):
+ result = sorted(glob.glob(pattern), key=path_ver_cmp, reverse=True)
+
+ #result = "" if len(result) == 0 else result[0]
+ result = result[0] #XXX: Raise exception here if no target found
+
+ return result
+
+ inc_cpp = search_path("%s/c++/*" % inc_dir)
+ inc_llvm = search_path("%s/llvm-*/**/clang/*/include" % llvm_base)
+ if value:
+ default_cflags = value[0].split()
+ else:
+ default_cflags = ""
+
+ cflags_format = "%s --target=%s \
+ -I%s \
+ -I%s/%s \
+ -I%s"
+ # We should pass target as arm-poky-linux-gnueabi instead of arm-linux-gnueabi.
+ # target.alias returns this.
+ return cflags_format % (default_cflags, target.alias, inc_cpp,
+ inc_cpp, target.alias, inc_llvm)
+
+
+@depends('BINDGEN_CFLAGS', bindgen_inccpp, bindgen_llvm_base, target, cross_compiling)
@checking('bindgen cflags', lambda s: s if s else 'no')
-def bindgen_cflags(value):
- if value and len(value):
+def bindgen_cflags(value, bindgen_inccpp, bindgen_llvm_base, target, cross_compiling):
+ if cross_compiling and bindgen_inccpp:
+ return bindgen_cflags_cross_compiling(value, bindgen_inccpp, bindgen_llvm_base,
+ target)
+ elif value and len(value):
return value[0].split()


--
2.11.0

14 changes: 4 additions & 10 deletions recipes-mozilla/firefox/firefox_60.0b7.bb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SRC_URI = "https://ftp.mozilla.org/pub/firefox/releases/60.0b7/source/firefox-60
file://fixes/0001-Add-a-preference-to-force-enable-touch-events-withou.patch \
file://fixes/fix-get-cpu-feature-definition-conflict.patch \
file://fixes/fix-camera-permission-dialg-doesnot-close.patch \
file://fixes/0001-Add-generating-cflags-for-bindgen-mechanism.patch \
file://gn-configs/ \
"

Expand Down Expand Up @@ -134,16 +135,9 @@ def search_path(pattern):

do_configure() {
export SHELL=/bin/bash

# We will remove these lines after we introduce meta-rust.
# They aren't needed against meta-rust.
INC_CPP='${@search_path("${STAGING_INCDIR}/c++/*")}'
INC_LLVM='${@search_path("/usr/lib/llvm-*/**/clang/*/include")}'
export BINDGEN_CFLAGS="${BINDGEN_CFLAGS} \
--target=${TARGET_SYS} \
-I${INC_CPP} \
-I${INC_CPP}/${TARGET_SYS} \
-I${INC_LLVM}"
export RUST_TARGET_PATH=${STAGING_LIBDIR_NATIVE}/rustlib
export BINDGEN_INCCPP=${STAGING_INCDIR}
export BINDGEN_LLVM_BASE=/usr/lib

# TODO:
# It will be replaced with ${RUST_TARGET_SYS} which is provided by
Expand Down

0 comments on commit 8487ebc

Please sign in to comment.