1# Copyright 2016 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5LOCAL_MOJO_ROOT := $(call my-dir) 6 7JNI_GENERATOR_TOOL := \ 8 $(LOCAL_MOJO_ROOT)/base/android/jni_generator/jni_generator.py 9 10generated_sources_dir := $(local-generated-sources-dir) 11generated_files := 12 13# $(1): a single Java file 14define generate-jni-header 15 16java_file := $(1) 17local_path := $(LOCAL_PATH) 18target_path := $(generated_sources_dir)/jni 19gen_h := $$(target_path)/$$(basename $$(notdir $$(java_file)))_jni.h 20 21$$(gen_h) : PRIVATE_PATH := $$(local_path) 22$$(gen_h) : PRIVATE_TARGET := $$(target_path) 23$$(gen_h) : PRIVATE_CUSTOM_TOOL = \ 24 (cd $$(PRIVATE_PATH) && \ 25 python $$(abspath $$(JNI_GENERATOR_TOOL)) \ 26 --input_file=$$(subst $$(PRIVATE_PATH)/,,$$<) \ 27 --output_dir=$$(abspath $$(PRIVATE_TARGET)) \ 28 --includes base/android/jni_generator/jni_generator_helper.h \ 29 --ptr_type long \ 30 --native_exports_optional) 31$$(gen_h) : $$(local_path)/$$(java_file) $$(JNI_GENERATOR_TOOL) 32 $$(transform-generated-source) 33 34generated_files += $$(gen_h) 35 36endef # define generate-jni-header 37 38# Build each file separately since the build command needs to be done per-file. 39$(foreach file,$(LOCAL_JAVA_JNI_FILES),$(eval $(call generate-jni-header,$(file)))) 40 41# Add the generated sources to the C includes. 42LOCAL_C_INCLUDES += $(generated_sources_dir) 43 44# LOCAL_GENERATED_SOURCES will filter out anything that's not a C/C++ source 45# file, but still add the files as dependencies of the other files in the 46# module. 47LOCAL_GENERATED_SOURCES += $(generated_files) 48