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
7include $(LOCAL_MOJO_ROOT)/build_mojom_template_tools.mk
8
9MOJOM_TEMPLATE_SOURCES := $(shell find \
10	$(LOCAL_MOJO_ROOT)/mojo/public/tools/bindings/generators -name '*.tmpl')
11
12generated_templates_dir := \
13	$(call generated-sources-dir-for,SHARED_LIBRARIES,libmojo,,)/templates
14
15gen := $(generated_templates_dir)/.stamp
16sources := $(MOJOM_TEMPLATE_SOURCES)
17$(gen) : PRIVATE_TOOL := $(MOJOM_BINDINGS_GENERATOR)
18$(gen) : PRIVATE_OUT_DIR := $(generated_templates_dir)
19$(gen) : $(sources) $(MOJOM_TEMPLATE_TOOLS)
20	@echo generate_mojo_templates: $(PRIVATE_OUT_DIR)
21	$(hide) rm -rf $(dir $@)
22	$(hide) mkdir -p $(dir $@)
23	$(hide) python $(PRIVATE_TOOL) --use_bundled_pylibs precompile \
24		-o $(PRIVATE_OUT_DIR)
25	$(hide) touch $@
26
27# Make the files that are actually generated depend on the .stamp file.
28$(generated_templates_dir)/cpp_templates.zip: $(gen)
29	$(hide) touch $@
30
31$(generated_templates_dir)/java_templates.zip: $(gen)
32	$(hide) touch $@
33
34$(generated_templates_dir)/js_templates.zip: $(gen)
35	$(hide) touch $@
36