]> khamidou — GitHub mirrors - electron.git/commitdiff
Set sysroot for arm build
authorCheng Zhao <zcbenz@gmail.com>
Wed, 1 Jul 2015 09:54:27 +0000 (09:54 +0000)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 1 Jul 2015 09:54:27 +0000 (09:54 +0000)
atom.gyp
filenames.gypi
toolchain.gypi
tools/linux/sysroot_ld_path.sh [new file with mode: 0755]

index 423c59e862e5511931d1073ed6843ffa6315cdad..cce72f16c4677c7a9bfd2694c797ed959762d191 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -5,8 +5,6 @@
     'company_name%': 'GitHub, Inc',
     'company_abbr%': 'github',
     'version%': '0.28.3',
-
-    'atom_source_root': '<!(["python", "tools/atom_source_root.py"])',
   },
   'includes': [
     'filenames.gypi',
@@ -18,7 +16,7 @@
       'ATOM_PROJECT_NAME="<(project_name)"',
     ],
     'mac_framework_dirs': [
-      '<(atom_source_root)/external_binaries',
+      '<(source_root)/external_binaries',
     ],
   },
   'targets': [
index 562e65280d5992c1407eee064b55bf8954f19bae..8d3248e000993f1a50e18d4d2ac510bd3092fe13 100644 (file)
       'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk',
       'vi', 'zh-CN', 'zh-TW',
     ],
-    'atom_source_root': '<!(["python", "tools/atom_source_root.py"])',
     'conditions': [
       ['OS=="win"', {
         'app_sources': [
index 1b96ac3ab68d6a8066ce56f3164b3ee67fdc17fb..e2aa7de3fbedfb528267fdc90007f446e7db0b62 100644 (file)
@@ -1,5 +1,8 @@
 {
   'variables': {
+    # The abosulte version of <(DEPTH).
+    'source_root': '<!(cd <(DEPTH) && pwd -P)',
+
     # Clang stuff.
     'make_clang_dir%': 'vendor/llvm-build/Release+Asserts',
     # Set this to true when building with Clang.
@@ -51,6 +54,7 @@
     ],
   },
   'conditions': [
+    # Setup building with clang.
     ['clang==1', {
       'make_global_settings': [
         ['CC', '<(make_clang_dir)/bin/clang'],
       },
     }],  # clang==1
 
+    # Setup sysroot environment.
+    ['OS=="linux" and target_arch=="arm"', {
+      'variables': {
+        # sysroot needs to be an absolute path otherwise it generates
+        # incorrect results when passed to pkg-config
+        'sysroot': '<(source_root)/vendor/debian_wheezy_arm-sysroot',
+      },
+      'target_defaults': {
+        'target_conditions': [
+          ['_toolset=="target"', {
+            'cflags': [
+              '--sysroot=<(sysroot)',
+            ],
+            'ldflags': [
+              '--sysroot=<(sysroot)',
+              '<!(<(source_root)/tools/linux/sysroot_ld_path.sh <(sysroot))',
+            ],
+          }]
+        ],
+      },
+    }],  # target_arch==arm
+
+    # Setup cross-compilation on Linux.
     ['OS=="linux"', {
       'target_defaults': {
         'target_conditions': [
diff --git a/tools/linux/sysroot_ld_path.sh b/tools/linux/sysroot_ld_path.sh
new file mode 100755 (executable)
index 0000000..4b8bf73
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Reads etc/ld.so.conf and/or etc/ld.so.conf.d/*.conf and returns the
+# appropriate linker flags.
+#
+#  sysroot_ld_path.sh /abspath/to/sysroot
+#
+
+log_error_and_exit() {
+  echo $0: $@
+  exit 1
+}
+
+process_entry() {
+  if [ -z "$1" ] || [ -z "$2" ]; then
+    log_error_and_exit "bad arguments to process_entry()"
+  fi
+  local root="$1"
+  local localpath="$2"
+
+  echo $localpath | grep -qs '^/'
+  if [ $? -ne 0 ]; then
+    log_error_and_exit $localpath does not start with /
+  fi
+  local entry="$root$localpath"
+  echo -L$entry
+  echo -Wl,-rpath-link=$entry
+}
+
+process_ld_so_conf() {
+  if [ -z "$1" ] || [ -z "$2" ]; then
+    log_error_and_exit "bad arguments to process_ld_so_conf()"
+  fi
+  local root="$1"
+  local ld_so_conf="$2"
+
+  # ld.so.conf may include relative include paths. pushd is a bashism.
+  local saved_pwd=$(pwd)
+  cd $(dirname "$ld_so_conf")
+
+  cat "$ld_so_conf" | \
+    while read ENTRY; do
+      echo "$ENTRY" | grep -qs ^include
+      if [ $? -eq 0 ]; then
+        local included_files=$(echo "$ENTRY" | sed 's/^include //')
+        echo "$included_files" | grep -qs ^/
+        if [ $? -eq 0 ]; then
+          if ls $root$included_files >/dev/null 2>&1 ; then
+            for inc_file in $root$included_files; do
+              process_ld_so_conf "$root" "$inc_file"
+            done
+          fi
+        else
+          if ls $(pwd)/$included_files >/dev/null 2>&1 ; then
+            for inc_file in $(pwd)/$included_files; do
+              process_ld_so_conf "$root" "$inc_file"
+            done
+          fi
+        fi
+        continue
+      fi
+
+      echo "$ENTRY" | grep -qs ^/
+      if [ $? -eq 0 ]; then
+        process_entry "$root" "$ENTRY"
+      fi
+    done
+
+  # popd is a bashism
+  cd "$saved_pwd"
+}
+
+# Main
+
+if [ $# -ne 1 ]; then
+  echo Usage $0 /abspath/to/sysroot
+  exit 1
+fi
+
+echo $1 | grep -qs ' '
+if [ $? -eq 0 ]; then
+  log_error_and_exit $1 contains whitespace.
+fi
+
+LD_SO_CONF="$1/etc/ld.so.conf"
+LD_SO_CONF_D="$1/etc/ld.so.conf.d"
+
+if [ -e "$LD_SO_CONF" ]; then
+  process_ld_so_conf "$1" "$LD_SO_CONF" | xargs echo
+elif [ -e "$LD_SO_CONF_D" ]; then
+  find "$LD_SO_CONF_D" -maxdepth 1 -name '*.conf' -print -quit > /dev/null
+  if [ $? -eq 0 ]; then
+    for entry in $LD_SO_CONF_D/*.conf; do
+      process_ld_so_conf "$1" "$entry"
+    done | xargs echo
+  fi
+fi