1# Copyright 2018 The Fuchsia 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_DIR := $(GET_LOCAL_DIR)
6
7#
8# FIDL compiler host tests.
9#
10
11MODULE := $(LOCAL_DIR)
12
13MODULE_TYPE := hosttest
14
15MODULE_NAME := fidl-compiler-test
16
17EXAMPLE_DIR := system/host/fidl/examples/
18
19EXAMPLE_FILES := \
20    $(EXAMPLE_DIR)/alignment.fidl \
21    $(EXAMPLE_DIR)/empty.fidl \
22    $(EXAMPLE_DIR)/enums.fidl \
23    $(EXAMPLE_DIR)/events.fidl \
24    $(EXAMPLE_DIR)/example-0.fidl \
25    $(EXAMPLE_DIR)/example-1.fidl \
26    $(EXAMPLE_DIR)/example-2.fidl \
27    $(EXAMPLE_DIR)/example-3.fidl \
28    $(EXAMPLE_DIR)/example-4.fidl \
29    $(EXAMPLE_DIR)/example-5.fidl \
30    $(EXAMPLE_DIR)/example-6.fidl \
31    $(EXAMPLE_DIR)/example-7.fidl \
32    $(EXAMPLE_DIR)/example-8.fidl \
33    $(EXAMPLE_DIR)/example-9.fidl \
34    $(EXAMPLE_DIR)/interface-ordinals.fidl \
35    $(EXAMPLE_DIR)/library-a/point.fidl \
36    $(EXAMPLE_DIR)/library-b/view.fidl \
37    $(EXAMPLE_DIR)/simple.fidl \
38    $(EXAMPLE_DIR)/tables.fidl \
39    $(EXAMPLE_DIR)/test.fidl \
40    $(EXAMPLE_DIR)/types.fidl \
41    $(LOCAL_DIR)/testdata/goodformat.fidl \
42    $(LOCAL_DIR)/testdata/badformat.fidl.noformat \
43
44BUILDGEN_DIR=$(BUILDDIR)/system/utest/fidl-compiler
45
46$(BUILDGEN_DIR)/examples.cpp: $(EXAMPLE_FILES)
47	@$(MKDIR)
48	$(call BUILDECHO, generating FIDL test example file)
49	$(NOECHO)rm -rf $@ && \
50	printf "\
51#include <map>\n\
52#include <string>\n\
53#include \"examples.h\"\n\
54// Autogenerated: Do not modify!\n\
55std::map<std::string, std::string> Examples::map_ = {\n" >> $@ && \
56	for i in $^; do \
57	  printf "    {\""$${i}"\", R\"FIDL(""$$(cat $${i})"")FIDL\"}," >> $@; \
58	done &&  \
59	printf "\
60};\n" >> $@ \
61
62
63MODULE_SRCS := \
64    $(LOCAL_DIR)/main.cpp \
65    $(LOCAL_DIR)/bad_compound_identifier_tests.cpp \
66    $(LOCAL_DIR)/dup_attributes_tests.cpp \
67    $(LOCAL_DIR)/flat_ast_tests.cpp \
68    $(LOCAL_DIR)/formatter_unittests.cpp \
69    $(LOCAL_DIR)/json_generator_tests.cpp \
70    $(LOCAL_DIR)/max_bytes_tests.cpp \
71    $(LOCAL_DIR)/max_handle_tests.cpp \
72    $(LOCAL_DIR)/superinterface_tests.cpp \
73    $(LOCAL_DIR)/table_tests.cpp \
74    $(LOCAL_DIR)/using_tests.cpp \
75    $(LOCAL_DIR)/visitor_unittests.cpp \
76    $(BUILDGEN_DIR)/examples.cpp \
77
78MODULE_COMPILEFLAGS := \
79    -Isystem/ulib/unittest/include \
80    -Isystem/utest/fidl-compiler \
81
82MODULE_HOST_LIBS := \
83    system/host/fidl \
84    system/ulib/pretty.hostlib \
85    system/ulib/unittest.hostlib \
86
87MODULE_PACKAGE_INCS := \
88    $(LOCAL_DIR)/examples.h \
89
90include make/module.mk
91