OSDN Git Service

Convert Android.mk to Android.bp.
authorGarfield Tan <xutan@google.com>
Wed, 11 Oct 2017 17:39:03 +0000 (10:39 -0700)
committerGarfield Tan <xutan@google.com>
Fri, 13 Oct 2017 06:57:43 +0000 (06:57 +0000)
Test: "mma -j128" built libffi for arm/x86/x86_64.
Change-Id: I18d6db0e30540e0f1400db629809a64495863742

Android.bp [new file with mode: 0644]
Android.mk [deleted file]
gen_ffi_header.sh [new file with mode: 0755]
linux-arm/ffi.h
linux-x86/ffi.h

diff --git a/Android.bp b/Android.bp
new file mode 100644 (file)
index 0000000..3b66314
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+genrule {
+    name: "ffi_header",
+    cmd: "$(location gen_ffi_header.sh) < $(in) > $(out)",
+    srcs: ["include/ffi.h.in"],
+    out: ["ffi_gen.h"],
+    tool_files: ["gen_ffi_header.sh"],
+}
+
+arm_srcs = [
+    "src/arm/sysv.S",
+    "src/arm/ffi.c",
+]
+
+x86_srcs = [
+    "src/x86/ffi.c",
+    "src/x86/sysv.S",
+    "src/x86/win32.S",
+]
+
+x86_64_srcs = [
+    "src/x86/ffi64.c",
+    "src/x86/unix64.S",
+]
+
+cc_library_static {
+    name: "libffi",
+    cflags: ["-Wno-unused-parameter", "-Wno-sign-compare"],
+    local_include_dirs: ["include"],
+    generated_headers: ["ffi_header"],
+    export_generated_headers: ["ffi_header"],
+    srcs: [
+        "src/debug.c",
+        "src/java_raw_api.c",
+        "src/prep_cif.c",
+        "src/raw_api.c",
+        "src/types.c",
+    ],
+    multilib: {
+        lib64: {
+            srcs: x86_64_srcs,
+        },
+        lib32: {
+            srcs: arm_srcs + x86_srcs,
+        },
+    },
+    arch: {
+        arm: {
+            exclude_srcs: x86_srcs + x86_64_srcs,
+            local_include_dirs: ["linux-arm"],
+            export_include_dirs: ["linux-arm"],
+        },
+        x86: {
+            exclude_srcs: arm_srcs,
+            asflags: [
+                "-DHAVE_AS_X86_PCREL",
+                "-DHAVE_AS_ASCII_PSEUDO_OP",
+            ],
+            local_include_dirs: ["linux-x86"],
+            export_include_dirs: ["linux-x86"],
+        },
+        x86_64: {
+            exclude_srcs: arm_srcs,
+            asflags: [
+                "-DHAVE_AS_X86_PCREL",
+                "-DHAVE_AS_ASCII_PSEUDO_OP",
+            ],
+            local_include_dirs: ["linux-x86_64"],
+            export_include_dirs: ["linux-x86_64"],
+        },
+    },
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644 (file)
index 9665724..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-LIBFFI_TEMPLATE_SUBST := -e s/@VERSION@/3.2.1/
-LIBFFI_TEMPLATE_SUBST += -e s/@TARGET@/FAKE_TARGET_/
-LIBFFI_TEMPLATE_SUBST += -e s/@HAVE_LONG_DOUBLE@/CONF_HAVE_LONG_DOUBLE/
-LIBFFI_TEMPLATE_SUBST += -e s/@HAVE_LONG_DOUBLE_VARIANT@/CONF_HAVE_LONG_DOUBLE_VARIANT/
-LIBFFI_TEMPLATE_SUBST += -e s/@FFI_EXEC_TRAMPOLINE_TABLE@/CONF_FFI_EXEC_TRAMPOLINE_TABLE/
-
-include $(CLEAR_VARS)
-
-# Note: AOSP has (or had) a platform/external/libffi used by Dalvik/MIPS.
-# To avoid confusion, we call our version of the library cheets-libffi.
-LOCAL_MODULE := cheets-libffi
-LOCAL_MODULE_TAGS := optional
-
-ffi_arch := $(TARGET_ARCH)
-ffi_os := $(TARGET_OS)
-
-# Note: We created the "<OS>-<arch>" include directories to ease configuration
-# for each target.
-LOCAL_C_INCLUDES := \
-       $(LOCAL_PATH)/include \
-       $(LOCAL_PATH)/$(ffi_os)-$(ffi_arch) \
-
-LOCAL_CFLAGS += -Wno-unused-parameter
-LOCAL_CFLAGS += -Wno-sign-compare
-
-ifeq ($(ffi_os)-$(ffi_arch),linux-arm)
-LOCAL_SRC_FILES := src/arm/sysv.S src/arm/ffi.c
-valid_arch := true
-endif
-
-ifeq ($(ffi_os)-$(ffi_arch),linux-x86)
-LOCAL_SRC_FILES := src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
-LOCAL_ASFLAGS += \
-       -DHAVE_AS_X86_PCREL \
-       -DHAVE_AS_ASCII_PSEUDO_OP
-valid_arch := true
-endif
-
-ifeq ($(ffi_os)-$(ffi_arch),linux-x86_64)
-LOCAL_SRC_FILES_64 := src/x86/ffi64.c src/x86/unix64.S
-LOCAL_SRC_FILES_32 := src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
-LOCAL_ASFLAGS += \
-       -DHAVE_AS_X86_PCREL \
-       -DHAVE_AS_ASCII_PSEUDO_OP
-
-valid_arch := true
-endif
-
-ifneq ($(valid_arch),true)
-$(error The os/architecture $(ffi_os)-$(ffi_arch) is not supported by cheets-libffi.)
-endif
-
-LOCAL_SRC_FILES += \
-       src/debug.c \
-       src/java_raw_api.c \
-       src/prep_cif.c \
-       src/raw_api.c \
-       src/types.c
-
-# --- Generate include/ffi-real.h from include/ffi.h.in
-GEN := $(addprefix $(LOCAL_PATH)/include/, \
-                                               ffi.h \
-                               )
-LOCAL_ADDITIONAL_DEPENDENCIES += $(GEN)
-$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN) : PRIVATE_CUSTOM_TOOL = sed $(LIBFFI_TEMPLATE_SUBST) < $< > $@
-$(GEN) : $(LOCAL_PATH)/include/%.h : $(LOCAL_PATH)/include/%.h.in
-       $(transform-generated-source)
-# Note: The line above must be indented with tabs.
-
-include $(BUILD_STATIC_LIBRARY)
\ No newline at end of file
diff --git a/gen_ffi_header.sh b/gen_ffi_header.sh
new file mode 100755 (executable)
index 0000000..1bca2d0
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+LIBFFI_TEMPLATE_SUBST=(
+  "-e s/@VERSION@/3.2.1/" \
+  "-e s/@TARGET@/FAKE_TARGET_/" \
+  "-e s/@HAVE_LONG_DOUBLE@/CONF_HAVE_LONG_DOUBLE/" \
+  "-e s/@HAVE_LONG_DOUBLE_VARIANT@/CONF_HAVE_LONG_DOUBLE_VARIANT/" \
+  "-e s/@FFI_EXEC_TRAMPOLINE_TABLE@/CONF_FFI_EXEC_TRAMPOLINE_TABLE/"
+)
+sed "${LIBFFI_TEMPLATE_SUBST[@]}"
index ea86d5e..863911e 100644 (file)
@@ -21,6 +21,6 @@
 #include "../src/arm/ffitarget.h"
 #undef LIBFFI_H
 
-#include "../include/ffi.h"
+#include "ffi_gen.h"
 
-#endif
\ No newline at end of file
+#endif
index 16c4a08..5717a82 100644 (file)
@@ -22,6 +22,6 @@
 #include "../src/x86/ffitarget.h"
 #undef LIBFFI_H
 
-#include "../include/ffi.h"
+#include "ffi_gen.h"
 
-#endif
\ No newline at end of file
+#endif