* gentpl.py: Use Autogen macros so that the output template file
(Makefile.tpl) size is reduced.
This commit is contained in:
parent
fc5efcc083
commit
8667a314ba
2 changed files with 105 additions and 14 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-08-25 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
* gentpl.py: Use Autogen macros so that the output template file
|
||||
(Makefile.tpl) size is reduced.
|
||||
|
||||
2011-09-29 Mads Kiilerich <mads@kiilerich.com>
|
||||
|
||||
* grub-core/Makefile.core.def (kernel): Add kern/i386/int.S to
|
||||
|
|
114
gentpl.py
114
gentpl.py
|
@ -183,6 +183,17 @@ def foreach_platform_specific_value(platform, suffix, nonetag, closure):
|
|||
r += "[+ ELSE +][+ FOR " + nonetag + " +]" + closure("[+ ." + nonetag + " +]") + "[+ ENDFOR +][+ ENDIF +]"
|
||||
return r
|
||||
|
||||
#
|
||||
# Returns autogen code that defines an autogen macro using the
|
||||
# definition given in the 'snippet'.
|
||||
#
|
||||
def define_autogen_macro(name, snippet):
|
||||
r = ""
|
||||
r += "[+ DEFINE " + name + " +]"
|
||||
r += snippet
|
||||
r += "[+ ENDDEF +]\n"
|
||||
return r
|
||||
|
||||
#
|
||||
# Template for handling values from sum of all groups for a platform,
|
||||
# for example:
|
||||
|
@ -245,10 +256,18 @@ def foreach_enabled_platform(closure):
|
|||
# emu_condition = COND_GRUB_EMU_USB;
|
||||
# };
|
||||
#
|
||||
def define_macro_for_platform_conditionals_if_statement(p):
|
||||
return define_autogen_macro(
|
||||
"if_" + p + "_conditionals",
|
||||
foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "if " + cond + "\n"))
|
||||
def define_macro_for_platform_conditionals_endif_statement(p):
|
||||
return define_autogen_macro(
|
||||
"endif_" + p + "_conditionals",
|
||||
foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "endif " + cond + "\n"))
|
||||
def under_platform_specific_conditionals(platform, snippet):
|
||||
r = foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "if " + cond + "\n")
|
||||
r = "[+ if_" + platform + "_conditionals +]"
|
||||
r += snippet
|
||||
r += foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "endif " + cond + "\n")
|
||||
r += "[+ endif_" + platform + "_conditionals +]"
|
||||
return r
|
||||
|
||||
def platform_specific_values(platform, suffix, nonetag):
|
||||
|
@ -261,18 +280,69 @@ def platform_values(platform, suffix):
|
|||
def extra_dist():
|
||||
return foreach_value("extra_dist", lambda value: value + " ")
|
||||
|
||||
def platform_sources(p): return platform_values(p, "")
|
||||
def platform_nodist_sources(p): return platform_values(p, "_nodist")
|
||||
def platform_dependencies(p): return platform_values(p, "dependencies", "_dependencies")
|
||||
def define_macro_for_platform_sources(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_sources",
|
||||
platform_values(p, ""))
|
||||
def define_macro_for_platform_nodist_sources(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_nodist_sources",
|
||||
platform_values(p, "_nodist"))
|
||||
def define_macro_for_platform_dependencies(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_dependencies",
|
||||
platform_values(p, "dependencies", "_dependencies"))
|
||||
def platform_sources(p): return "[+ get_" + p + "_sources +]"
|
||||
def platform_nodist_sources(p): return "[+ get_" + p + "_nodist_sources +]"
|
||||
def platform_dependencies(p): return "[+ get_" + p + "_dependencies +]"
|
||||
|
||||
def platform_startup(p): return platform_specific_values(p, "_startup", "startup")
|
||||
def platform_ldadd(p): return platform_specific_values(p, "_ldadd", "ldadd")
|
||||
def platform_cflags(p): return platform_specific_values(p, "_cflags", "cflags")
|
||||
def platform_ldflags(p): return platform_specific_values(p, "_ldflags", "ldflags")
|
||||
def platform_cppflags(p): return platform_specific_values(p, "_cppflags", "cppflags")
|
||||
def platform_ccasflags(p): return platform_specific_values(p, "_ccasflags", "ccasflags")
|
||||
def platform_stripflags(p): return platform_specific_values(p, "_stripflags", "stripflags")
|
||||
def platform_objcopyflags(p): return platform_specific_values(p, "_objcopyflags", "objcopyflags")
|
||||
#
|
||||
# Returns Autogen code which defines the autogen macros that collect
|
||||
# platform specific values for cflags, ldflags, etc. tags.
|
||||
#
|
||||
def define_macro_for_platform_startup(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_startup",
|
||||
platform_specific_values(p, "_startup", "startup"))
|
||||
def define_macro_for_platform_cflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_cflags",
|
||||
platform_specific_values(p, "_cflags", "cflags"))
|
||||
def define_macro_for_platform_ldadd(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_ldadd",
|
||||
platform_specific_values(p, "_ldadd", "ldadd"))
|
||||
def define_macro_for_platform_ldflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_ldflags",
|
||||
platform_specific_values(p, "_ldflags", "ldflags"))
|
||||
def define_macro_for_platform_cppflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_cppflags",
|
||||
platform_specific_values(p, "_cppflags", "cppflags"))
|
||||
def define_macro_for_platform_ccasflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_ccasflags",
|
||||
platform_specific_values(p, "_ccasflags", "ccasflags"))
|
||||
def define_macro_for_platform_stripflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_stripflags",
|
||||
platform_specific_values(p, "_stripflags", "stripflags"))
|
||||
def define_macro_for_platform_objcopyflags(p):
|
||||
return define_autogen_macro(
|
||||
"get_" + p + "_objcopyflags",
|
||||
platform_specific_values(p, "_objcopyflags", "objcopyflags"))
|
||||
#
|
||||
# Autogen calls to invoke the above macros.
|
||||
#
|
||||
def platform_startup(p): return "[+ get_" + p + "_startup +]"
|
||||
def platform_ldadd(p): return "[+ get_" + p + "_ldadd +]"
|
||||
def platform_cflags(p): return "[+ get_" + p + "_cflags +]"
|
||||
def platform_ldflags(p): return "[+ get_" + p + "_ldflags +]"
|
||||
def platform_cppflags(p): return "[+ get_" + p + "_cppflags +]"
|
||||
def platform_ccasflags(p): return "[+ get_" + p + "_ccasflags +]"
|
||||
def platform_stripflags(p): return "[+ get_" + p + "_stripflags +]"
|
||||
def platform_objcopyflags(p): return "[+ get_" + p + "_objcopyflags +]"
|
||||
|
||||
#
|
||||
# Emit snippet only the first time through for the current name.
|
||||
|
@ -489,7 +559,6 @@ def script_rules():
|
|||
def data_rules():
|
||||
return rules("data", data)
|
||||
|
||||
print "[+ AutoGen5 template +]\n"
|
||||
a = module_rules()
|
||||
b = kernel_rules()
|
||||
c = image_rules()
|
||||
|
@ -499,6 +568,23 @@ f = script_rules()
|
|||
g = data_rules()
|
||||
z = global_variable_initializers()
|
||||
|
||||
print "[+ AutoGen5 template +]\n"
|
||||
for p in GRUB_PLATFORMS:
|
||||
print define_macro_for_platform_sources(p)
|
||||
print define_macro_for_platform_nodist_sources(p)
|
||||
# print define_macro_for_platform_dependencies(p)
|
||||
|
||||
print define_macro_for_platform_startup(p)
|
||||
print define_macro_for_platform_cflags(p)
|
||||
print define_macro_for_platform_ldadd(p)
|
||||
print define_macro_for_platform_ldflags(p)
|
||||
print define_macro_for_platform_cppflags(p)
|
||||
print define_macro_for_platform_ccasflags(p)
|
||||
print define_macro_for_platform_stripflags(p)
|
||||
print define_macro_for_platform_objcopyflags(p)
|
||||
|
||||
print define_macro_for_platform_conditionals_if_statement(p)
|
||||
print define_macro_for_platform_conditionals_endif_statement(p)
|
||||
# print z # initializer for all vars
|
||||
print a
|
||||
print b
|
||||
|
|
Loading…
Reference in a new issue