Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
build: remove "repeated" rules for builtin .h
Browse files Browse the repository at this point in the history
This patch removed the common script sol-builtins-gen.py to generate
builtins definition symbols and introduce new schema to generate the
*builtins*.h with templates. Also removed all specific rules to generate
each header file.

Signed-off-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
  • Loading branch information
Leandro Dorileo committed Sep 2, 2015
1 parent 4d0f245 commit fd274c9
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 148 deletions.
87 changes: 0 additions & 87 deletions data/scripts/sol-builtins-gen.py

This file was deleted.

32 changes: 32 additions & 0 deletions data/templates/builtins-common.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* this file was auto-generated by Soletta's template.py script */

#pragma once

{{
import os
def gen_builtins(decl, item, array, count, builtins):
builtins = os.environ.get(builtins)
builtins = builtins.strip()
if builtins:
builtins = builtins.replace("-","_").split(" ")
decl = decl.replace("@NAME@", "%(NAME)s").replace("@name@", "%(name)s")
item = item.replace("@NAME@", "%(NAME)s").replace("@name@", "%(name)s")
for b in builtins:
vrs = {
"name": b.lower(),
"NAME": b.upper()
}
st.println("extern %s;" % (decl % vrs))
if builtins:
st.println("%s = {" % array)
for b in builtins:
vrs = {
"name": b.lower(),
"NAME": b.upper()
}
st.println(" %s," % (item % vrs))
st.println("};")
st.println("#define %s %d" % (count, len(builtins)))
}}
9 changes: 9 additions & 0 deletions src/lib/common/sol-pin-mux-builtins-gen.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{
st.include("../../../data/templates/builtins-common.tpl")

array = "static const struct sol_pin_mux *SOL_PIN_MUX_BUILTINS_ALL[]"
count = "SOL_PIN_MUX_BUILTIN_COUNT"
decl = "const struct sol_pin_mux SOL_PIN_MUX_@NAME@"
item = "&SOL_PIN_MUX_@NAME@"
gen_builtins(decl, item, array, count, "builtin-pin-mux")
}}
9 changes: 9 additions & 0 deletions src/lib/common/sol-platform-linux-micro-builtins-gen.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{
st.include("../../../data/templates/builtins-common.tpl")

array = "static const struct sol_platform_linux_micro_module *SOL_PLATFORM_LINUX_MICRO_MODULE_ALL[]"
count = "SOL_PLATFORM_LINUX_MICRO_MODULE_COUNT"
decl = "struct sol_platform_linux_micro_module SOL_PLATFORM_LINUX_MICRO_MODULE_@NAME@"
item = "&SOL_PLATFORM_LINUX_MICRO_MODULE_@NAME@"
gen_builtins(decl, item, array, count, "builtin-linux-micro")
}}
8 changes: 8 additions & 0 deletions src/lib/flow/sol-flow-builtins-gen.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{
st.include("../../../data/templates/builtins-common.tpl")
decl = "const struct sol_flow_node_type *sol_flow_foreach_builtin_node_type_@name@(bool (*)(void *, const struct sol_flow_node_type *), const void *)"
item = "sol_flow_foreach_builtin_node_type_@name@"
array = "static const void *SOL_FLOW_BUILTIN_NODE_TYPE_ALL[]"
count = "SOL_FLOW_BUILTIN_NODE_TYPE_COUNT"
gen_builtins(decl, item, array, count, "builtin-flows")
}}
9 changes: 9 additions & 0 deletions src/lib/flow/sol-flow-metatype-builtins-gen.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{
st.include("../../../data/templates/builtins-common.tpl")

array = "static const struct sol_flow_metatype *SOL_FLOW_METATYPE_BUILTINS_ALL[]"
count = "SOL_FLOW_METATYPE_BUILTINS_COUNT"
decl = "const struct sol_flow_metatype SOL_FLOW_METATYPE_@NAME@"
item = "&SOL_FLOW_METATYPE_@NAME@"
gen_builtins(decl, item, array, count, "builtin-flow-metatype")
}}
64 changes: 6 additions & 58 deletions tools/build/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ endif # $(M)
$(eval $(call inc-subdirs))
$(eval $(call extra-bins))

