Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set FW compile date in AUTOPILOT_VERSION.os_sw_version #7287

Merged
merged 9 commits into from Jun 18, 2019
14 changes: 11 additions & 3 deletions APMrover2/version.cpp
Expand Up @@ -13,8 +13,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Rover.h"

#define FORCE_VERSION_H_INCLUDE
#include "version.h"
#undef FORCE_VERSION_H_INCLUDE
Expand All @@ -28,14 +26,24 @@ const AP_FWVersion AP_FWVersion::fwver{
.fw_type = FW_TYPE,
#ifndef GIT_VERSION
.fw_string = THISFIRMWARE,
.fw_hash_str = "",
#else
.fw_string = THISFIRMWARE " (" GIT_VERSION ")",
.fw_hash_str = GIT_VERSION,
#endif
#ifdef CHIBIOS_GIT_VERSION
.middleware_name = nullptr,
.middleware_hash_str = nullptr,
#ifdef CHIBIOS_GIT_VERSION
.os_name = "ChibiOS",
.os_hash_str = CHIBIOS_GIT_VERSION,
#else
.os_name = nullptr,
.os_hash_str = nullptr,
#endif
#ifdef BUILD_DATE_YEAR
// encode build date in os_sw_version
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
#else
.os_sw_version = 0,
#endif
};
13 changes: 11 additions & 2 deletions AntennaTracker/version.cpp
Expand Up @@ -12,7 +12,6 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Tracker.h"

#define FORCE_VERSION_H_INCLUDE
#include "version.h"
Expand All @@ -27,14 +26,24 @@ const AP_FWVersion AP_FWVersion::fwver{
.fw_type = FW_TYPE,
#ifndef GIT_VERSION
.fw_string = THISFIRMWARE,
.fw_hash_str = "",
#else
.fw_string = THISFIRMWARE " (" GIT_VERSION ")",
.fw_hash_str = GIT_VERSION,
#endif
#ifdef CHIBIOS_GIT_VERSION
.middleware_name = nullptr,
.middleware_hash_str = nullptr,
#ifdef CHIBIOS_GIT_VERSION
.os_name = "ChibiOS",
.os_hash_str = CHIBIOS_GIT_VERSION,
#else
.os_name = nullptr,
.os_hash_str = nullptr,
#endif
#ifdef BUILD_DATE_YEAR
// encode build date in os_sw_version
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
#else
.os_sw_version = 0,
#endif
};
14 changes: 11 additions & 3 deletions ArduCopter/version.cpp
Expand Up @@ -13,8 +13,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Copter.h"

#define FORCE_VERSION_H_INCLUDE
#include "version.h"
#undef FORCE_VERSION_H_INCLUDE
Expand All @@ -28,14 +26,24 @@ const AP_FWVersion AP_FWVersion::fwver{
.fw_type = FW_TYPE,
#ifndef GIT_VERSION
.fw_string = THISFIRMWARE,
.fw_hash_str = "",
peterbarker marked this conversation as resolved.
Show resolved Hide resolved
#else
.fw_string = THISFIRMWARE " (" GIT_VERSION ")",
.fw_hash_str = GIT_VERSION,
#endif
#ifdef CHIBIOS_GIT_VERSION
.middleware_name = nullptr,
.middleware_hash_str = nullptr,
#ifdef CHIBIOS_GIT_VERSION
.os_name = "ChibiOS",
.os_hash_str = CHIBIOS_GIT_VERSION,
#else
.os_name = nullptr,
.os_hash_str = nullptr,
#endif
#ifdef BUILD_DATE_YEAR
// encode build date in os_sw_version
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
#else
.os_sw_version = 0,
#endif
};
16 changes: 12 additions & 4 deletions ArduPlane/version.cpp
Expand Up @@ -13,8 +13,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Plane.h"

#define FORCE_VERSION_H_INCLUDE
#include "version.h"
#undef FORCE_VERSION_H_INCLUDE
Expand All @@ -25,17 +23,27 @@ const AP_FWVersion AP_FWVersion::fwver{
.major = FW_MAJOR,
.minor = FW_MINOR,
.patch = FW_PATCH,
.fw_type = (enum FIRMWARE_VERSION_TYPE)(FW_TYPE),
.fw_type = FW_TYPE,
#ifndef GIT_VERSION
.fw_string = THISFIRMWARE,
.fw_hash_str = "",
#else
.fw_string = THISFIRMWARE " (" GIT_VERSION ")",
.fw_hash_str = GIT_VERSION,
#endif
#ifdef CHIBIOS_GIT_VERSION
.middleware_name = nullptr,
.middleware_hash_str = nullptr,
#ifdef CHIBIOS_GIT_VERSION
.os_name = "ChibiOS",
.os_hash_str = CHIBIOS_GIT_VERSION,
#else
.os_name = nullptr,
.os_hash_str = nullptr,
#endif
#ifdef BUILD_DATE_YEAR
// encode build date in os_sw_version
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
#else
.os_sw_version = 0,
#endif
};
14 changes: 11 additions & 3 deletions ArduSub/version.cpp
Expand Up @@ -13,8 +13,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Sub.h"

