build: cleanup dependencies

The service-specific implementation header needs to include only the raw
enums/flags headers; while the source needs to include the enum/flags types
headers.
This commit is contained in:
Aleksander Morgado 2012-08-02 10:29:21 +02:00
parent bd6257f8eb
commit 94aa985761
5 changed files with 39 additions and 27 deletions

View File

@ -49,12 +49,6 @@ def codegen_main():
output_file_c = open(opts.output + ".c", 'w')
output_file_h = open(opts.output + ".h", 'w')
# Add common stuff to the output files
utils.add_copyright(output_file_c);
utils.add_copyright(output_file_h);
utils.add_header_start(output_file_h, os.path.basename(opts.output))
utils.add_source_start(output_file_c, os.path.basename(opts.output))
# Load all common types
common_object_list_json = []
opts.include.append(opts.input)
@ -68,10 +62,16 @@ def codegen_main():
# Load database file contents
database_file_contents = utils.read_json_file(opts.input)
# Get our message collection
# Build message list
object_list_json = json.loads(database_file_contents)
message_list = MessageList(object_list_json, common_object_list_json)
# Add common stuff to the output files
utils.add_copyright(output_file_c);
utils.add_copyright(output_file_h);
utils.add_header_start(output_file_h, os.path.basename(opts.output), message_list.service)
utils.add_source_start(output_file_c, os.path.basename(opts.output))
# Emit the message creation/parsing code
message_list.emit(output_file_h, output_file_c)

View File