export builtin-flows
export builtin-linux-micro
export builtin-pin-mux
export builtin-flow-metatype

PRE_GEN += $(all-gen-hdrs) $(all-dest-hdr) $(all-dest-bin)

define make-warning
Expand Down Expand Up @@ -366,6 +371,7 @@ $(foreach gen,$(sort $(all-gens)),$(eval $(call make-gen,$(gen))))
define make-template-gen
$($(1)-dest): $(1) $(KCONFIG_CONFIG) $(MAKEFILE_GEN)
$(Q)echo " "GEN" "$$@
$(Q)$(MKDIR) -p $(dir $($(1)-dest))
$(Q)$(PYTHON) $(TEMPLATE_SCRIPT) --context-files $(KCONFIG_CONFIG) $(MAKEFILE_GEN) \
--template=$(1) --output=$($(1)-dest)
endef
Expand Down Expand Up @@ -403,64 +409,6 @@ $(FLOW_NODE_TYPES_H): $(NODE_TYPE_H_GEN_SCRIPT) $(KCONFIG_CONFIG)
$(Q)echo " "GEN" "$(@)
$(Q)$(PYTHON) $(NODE_TYPE_H_GEN_SCRIPT) $(FLOW_NODE_TYPES_H) $(all-gen-hdrs)

$(LINUX_MICRO_BUILTINS_H): $(BUILTINS_SCRIPT) $(KCONFIG_CONFIG)
$(Q)echo " "GEN" "$(@)
$(Q)$(PYTHON) $(BUILTINS_SCRIPT) --output=$@ \
--array="static const struct sol_platform_linux_micro_module *SOL_PLATFORM_LINUX_MICRO_MODULE_ALL[]" \
--count="SOL_PLATFORM_LINUX_MICRO_MODULE_COUNT" \
--decl="struct sol_platform_linux_micro_module SOL_PLATFORM_LINUX_MICRO_MODULE_@NAME@" \
--item="&SOL_PLATFORM_LINUX_MICRO_MODULE_@NAME@" \
$(subst -,_,$(builtin-linux-micro))

$(FLOW_BUILTINS_H): $(BUILTINS_SCRIPT) $(KCONFIG_CONFIG)
$(Q)echo " "GEN" "$(@)
$(Q)$(MKDIR) -p $(dir $(FLOW_BUILTINS_H))
$(Q)$(PYTHON) $(BUILTINS_SCRIPT) \
--output=$@ \
--array="static const void *SOL_FLOW_BUILTIN_NODE_TYPE_ALL[]" \
--count="SOL_FLOW_BUILTIN_NODE_TYPE_COUNT" \
--decl="const struct sol_flow_node_type *sol_flow_foreach_builtin_node_type_@name@(bool (*)(void *, const struct sol_flow_node_type *), const void *)" \
--item="sol_flow_foreach_builtin_node_type_@name@" \
$(subst -,_,$(builtin-flows))

$(PIN_MUX_BUILTINS_H): $(BUILTINS_SCRIPT) $(KCONFIG_CONFIG)
$(Q)echo " "GEN" "$(@)
$(Q)$(MKDIR) -p $(dir $(PIN_MUX_BUILTINS_H))
$(Q)$(PYTHON) $(BUILTINS_SCRIPT) \
--output=$@ \
--array="static const struct sol_pin_mux *SOL_PIN_MUX_BUILTINS_ALL[]" \
--count="SOL_PIN_MUX_BUILTIN_COUNT" \
--decl="const struct sol_pin_mux SOL_PIN_MUX_@NAME@" \
--item="&SOL_PIN_MUX_@NAME@" \
$(subst -,_,$(builtin-pin-mux))

