summaryrefslogtreecommitdiffstats
path: root/native/copy-to-ndk.sh
blob: 64708929cc601a71d9605ce48718512b06dc4874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Take care of copying current header files over to the correct
# location in the NDK.

copyndkheaders() {
    local CURR_PLATFORM=android-9
    local ALL_PLATFORMS="$CURR_PLATFORM android-8 android-5 android-4 android-3"

    local SRC_HEADERS=$ANDROID_BUILD_TOP/frameworks/base/native/include/android
    local NDK_PLATFORMS=$ANDROID_BUILD_TOP/development/ndk/platforms
    local DST_HEADERS=$NDK_PLATFORMS/$CURR_PLATFORM

    local SRC_LIB_ANDROID=$ANDROID_PRODUCT_OUT/system/lib/libandroid.so
    local DST_LIB_ANDROID=$NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/lib/libandroid.so

    local didsomething=""

    #echo "SRC_HEADERS: $SRC_HEADERS"

    for i in $(cd $SRC_HEADERS; ls *.h); do
        local src=$SRC_HEADERS/$i
        local changed=""
        for j in $ALL_PLATFORMS; do
            local dst=$NDK_PLATFORMS/$j/include/android/$i
            if [ "$changed" == "" -a -e $dst ]; then
                echo "Exists: $dst"
                if diff $src $dst >/dev/null; then
                    echo "$i: has not changed from $j" >/dev/null
                    changed="false"
                else
                    changed="true"
                    echo "$i: has changed from $j" >/dev/null
                fi
            fi
        done
        if [ "$changed" == "true" -o "$changed" == "" ]; then
            echo "Updating: $i"
            cp $src $NDK_PLATFORMS/$CURR_PLATFORM/include/android/$i
            didsomething="true"
        fi
    done

    if diff $SRC_LIB_ANDROID $DST_LIB_ANDROID >/dev/null; then
        echo "libandroid.so: has not changed"
    else
        echo "Updating: $DST_LIB_ANDROID"
        cp $SRC_LIB_ANDROID $DST_LIB_ANDROID
        didsomething="true"
    fi
    if [ "$didsomething" != "" ]; then
        echo "Headers changed...  rebuilding platforms."
        sh $ANDROID_BUILD_TOP/ndk/build/tools/build-platforms.sh
    fi
}

copyndkheaders