Generate .c for .y and .l
- For .l/.y source files, generate .c files; for .ll/.yy source files,
generate c++ files.
- Simplified the rules by adding the generated sources to
my_generated_sources.
- Simplified generated header file naming by always using .h extension
with bison's "--defines=" option.
- Removed the unnecesarry conditional inclusion to the generated
headers. Bison already automatically generates such things.
Bug: 26492989
Change-Id: I9ab6dc149c258f7642bc36c3fa32f90ff7ee51a4
diff --git a/core/definitions.mk b/core/definitions.mk
index a6218cc..5fe126d 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -875,7 +875,7 @@
## Commands for running lex
###########################################################
-define transform-l-to-cpp
+define transform-l-to-c-or-cpp
@echo "Lex: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(hide) $(LEX) -o$@ $<
@@ -884,20 +884,14 @@
###########################################################
## Commands for running yacc
##
-## Because the extension of c++ files can change, the
-## extension must be specified in $1.
-## E.g, "$(call transform-y-to-cpp,.cpp)"
###########################################################
-define transform-y-to-cpp
+define transform-y-to-c-or-cpp
@echo "Yacc: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
-$(YACC) $(PRIVATE_YACCFLAGS) -o $@ $<
-touch $(@:$1=$(YACC_HEADER_SUFFIX))
-echo '#ifndef '$(@F:$1=_h) > $(@:$1=.h)
-echo '#define '$(@F:$1=_h) >> $(@:$1=.h)
-cat $(@:$1=$(YACC_HEADER_SUFFIX)) >> $(@:$1=.h)
-echo '#endif' >> $(@:$1=.h)
+$(YACC) $(PRIVATE_YACCFLAGS) \
+ --defines=$(basename $@).h \
+ -o $@ $<
endef
###########################################################