$(FLOW_METATYPE_BUILTINS_H): $(BUILTINS_SCRIPT) $(KCONFIG_CONFIG)
$(Q)echo " "GEN" "$(@)
$(Q)$(PYTHON) $(BUILTINS_SCRIPT) \
--output=$@ \
--array="static const struct sol_flow_metatype *SOL_FLOW_METATYPE_BUILTINS_ALL[]" \
--count="SOL_FLOW_METATYPE_BUILTINS_COUNT" \
--decl="const struct sol_flow_metatype SOL_FLOW_METATYPE_@NAME@" \
--item="&SOL_FLOW_METATYPE_@NAME@" \
$(subst -,_,$(builtin-flow-metatype))

$(PC_GEN): $(PC_GEN_IN) $(KCONFIG_CONFIG) $(MAKEFILE_GEN)
$(Q)echo " "GEN" "$(PC_GEN)
$(Q)$(MKDIR) -p $(dir $(PC_GEN))
$(Q)$(PYTHON) $(TEMPLATE_SCRIPT) --context-files $(KCONFIG_CONFIG) $(MAKEFILE_GEN) \
--template=$(PC_GEN_IN) --output=$(PC_GEN)

$(NODE_TYPE_GEN_SCRIPT): $(NODE_TYPE_GEN_SCRIPT_IN) $(KCONFIG_CONFIG) $(MAKEFILE_GEN)
$(Q)echo " "GEN" "$(NODE_TYPE_GEN_SCRIPT)
$(Q)$(MKDIR) -p $(dir $(NODE_TYPE_GEN_SCRIPT))
$(Q)$(PYTHON) $(TEMPLATE_SCRIPT) --context-files $(KCONFIG_CONFIG) $(MAKEFILE_GEN) \
--template=$(NODE_TYPE_GEN_SCRIPT_IN) --output=$(NODE_TYPE_GEN_SCRIPT)

$(FLOW_NODE_TYPE_FIND): $(FLOW_NODE_TYPE_FIND_IN) $(KCONFIG_CONFIG) $(MAKEFILE_GEN)
$(Q)echo " "GEN" "$(FLOW_NODE_TYPE_FIND)
$(Q)$(PYTHON) $(TEMPLATE_SCRIPT) --context-files $(KCONFIG_CONFIG) $(MAKEFILE_GEN) \
--template=$(FLOW_NODE_TYPE_FIND_IN) --output=$(FLOW_NODE_TYPE_FIND)

$(KCONFIG_AUTOHEADER): $(DEPENDENCY_CACHE) $(KCONFIG_CONFIG) $(obj)/conf
$(Q)mkdir -p $(KCONFIG_INCLUDE)config $(KCONFIG_INCLUDE)generated
$(Q)$(obj)/conf -s --silentoldconfig Kconfig
29 changes: 26 additions & 3 deletions tools/build/Makefile.vars
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,27 @@ SAMPLE_CFLAGS := $(BIN_CFLAGS)
SAMPLE_LDFLAGS := $(BIN_LDFLAGS)

# generators
add-template = \
$(eval all-templates += $(1)) \
$(eval $(1)-dest := $(2)) \

## headers
LINUX_MICRO_BUILTINS_H := $(top_srcdir)src/lib/common/sol-platform-linux-micro-builtins-gen.h
LINUX_MICRO_BUILTINS_H_IN := $(top_srcdir)src/lib/common/sol-platform-linux-micro-builtins-gen.h.in
LINUX_MICRO_BUILTINS_H := $(build_stagedir)lib/common/sol-platform-linux-micro-builtins-gen.h

FLOW_BUILTINS_H_IN := $(top_srcdir)src/lib/flow/sol-flow-builtins-gen.h.in
FLOW_BUILTINS_H := $(build_stagedir)lib/flow/sol-flow-builtins-gen.h

$(call add-template,$(FLOW_BUILTINS_H_IN),$(FLOW_BUILTINS_H))

