Test: "mma -j128" built libffi for arm/x86/x86_64.
Change-Id: I18d6db0e30540e0f1400db629809a64495863742
--- /dev/null
+// 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"],
+ },
+ },
+}
+++ /dev/null
-# 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
--- /dev/null
+#!/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[@]}"
#include "../src/arm/ffitarget.h"
#undef LIBFFI_H
-#include "../include/ffi.h"
+#include "ffi_gen.h"
-#endif
\ No newline at end of file
+#endif
#include "../src/x86/ffitarget.h"
#undef LIBFFI_H
-#include "../include/ffi.h"
+#include "ffi_gen.h"
-#endif
\ No newline at end of file
+#endif