This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/1593 utils/conv_gen.py: add header generation feature Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea --- M utils/conv_gen.py 1 file changed, 43 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/1593/1 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index 34e164a..24dc395 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -168,6 +168,20 @@ # Up to 12 numbers should be placed per line print_formatted(self.puncture, "%3d, ", 12, fi) + def print_description(self, fi, brief = False): + if brief is True: + fi.write("/*! \\brief ") + fi.write("structure describing %s\n" + % self.description[0]) + for line in self.description[1:]: + fi.write(" * %s\n" % line) + else: + fi.write("/**\n") + for line in self.description: + fi.write(" * %s\n" % line) + + fi.write(" */\n") + def print_state_and_output(self, fi): pack = lambda n: \ sum([x << (self.rate_inv - i - 1) for i, x in enumerate(n)]) @@ -205,10 +219,7 @@ # Write description as a multi-line comment if self.description is not None: - fi.write("/**\n") - for line in self.description: - fi.write(" * %s\n" % line) - fi.write(" */\n") + self.print_description(fi) # Print a final convolutional code definition fi.write("const struct osmo_conv_code %s_%s = {\n" % (pref, self.name)) @@ -347,12 +358,38 @@ f.write("};\n") +def generate_header(codes, path, prefix, description = None): + # Open a new file for writing + f = open(os.path.join(path, prefix + ".h"), 'w') + + # Print license and includes + f.write(mod_license + "\n") + f.write("#pragma once\n\n") + f.write("#include <stdint.h>\n") + f.write("#include <osmocom/core/conv.h>\n\n") + + # Print general file description if preset + if description is not None: + f.write("/*! \\file %s.h\n" % prefix) + f.write(" * %s\n" % description) + f.write(" */\n\n") + + sys.stderr.write("Generating header file...\n") + + # Generate declarations one by one + for code in codes.conv_codes: + sys.stderr.write("Generate '%s' declaration\n" % code.name) + code.print_description(f, True) + f.write("extern const struct osmo_conv_code %s_%s;\n\n" + % (prefix, code.name)) + def print_help(error = None): print("Usage: python %s action code_type [path]" % sys.argv[0]) print("\nAvailable actions:") print(" gen_codes - generate convolutional code definitions") print(" gen_vectors - generate test vectors") + print(" gen_header - generate header file") print("\nAvailable code types:") print(" gsm - GSM specific codes") @@ -388,6 +425,8 @@ generate_codes(codes, path, "gsm0503") elif action == "gen_vectors": generate_vectors(codes, path, "gsm0503", inc) + elif action == "gen_header": + generate_header(codes, path, "gsm0503") else: print_help("Error: Unknown action!") sys.exit(1) -- To view, visit https://gerrit.osmocom.org/1593 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>