PIN_MUX_BUILTINS_H_IN := $(top_srcdir)src/lib/common/sol-pin-mux-builtins-gen.h.in
PIN_MUX_BUILTINS_H := $(build_stagedir)lib/common/sol-pin-mux-builtins-gen.h

FLOW_METATYPE_BUILTINS_H_IN := $(top_srcdir)src/lib/flow/sol-flow-metatype-builtins-gen.h.in
FLOW_METATYPE_BUILTINS_H := $(build_stagedir)lib/flow/sol-flow-metatype-builtins-gen.h

$(call add-template,$(FLOW_METATYPE_BUILTINS_H_IN),$(FLOW_METATYPE_BUILTINS_H))

NODE_TYPE_SCHEMA := $(top_srcdir)data/schemas/node-type-genspec.schema
NODE_TYPE_SCHEMA_DEST := $(build_flowdatadir)schemas/node-type-genspec.schema

Expand All @@ -272,6 +287,8 @@ BOARD_DETECT_DEST := $(build_datadir)board_detect.json
FLOW_NODE_TYPE_FIND := $(build_bindir)sol-flow-node-type-find.py
FLOW_NODE_TYPE_FIND_IN := $(SCRIPTDIR)sol-flow-node-type-find.py.in

$(call add-template,$(FLOW_NODE_TYPE_FIND_IN),$(FLOW_NODE_TYPE_FIND))

FLOW_BUILTINS_DESC := $(build_descdir)builtins.json

FLOW_MERGE_BUILTINS_SCRIPT := $(SCRIPTDIR)flow-merge-builtins.py
Expand All @@ -282,21 +299,25 @@ HEADER_GEN :=

ifeq (y,$(PLATFORM_LINUX_MICRO))
HEADER_GEN += $(LINUX_MICRO_BUILTINS_H)

$(call add-template,$(LINUX_MICRO_BUILTINS_H_IN),$(LINUX_MICRO_BUILTINS_H))
endif

ifeq (y,$(USE_PIN_MUX))
HEADER_GEN += $(PIN_MUX_BUILTINS_H)

$(call add-template,$(PIN_MUX_BUILTINS_H_IN),$(PIN_MUX_BUILTINS_H))
endif

HEADER_GEN += $(FLOW_BUILTINS_H)
HEADER_GEN += $(FLOW_METATYPE_BUILTINS_H)

## scripts
BUILTINS_SCRIPT := $(SCRIPTDIR)sol-builtins-gen.py

NODE_TYPE_GEN_SCRIPT := $(build_bindir)sol-flow-node-type-gen.py
NODE_TYPE_GEN_SCRIPT_IN := $(SCRIPTDIR)sol-flow-node-type-gen.py.in

$(call add-template,$(NODE_TYPE_GEN_SCRIPT_IN),$(NODE_TYPE_GEN_SCRIPT))

NODE_TYPE_STUB_GEN_SCRIPT := $(SCRIPTDIR)sol-flow-node-type-stub-gen.py
NODE_TYPE_STUB_GEN_TEST := $(top_srcdir)src/test-stub-gen/dummy.json
NODE_TYPE_STUB_GEN_DIR := $(build_stagedir)dummy/
Expand Down Expand Up @@ -341,6 +362,8 @@ FLOW_OIC_SPEC_DIR := $(top_srcdir)data/oic
PC_GEN := $(build_pcdir)soletta.pc
PC_GEN_IN := $(top_srcdir)pc/soletta.pc.in

$(call add-template,$(PC_GEN_IN),$(PC_GEN))

PRE_GEN := $(HEADER_GEN) $(KCONFIG_AUTOHEADER) $(KCONFIG_CONFIG) $(BSDEPS)
PRE_GEN += $(NODE_TYPE_GEN_SCRIPT) $(PC_GEN)

Expand Down

0 comments on commit fd274c9

Please sign in to comment.