FBuild now has better autoconf-esque substitution
posted on August 23, 2009 - 04:50 PM PDT
by Erick Tryzelaar
filed under:
FBuild
bohan on reddit pointed out that my text.m4_substitute doesn't actually have anything to do with m4. So I replaced it with two autoconf inspired functions: text.autoconfig_config_file and text.autoconfig_config_header. Consider this source:
const char* foo = @foo@;
#undef HAVE_FOO
#undef HAVE_BAR
#undef HAVE_BAZ
If you use this function:
text.autoconf_config_file(ctx, 'foo.py', 'foo.h.in', {
'foo': '"FOO"',
})
which replicates the functionality of AC_CONFIG_FILES, you'll get:
const char* foo = "FOO";
#undef HAVE_FOO
#undef HAVE_BAR
#undef HAVE_BAZ
And if you process it with this:
text.autoconf_config_header(ctx, 'baz.h', 'baz.h.in', {
'foo': '"FOO"',
'HAVE_FOO': 1,
'HAVE_BAR': 0,
'HAVE_BAZ': '"BAZ"',
})
which replicates AC_CONFIG_HEADERS, you'll get:
const char* foo = "FOO";
#define HAVE_FOO 1
/* #undef HAVE_BAR */
#define HAVE_BAZ "BAZ"