#!/usr/bin/python2 from sys import argv, exit from getopt import getopt from re import match, sub import os def get_current_numbers(): config = {} if os.environ.has_key("SW_KERNEL"): config["sw_kernel"] = os.environ["SW_KERNEL"] if os.environ.has_key("SW_MAJOR"): config["sw_major"] = os.environ["SW_MAJOR"] if os.environ.has_key("SW_MINOR"): config["sw_minor"] = os.environ["SW_MINOR"] return config def generate_include(numbers): f = open("source/firmware/version.h", "w") f.write("/* Release number include file */\n\n") f.write("#ifndef VERSION_H\n") f.write("#define VERSION_H\n\n") if numbers.has_key("sw_kernel"): f.write("#define KERNEL_VERSION\t\"" + numbers["sw_kernel"] + "\"\n") else: f.write("#define KERNEL_VERSION\t\"unknown\"\n") if numbers.has_key("sw_major"): f.write("#define MAJOR_VERSION\t\"" + numbers["sw_major"] + "\"\n") else: f.write("#define MAJOR_VERSION\t\"unknown\"\n") if numbers.has_key("sw_minor"): f.write("#define MINOR_VERSION\t\"" + numbers["sw_minor"] + "\"\n") else: f.write("#define MINOR_VERSION\t\"unknown\"\n") f.write("\n#endif /* VERSION_H */\n") f.close() def main(argv): numbers = get_current_numbers() generate_include(numbers) if __name__ == "__main__": main(argv[1:])