1##
2# mksnapshot
3# ===================================================
4
5ifneq (,$(filter $(mksnapshot_arch),$(V8_SUPPORTED_ARCH)))
6
7LOCAL_PATH := $(call my-dir)
8include $(CLEAR_VARS)
9
10# Set up the target identity
11LOCAL_IS_HOST_MODULE := true
12LOCAL_MODULE := v8_mksnapshot.$(mksnapshot_arch)
13LOCAL_MODULE_CLASS := EXECUTABLES
14LOCAL_MODULE_TAGS = optional
15LOCAL_MULTILIB := $(mksnapshot_multilib)
16generated_sources := $(call local-generated-sources-dir)
17
18V8_LOCAL_JS_LIBRARY_FILES :=
19V8_LOCAL_JS_EXPERIMENTAL_LIBRARY_FILES :=
20include $(LOCAL_PATH)/Android.v8common.mk
21
22LOCAL_SRC_FILES += \
23  src/mksnapshot.cc \
24  src/snapshot-empty.cc
25
26ifneq (,$(filter $(HOST_ARCH),x86 x86_64))
27LOCAL_SRC_FILES += src/base/atomicops_internals_x86_gcc.cc
28endif
29
30ifeq ($(HOST_OS),linux)
31LOCAL_SRC_FILES += \
32  src/base/platform/platform-linux.cc \
33  src/base/platform/platform-posix.cc
34endif
35ifeq ($(HOST_OS),darwin)
36LOCAL_SRC_FILES += \
37  src/base/platform/platform-macos.cc \
38  src/base/platform/platform-posix.cc
39endif
40
41LOCAL_JS_LIBRARY_FILES := $(addprefix $(LOCAL_PATH)/, $(V8_LOCAL_JS_LIBRARY_FILES))
42LOCAL_JS_EXPERIMENTAL_LIBRARY_FILES := $(addprefix $(LOCAL_PATH)/, $(V8_LOCAL_JS_EXPERIMENTAL_LIBRARY_FILES))
43
44# Copy js2c.py to generated sources directory and invoke there to avoid
45# generating jsmin.pyc in the source directory
46JS2C_PY := $(generated_sources)/js2c.py $(generated_sources)/jsmin.py
47$(JS2C_PY): $(generated_sources)/%.py : $(LOCAL_PATH)/tools/%.py | $(ACP)
48	@echo "Copying $@"
49	$(copy-file-to-target)
50
51# Generate libraries.cc
52GEN3 := $(generated_sources)/libraries.cc
53$(GEN3): SCRIPT := $(generated_sources)/js2c.py
54$(GEN3): $(LOCAL_JS_LIBRARY_FILES) $(JS2C_PY)
55	@echo "Generating libraries.cc"
56	@mkdir -p $(dir $@)
57	python $(SCRIPT) $@ CORE off $(LOCAL_JS_LIBRARY_FILES)
58LOCAL_GENERATED_SOURCES := $(generated_sources)/libraries.cc
59
60# Generate experimental-libraries.cc
61GEN4 := $(generated_sources)/experimental-libraries.cc
62$(GEN4): SCRIPT := $(generated_sources)/js2c.py
63$(GEN4): $(LOCAL_JS_EXPERIMENTAL_LIBRARY_FILES) $(JS2C_PY)
64	@echo "Generating experimental-libraries.cc"
65	@mkdir -p $(dir $@)
66	python $(SCRIPT) $@ EXPERIMENTAL off $(LOCAL_JS_EXPERIMENTAL_LIBRARY_FILES)
67LOCAL_GENERATED_SOURCES += $(generated_sources)/experimental-libraries.cc
68
69LOCAL_CFLAGS := \
70	-Wno-endif-labels \
71	-Wno-import \
72	-Wno-format \
73	-ansi \
74	-fno-rtti \
75	-DENABLE_DEBUGGER_SUPPORT \
76	-DENABLE_LOGGING_AND_PROFILING \
77	-DENABLE_VMSTATE_TRACKING \
78	-DV8_NATIVE_REGEXP \
79	-DV8_LIBRT_NOT_AVAILABLE \
80	-Wno-unused-parameter \
81	-std=gnu++0x
82
83LOCAL_CFLAGS_v8_target_arm += -DV8_TARGET_ARCH_ARM -O0
84LOCAL_CFLAGS_v8_target_arm64 += -DV8_TARGET_ARCH_ARM64
85
86ifeq ($(ARCH_ARM_HAVE_VFP),true)
87    LOCAL_CFLAGS_v8_target_arm += -DCAN_USE_VFP_INSTRUCTIONS -DCAN_USE_ARMV7_INSTRUCTIONS
88endif
89
90LOCAL_CFLAGS_v8_target_mips += -DV8_TARGET_ARCH_MIPS \
91	-DCAN_USE_FPU_INSTRUCTIONS \
92	-Umips \
93	-finline-limit=64 \
94	-fno-strict-aliasing
95
96LOCAL_CFLAGS_v8_target_mips64 += -DV8_TARGET_ARCH_MIPS64 \
97	-Umips \
98	-finline-limit=64 \
99	-fno-strict-aliasing
100
101LOCAL_CFLAGS_v8_target_x86 += -DV8_TARGET_ARCH_IA32
102LOCAL_CFLAGS_v8_target_x86_64 += -DV8_TARGET_ARCH_X64
103
104ifeq ($(DEBUG_V8),true)
105	LOCAL_CFLAGS += -DDEBUG -UNDEBUG
106endif
107
108# LOCAL_SRC_FILES_arch only applies to target modules, but we want them
109# for a host module, so append them manually
110LOCAL_SRC_FILES += $(v8_local_src_files_$(mksnapshot_arch))
111LOCAL_CFLAGS += $(LOCAL_CFLAGS_v8_target_$(mksnapshot_arch))
112
113LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
114
115# This is on host.
116LOCAL_LDLIBS := -lpthread
117
118LOCAL_SHARED_LIBRARIES := libicuuc-host libicui18n-host
119
120LOCAL_STATIC_LIBRARIES := liblog
121
122include $(BUILD_HOST_EXECUTABLE)
123else
124$(warning mksnapshot.$(mksnapshot_arch): architecture $(mksnapshot_arch) not supported)
125endif
126