@ -60,24 +60,34 @@ def build_header_guard(output_name):
"""
Write the common header start chunk
"""
def add_header_start(f, output_name):
template = string.Template(
"\n"
"#ifndef ${guard}\n"
"#define ${guard}\n"
def add_header_start(f, output_name, service):
translations = { 'guard' : build_header_guard(output_name),
'service' : build_underscore_name(service) }
template = (
"\n"
"#include <glib.h>\n"
"#include <glib-object.h>\n"
"#include <gio/gio.h>\n"
"\n"
"#include \"qmi-enum-types.h\"\n"
"#include \"qmi-flags64-types.h\"\n"
"#include \"qmi-enums.h\"\n")
# CTL doesn't have enums
if service != 'CTL':
template += (
"#include \"qmi-enums-${service}.h\"\n")
# CTL and WDS don't have flags64
if service != 'CTL' and service != 'WDS':
template += (
"#include \"qmi-flags64-${service}.h\"\n")
template += (
"#include \"qmi-message.h\"\n"
"#include \"qmi-client.h\"\n"
"\n"
"#ifndef ${guard}\n"
"#define ${guard}\n"
"\n"
"G_BEGIN_DECLS\n"
"\n")
f.write(template.substitute(guard = build_header_guard(output_name)))
f.write(string.Template(template).substitute(translations))
"""
@ -101,6 +111,8 @@ def add_source_start(f, output_name):
"#include <string.h>\n"
"\n"
"#include \"${name}.h\"\n"
"#include \"qmi-enum-types.h\"\n"
"#include \"qmi-flags64-types.h\"\n"
"#include \"qmi-error-types.h\"\n"
"#include \"qmi-device.h\"\n"
"#include \"qmi-utils.h\"\n"

View File

@ -25,10 +25,10 @@ qmi-error-types.c: qmi-errors.h qmi-error-types.h $(top_srcdir)/build-aux/templa
qmi-errors.h > $@
# Enum/Flag types
ENUMS = qmi-enums.h qmi-enums-wds.h qmi-enums-dms.h qmi-enums-nas.h qmi-dms.h qmi-wds.h qmi-nas.h qmi-ctl.h
qmi-enum-types.h: $(ENUMS) $(top_srcdir)/build-aux/templates/qmi-enum-types-template.h qmi-ctl.stamp qmi-dms.stamp qmi-wds.stamp qmi-nas.stamp
ENUMS = qmi-enums.h qmi-enums-wds.h qmi-enums-dms.h qmi-enums-nas.h
qmi-enum-types.h: $(ENUMS) $(top_srcdir)/build-aux/templates/qmi-enum-types-template.h
$(AM_V_GEN) $(GLIB_MKENUMS) \
--fhead "#ifndef __LIBQMI_GLIB_ENUM_TYPES_H__\n#define __LIBQMI_GLIB_ENUM_TYPES_H__\n#include \"qmi-enums.h\"\n#include \"qmi-enums-wds.h\"\n#include \"qmi-enums-dms.h\"\n#include \"qmi-enums-nas.h\"\n#include \"qmi-ctl.h\"\n#include \"qmi-dms.h\"\n#include \"qmi-wds.h\"\n#include \"qmi-nas.h\"\n" \
--fhead "#ifndef __LIBQMI_GLIB_ENUM_TYPES_H__\n#define __LIBQMI_GLIB_ENUM_TYPES_H__\n#include \"qmi-enums.h\"\n#include \"qmi-enums-wds.h\"\n#include \"qmi-enums-dms.h\"\n#include \"qmi-enums-nas.h\"\n" \
--template $(top_srcdir)/build-aux/templates/qmi-enum-types-template.h \
--ftail "#endif /* __LIBQMI_GLIB_ENUM_TYPES_H__ */\n" \
$(ENUMS) > $@
@ -41,7 +41,7 @@ qmi-enum-types.c: $(ENUMS) qmi-enum-types.h $(top_srcdir)/build-aux/templates/qm
# 64bit flag types
FLAGS64 = qmi-flags64-dms.h qmi-flags64-nas.h
qmi-flags64-types.h: $(FLAGS64) $(top_srcdir)/build-aux/templates/qmi-flags64-types-template.h qmi-dms.stamp qmi-nas.stamp
qmi-flags64-types.h: $(FLAGS64) $(top_srcdir)/build-aux/templates/qmi-flags64-types-template.h
$(AM_V_GEN) $(GLIB_MKENUMS) \
--fhead "#ifndef __LIBQMI_GLIB_FLAGS64_TYPES_H__\n#define __LIBQMI_GLIB_FLAGS64_TYPES_H__\n#include \"qmi-flags64-dms.h\"\n#include \"qmi-flags64-nas.h\"\n" \
--template $(top_srcdir)/build-aux/templates/qmi-flags64-types-template.h \
@ -103,13 +103,13 @@ qmi-device.c: qmi-error-types.h qmi-enum-types.h
qmi-client.c: qmi-error-types.h qmi-enum-types.h
qmi-message.c: qmi-error-types.h qmi-enum-types.h qmi-ctl.h qmi-dms.h qmi-wds.h qmi-nas.h
qmi-ctl.h: qmi-ctl.stamp
qmi-ctl.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-ctl.stamp
qmi-dms.h: qmi-dms.stamp
qmi-dms.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-dms.stamp
qmi-wds.h: qmi-wds.stamp
qmi-wds.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-wds.stamp
qmi-nas.h: qmi-nas.stamp
qmi-nas.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-nas.stamp
qmi-ctl.c: qmi-error-types.h qmi-enum-types.h qmi-ctl.h
qmi-dms.h: qmi-dms.stamp qmi-enums-dms.h
qmi-dms.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-dms.h
qmi-wds.h: qmi-wds.stamp qmi-enums-wds.h
qmi-wds.c: qmi-error-types.h qmi-enum-types.h qmi-wds.h
qmi-nas.h: qmi-nas.stamp qmi-enums-nas.h
qmi-nas.c: qmi-error-types.h qmi-enum-types.h qmi-flags64-types.h qmi-nas.h
libqmi_glib_la_SOURCES = \
libqmi-glib.h \

View File

@ -23,7 +23,6 @@
#ifndef _LIBQMI_GLIB_H_
#define _LIBQMI_GLIB_H_
#include "qmi-errors.h"
#include "qmi-error-types.h"
#include "qmi-enum-types.h"
#include "qmi-flags64-types.h"

View File

@ -24,6 +24,7 @@
#define _LIBQMI_GLIB_QMI_DEVICE_H_
#include <glib-object.h>
#include <gio/gio.h>
#include "qmi-enums.h"
#include "qmi-message.h"