#define FORCE_VERSION_H_INCLUDE
#include "version.h"
#undef FORCE_VERSION_H_INCLUDE
Expand All @@ -28,14 +26,24 @@ const AP_FWVersion AP_FWVersion::fwver{
.fw_type = FW_TYPE,
#ifndef GIT_VERSION
.fw_string = THISFIRMWARE,
.fw_hash_str = "",
#else
.fw_string = THISFIRMWARE " (" GIT_VERSION ")",
.fw_hash_str = GIT_VERSION,
#endif
#ifdef CHIBIOS_GIT_VERSION
.middleware_name = nullptr,
.middleware_hash_str = nullptr,
#ifdef CHIBIOS_GIT_VERSION
.os_name = "ChibiOS",
.os_hash_str = CHIBIOS_GIT_VERSION,
#else
.os_name = nullptr,
.os_hash_str = nullptr,
#endif
#ifdef BUILD_DATE_YEAR
// encode build date in os_sw_version
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
#else
.os_sw_version = 0,
#endif
};
10 changes: 7 additions & 3 deletions Tools/ardupilotwaf/boards.py
Expand Up @@ -246,6 +246,9 @@ def configure_env(self, cfg, env):
cfg.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()
]

if cfg.env.build_dates:
env.build_dates = True

# We always want to use PRI format macros
cfg.define('__STDC_FORMAT_MACROS', 1)

Expand All @@ -259,9 +262,10 @@ def build(self, bld):
bld.ap_version_append_str('GIT_VERSION', bld.git_head_hash(short=True))
import time
ltime = time.localtime()
bld.ap_version_append_int('BUILD_DATE_YEAR', ltime.tm_year)
bld.ap_version_append_int('BUILD_DATE_MONTH', ltime.tm_mon)
bld.ap_version_append_int('BUILD_DATE_DAY', ltime.tm_mday)
if bld.env.build_dates:
bld.ap_version_append_int('BUILD_DATE_YEAR', ltime.tm_year)
bld.ap_version_append_int('BUILD_DATE_MONTH', ltime.tm_mon)
bld.ap_version_append_int('BUILD_DATE_DAY', ltime.tm_mday)

def embed_ROMFS_files(self, ctx):
'''embed some files using AP_ROMFS'''
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Common/AP_FWVersion.h
Expand Up @@ -17,6 +17,7 @@ class AP_FWVersion {
const char *middleware_hash_str;
const char *os_name;
const char *os_hash_str;
const uint32_t os_sw_version;

static const AP_FWVersion &get_fwverz() { return fwver; }

Expand Down
3 changes: 1 addition & 2 deletions libraries/GCS_MAVLink/GCS_Common.cpp
Expand Up @@ -2391,7 +2391,6 @@ void GCS_MAVLINK::send_autopilot_version() const
{
uint32_t flight_sw_version;
uint32_t middleware_sw_version = 0;
uint32_t os_sw_version = 0;
uint32_t board_version = 0;
char flight_custom_version[MAVLINK_MSG_AUTOPILOT_VERSION_FIELD_FLIGHT_CUSTOM_VERSION_LEN]{};
char middleware_custom_version[MAVLINK_MSG_AUTOPILOT_VERSION_FIELD_MIDDLEWARE_CUSTOM_VERSION_LEN]{};
Expand Down Expand Up @@ -2427,7 +2426,7 @@ void GCS_MAVLINK::send_autopilot_version() const
capabilities(),
flight_sw_version,
middleware_sw_version,
os_sw_version,
version.os_sw_version,
board_version,
(uint8_t *)flight_custom_version,
(uint8_t *)middleware_custom_version,
Expand Down
8 changes: 7 additions & 1 deletion libraries/GCS_MAVLink/GCS_Dummy.h
Expand Up @@ -7,7 +7,13 @@ const AP_FWVersion AP_FWVersion::fwver
minor: 1,
patch: 4,
fw_type: FIRMWARE_VERSION_TYPE_DEV,
fw_string: "Dummy GCS"
fw_string: "Dummy GCS",
fw_hash_str: "",
middleware_name: "",
middleware_hash_str: "",
os_name: "",
os_hash_str: "",
peterbarker marked this conversation as resolved.
Show resolved Hide resolved
os_sw_version: 0
};

const struct GCS_MAVLINK::stream_entries GCS_MAVLINK::all_stream_entries[] {};
Expand Down
8 changes: 7 additions & 1 deletion libraries/GCS_MAVLink/examples/routing/routing.cpp
Expand Up @@ -18,7 +18,13 @@ const AP_FWVersion AP_FWVersion::fwver
minor: 1,
patch: 4,
fw_type: FIRMWARE_VERSION_TYPE_DEV,
fw_string: "routing example"
fw_string: "routing example",
fw_hash_str: "",
middleware_name: "",
middleware_hash_str: "",
os_name: "",
os_hash_str: "",
os_sw_version: 0
};

const struct GCS_MAVLINK::stream_entries GCS_MAVLINK::all_stream_entries[] {};
Expand Down
4 changes: 4 additions & 0 deletions wscript
Expand Up @@ -196,6 +196,10 @@ configuration in order to save typing.
default=False,
help="Enable SITL RGBLed")

g.add_option('--build-dates', action='store_true',
default=False,
help="Include build date in binaries. Appears in AUTOPILOT_VERSION.os_sw_version")

g.add_option('--sitl-flash-storage',
action='store_true',
default=False,
Expand Down