app versioning/deployment

This commit is contained in:
tkl
2016-08-21 13:45:36 +02:00
parent 411a927704
commit 9ef624b52f
5 changed files with 101 additions and 51 deletions

View File

@@ -0,0 +1,9 @@
/* Release number include file */
#ifndef VERSION_H
#define VERSION_H
#define MAJOR_VERSION "unknown"
#define MINOR_VERSION "unknown"
#define BUILD_NUMBER "unknown"
#endif /* VERSION_H */

View File

@@ -11,6 +11,7 @@
#include "driver.h"
#include "shell.h"
#include "drive_ctrl.h"
#include "version.h"
static void *drive_turn_right_cb(const char *param);
static void *drive_turn_left_cb(const char *param);
@@ -19,6 +20,13 @@ static void *drive_retard_cb(const char *param);
static void *drive_halt_cb(const char *param);
static void *drive_forward_cb(const char *param);
static void *drive_backward_cb(const char *param);
static void *app_version(const char *param);
static struct command drive_forward = {
.command = "version",
.description = "Get application version.",
.command_callback = app_version,
};
static struct command drive_forward = {
.command = "f",
@@ -150,3 +158,18 @@ static void *drive_backward_cb(const char *param)
return NULL;
}
static void *app_version(const char *param)
{
#if 0
char *greeter = "engine_control version: ";
drv_write(shell_object.shell_device, greeter, strlen(greeter));
drv_write(shell_object.shell_device, MAJOR_VERSION, strlen(MAJOR_VERSION));
drv_write(shell_object.shell_device, ".", 1);
drv_write(shell_object.shell_device, MINOR_VERSION, strlen(MINOR_VERSION));
drv_write(shell_object.shell_device, ".", 1);
drv_write(shell_object.shell_device, BUILD_NUMBER, strlen(BUILD_NUMBER));
#endif
return NULL;
}

View File

@@ -0,0 +1,43 @@
#!/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_MAJOR"):
config["sw_major"] = os.environ["SW_MAJOR"]
if os.environ.has_key("SW_MINOR"):
config["sw_minor"] = os.environ["SW_MINOR"]
if os.environ.has_key("CI_BUILD_ID"):
config["build_id"] = os.environ["CI_BUILD_ID"]
return config
def generate_include(numbers):
f = open("source/application/include/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_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")
if numbers.has_key("build_id"):
f.write("#define BUILD_NUMBER\t\"" + numbers["build_id"] + "\"\n")
else:
f.write("#define BUILD_NUMBER\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:])