add Yacc/bison support in gbuild

This commit is contained in:
Norbert Thiebaud 2011-08-19 20:38:08 -05:00
parent e5b8876064
commit d73872e9f2
3 changed files with 76 additions and 19 deletions

View file

@ -78,6 +78,8 @@ $(eval $(foreach method,\
add_objcobjects \
add_objcxxobject \
add_objcxxobjects \
add_grammar \
add_grammars \
add_exception_objects \
add_noexception_objects \
add_generated_cobjects \

View file

@ -223,6 +223,20 @@ endif
gb_GenCxxObject_GenCxxObject =
# YaccObject class
gb_YaccObject_get_grammar = $(1)/$(2).y
gb_YACC := bison
# YaccObject class
define gb_YaccObject__command
$(call gb_Output_announce,$(2),$(true),YAC,3)
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(1)) && \
$(gb_YACC) $(T_YACCFLAGS) -d -o $(1) $(3) )
endef
# ObjCxxObject class
#
@ -339,6 +353,8 @@ gb_LinkTarget_OBJECTS :=
$(call gb_LinkTarget_get_clean_target,%) :
$(call gb_Output_announce,$*,$(false),LNK,4)
RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
$(WORKDIR)/GenCObject/$(notdir $*) \
$(WORKDIR)/GenCxxObject/$(nodir $*) \
$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
$(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
@ -349,9 +365,7 @@ $(call gb_LinkTarget_get_clean_target,%) :
$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
$(call gb_LinkTarget_get_target,$*) \
$(call gb_LinkTarget_get_dep_target,$*) \
@ -360,7 +374,7 @@ $(call gb_LinkTarget_get_clean_target,%) :
$(call gb_LinkTarget_get_objects_list,$*) \
$(DLLTARGET) \
$(AUXTARGETS)) && \
cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -f && \
cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
rm -f $${RESPONSEFILE}
@ -478,6 +492,10 @@ $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
@ -525,11 +543,13 @@ $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
$(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
$(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
$(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
$(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
$(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS) $(CFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS) $(CXXFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS) $(OBJCXXFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS) $(OBJCFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
@ -856,6 +876,31 @@ endif
endef
define gb_LinkTarget_yacc_add_cpp_dep
$(call gb_CxxObject_get_target,$(2)) : $(call gb_YaccObject_get_target_source,$(1))
endef
###
# Add a bison grammars to the build.
# gb_LinkTarget_add_grammar(<component>,<grammar file>,<YYFLAGS>,<additional CXXFLAGS>,<list of objects that depend on the generated header>
#
define gb_LinkTarget_add_grammar
$(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
$(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
$(foreach obj,$(3),
$(call gb_LinkTarget_yacc_add_cpp_dep,$(2),$(obj)))
$(call gb_GenCxxObject_get_target,$(2)) : $(call gb_YaccObject_get_target_source,$(2))
$$(call gb_CxxObject__command,$$@,$(2),$$<,$$(call gb_GenCxxObject_get_dep_target,$(2)))
$(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
$(call gb_GenCxxObject_get_target,$(2)) : $(call gb_YaccObject_get_target_source,$(2)) $(call gb_YaccObject_get_target_include,$(2))
$(call gb_YaccObject_get_target_source,$(2)) $(call gb_YaccObject_get_target_include,$(2)) : $(call gb_YaccObject_get_grammar,$(gb_REPOS),$(2))
$$(call gb_YaccObject__command,$$@,$(2),$$<)
endef
define gb_LinkTarget_add_noexception_object
$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(CXXFLAGS))
endef
@ -928,6 +973,14 @@ define gb_LinkTarget_add_generated_exception_objects
$(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj)))
endef
###
# Add a bison grammars to the build.
# gb_LinkTarget_add_grammar(<component>,<list of grammar files>,<list of objects that depend on the generated header>
#
define gb_LinkTarget_add_grammars
$(foreach obj,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(obj),$(3)))
endef
define gb_LinkTarget_set_targettype
$(call gb_LinkTarget_get_target,$(1)) \
$(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)

View file

@ -76,6 +76,8 @@ gb_CustomTarget_get_target = $(WORKDIR)/CustomTarget/$(1).done
gb_CustomTarget_get_workdir = $(WORKDIR)/CustomTarget/$(1)
gb_CxxObject_get_target = $(WORKDIR)/CxxObject/$(1).o
gb_GenCxxObject_get_target = $(WORKDIR)/GenCxxObject/$(1).o
gb_YaccObject_get_target_source = $(WORKDIR)/GenCxxObject/$(1).cxx
gb_YaccObject_get_target_include = $(WORKDIR)/GenCxxObject/$(1).hxx
gb_Executable_get_external_headers_target = $(WORKDIR)/ExternalHeaders/Executable/$(1)
gb_Executable_get_headers_target = $(WORKDIR)/Headers/Executable/$(1)
gb_Jar_get_target = $(WORKDIR)/Jar/$(1).jar