aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-02 10:29:21 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-02 10:33:51 +0200
commit94aa98576149224e06455011be3f25901edce3cc (patch)
tree0df7f7a4f4afd5ee31b3ceda908553e95028fff8 /build-aux
parentbd6257f8eb1ed396747776faf6cc652023027447 (diff)
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.
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/qmi-codegen/qmi-codegen14
-rw-r--r--build-aux/qmi-codegen/utils.py28
2 files changed, 27 insertions, 15 deletions
diff --git a/build-aux/qmi-codegen/qmi-codegen b/build-aux/qmi-codegen/qmi-codegen
index 5f12228..a25c7f0 100755
--- a/build-aux/qmi-codegen/qmi-codegen
+++ b/build-aux/qmi-codegen/qmi-codegen
@@ -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)
diff --git a/build-aux/qmi-codegen/utils.py b/build-aux/qmi-codegen/utils.py
index bff3713..96c3ee7 100644
--- a/build-aux/qmi-codegen/utils.py
+++ b/build-aux/qmi-codegen/utils.py
@@ -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"