Fixed the version naming

This commit is contained in:
garfieldG
2017-07-05 18:26:26 +03:00
committed by Lorenz Meier
parent 7a9e31f440
commit 44e148151b
2 changed files with 46 additions and 11 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ try:
except: except:
old_header = '' old_header = ''
git_tag = subprocess.check_output('git describe --always --tags'.split(), git_tag = subprocess.check_output('git describe --always --tags --dirty'.split(),
stderr=subprocess.STDOUT).decode('utf-8').strip() stderr=subprocess.STDOUT).decode('utf-8').strip()
git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
stderr=subprocess.STDOUT).decode('utf-8').strip() stderr=subprocess.STDOUT).decode('utf-8').strip()
@@ -23,7 +23,7 @@ try:
except: except:
git_branch_name = '' git_branch_name = ''
git_version_short = git_version[0:16] git_version_short = git_version[0:16]
nuttx_git_tag = subprocess.check_output('git describe --always --tags'.split(), nuttx_git_tag = subprocess.check_output('git describe --always --tags --dirty'.split(),
cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip().replace("nuttx-","v") cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip().replace("nuttx-","v")
nuttx_git_tag = re.sub('-.*','.0',nuttx_git_tag) nuttx_git_tag = re.sub('-.*','.0',nuttx_git_tag)
nuttx_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), nuttx_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
+44 -9
View File
@@ -58,6 +58,27 @@ enum FIRMWARE_TYPE {
FIRMWARE_TYPE_RELEASE = 255 FIRMWARE_TYPE_RELEASE = 255
}; };
typedef enum {
PATCH=0,
MINOR=8,
MAJOR=16
} version_type_t;
static void string_to_int(int8_t mag, version_type_t v_type, uint32_t *ver, int start, const char *tag)
{
const char *curr = &tag[start];
uint32_t temp_ver = 0;
while (curr <= &tag[mag])
{
temp_ver = (temp_ver << 3) + (temp_ver << 1) + (*curr - '0');
curr++;
}
*ver = (temp_ver << v_type) + *ver;
}
/** /**
* Convert a version tag string to a number * Convert a version tag string to a number
* @param tag version tag in one of the following forms: * @param tag version tag in one of the following forms:
@@ -74,6 +95,7 @@ static uint32_t version_tag_to_number(const char *tag)
unsigned mag = 0; unsigned mag = 0;
int32_t type = -1; int32_t type = -1;
unsigned dashcount = 0; unsigned dashcount = 0;
version_type_t v_type = PATCH;
for (int i = len - 1; i >= 0; i--) { for (int i = len - 1; i >= 0; i--) {
@@ -82,20 +104,33 @@ static uint32_t version_tag_to_number(const char *tag)
} }
if (tag[i] >= '0' && tag[i] <= '9') { if (tag[i] >= '0' && tag[i] <= '9') {
if (mag < 32) { if (!mag)
char number = tag[i] - '0'; {
mag = i;
ver += (number << mag);
mag += 4;
} }
} else if (tag[i] == '.') { if (i == 0)
if (mag % 8) { {
mag += 4; string_to_int(mag, v_type, &ver, i, tag);
} }
continue; } else if ((tag[i] == '.') || (i==0)) {
string_to_int(mag, v_type, &ver, (i + 1), tag);
mag = 0;
switch(v_type)
{
case PATCH:
v_type = MINOR;
break;
case MINOR:
v_type = MAJOR;
break;
case MAJOR:
default:
break;
}
} else if (i > 3 && type == -1) { } else if (i > 3 && type == -1) {
/* scan and look for signature characters for each type */ /* scan and look for signature characters for each type */
const char *curr = &tag[i - 1]; const char *curr = &tag[i - 1];