• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -ex
2#
3# Copyright 2017 Google Inc. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# Regenerate host configuration files for the current host
18
19cd `dirname ${BASH_SOURCE[0]}`
20
21ANDROID_BUILD_TOP=$(cd ../../..; pwd)
22
23if [ $(uname) == 'Darwin' ]; then
24  DIR=darwin
25else
26  if [ $(uname -m) == 'aarch64' ]; then
27      DIR=linux_arm64
28  else
29      DIR=linux_x86_64
30  fi
31fi
32
33export CLANG_VERSION=$(cd $ANDROID_BUILD_TOP; build/soong/scripts/get_clang_version.py)
34
35if [ $DIR == "linux_x86_64" ]; then
36  export CC="$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/$CLANG_VERSION/bin/clang"
37  export CFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot"
38  export LDFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot -B$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64"
39elif [ $DIR == "linux_arm64" ]; then
40  #export CC="$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/$CLANG_VERSION/bin/clang"
41  export CC=clang
42  export CFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/build-tools/sysroots/aarch64-linux-musl"
43  export LDFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/build-tools/sysroots/aarch64-linux-musl -rtlib=compiler-rt -fuse-ld=lld --unwindlib=none"
44fi
45
46mkdir -p $DIR/pyconfig $DIR/libffi
47cd $DIR
48
49# Generate pyconfig.h
50rm -rf tmp
51mkdir tmp
52cd tmp
53../../configure
54cp pyconfig.h ../pyconfig/
55cd ..
56rm -rf tmp
57
58# Generate ffi.h / fficonfig.h
59rm -rf tmp
60mkdir tmp
61cd tmp
62../../Modules/_ctypes/libffi/configure
63cp fficonfig.h include/ffi.h ../libffi/
64cd ..
65rm -rf tmp
66