Add generate-versions-h.js and versions.h. Execute generate-versions-h.js from make-release.js
This commit is contained in:
41
scripts/generate-versions-h.js
Executable file
41
scripts/generate-versions-h.js
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const versionPropertyPrefixes = ['firmware', 'deviceProtocol', 'moduleProtocol', 'userConfig', 'hardwareConfig'];
|
||||||
|
const patchVersions = ['Major', 'Minor', 'Patch'];
|
||||||
|
const package = JSON.parse(fs.readFileSync(`${__dirname}/package.json`));
|
||||||
|
|
||||||
|
const versionVariables = versionPropertyPrefixes.map(versionPropertyPrefix => {
|
||||||
|
const versionPropertyName = `${versionPropertyPrefix}Version`
|
||||||
|
const versionPropertyValues = package[versionPropertyName].split('.');
|
||||||
|
return patchVersions.map(patchVersion => {
|
||||||
|
const versionPropertyValue = versionPropertyValues.shift();
|
||||||
|
const versionPropertyMacroName = `${versionPropertyPrefix}${patchVersion}Version`.split(/(?=[A-Z])/).join('_').toUpperCase()
|
||||||
|
return ` #define ${versionPropertyMacroName} ${versionPropertyValue}`;
|
||||||
|
}).join('\n') + '\n';
|
||||||
|
}).join('\n');
|
||||||
|
|
||||||
|
fs.writeFileSync(`${__dirname}/../shared/versions.h`,
|
||||||
|
`// Please do not edit this file by hand!
|
||||||
|
// It is to be regenerated by /scripts/generate-versions-h.js
|
||||||
|
|
||||||
|
#ifndef __VERSIONS_H__
|
||||||
|
#define __VERSIONS_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "fsl_common.h"
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t major;
|
||||||
|
uint16_t minor;
|
||||||
|
uint16_t patch;
|
||||||
|
} version_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
${versionVariables}
|
||||||
|
#endif
|
||||||
|
`);
|
||||||
@@ -5,6 +5,8 @@ require('shelljs/global');
|
|||||||
config.fatal = true;
|
config.fatal = true;
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
|
|
||||||
|
exec(`${__dirname}/generate-versions-h.js`);
|
||||||
|
|
||||||
const package = JSON.parse(fs.readFileSync(`${__dirname}/package.json`));
|
const package = JSON.parse(fs.readFileSync(`${__dirname}/package.json`));
|
||||||
const version = package.firmwareVersion;
|
const version = package.firmwareVersion;
|
||||||
const releaseName = `uhk-firmware-${version}`;
|
const releaseName = `uhk-firmware-${version}`;
|
||||||
|
|||||||
41
shared/versions.h
Normal file
41
shared/versions.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Please do not edit this file by hand!
|
||||||
|
// It is to be regenerated by /scripts/generate-versions-h.js
|
||||||
|
|
||||||
|
#ifndef __VERSIONS_H__
|
||||||
|
#define __VERSIONS_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "fsl_common.h"
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t major;
|
||||||
|
uint16_t minor;
|
||||||
|
uint16_t patch;
|
||||||
|
} version_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
#define FIRMWARE_MAJOR_VERSION 6
|
||||||
|
#define FIRMWARE_MINOR_VERSION 0
|
||||||
|
#define FIRMWARE_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#define DEVICE_PROTOCOL_MAJOR_VERSION 3
|
||||||
|
#define DEVICE_PROTOCOL_MINOR_VERSION 0
|
||||||
|
#define DEVICE_PROTOCOL_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#define MODULE_PROTOCOL_MAJOR_VERSION 3
|
||||||
|
#define MODULE_PROTOCOL_MINOR_VERSION 0
|
||||||
|
#define MODULE_PROTOCOL_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#define USER_CONFIG_MAJOR_VERSION 4
|
||||||
|
#define USER_CONFIG_MINOR_VERSION 0
|
||||||
|
#define USER_CONFIG_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#define HARDWARE_CONFIG_MAJOR_VERSION 1
|
||||||
|
#define HARDWARE_CONFIG_MINOR_VERSION 0
|
||||||
|
#define HARDWARE_CONFIG_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user