From baa287e5e569227971aadb0e59b51771763d4b91 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 5 May 2016 19:10:08 -0300 Subject: [PATCH] ArduPlane: use separate header for version macro Having the version macro in the config.h and consequently in the main vehicle header means that whenever the version changes we need to compiler the whole vehicle again. This would not be so bad if we weren't also appending the git hash in the version. In this case, whenever we commit to the repository we would need to recompile everything. Move to a separate header that is include only by its users. Then instead of compiling everything we will compile just a few files. --- ArduPlane/GCS_Mavlink.cpp | 1 + ArduPlane/Log.cpp | 1 + ArduPlane/Plane.cpp | 12 ++++++------ ArduPlane/Plane.h | 10 +++------- ArduPlane/config.h | 10 ---------- ArduPlane/system.cpp | 1 + ArduPlane/version.h | 10 ++++++++++ 7 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 ArduPlane/version.h diff --git a/ArduPlane/GCS_Mavlink.cpp b/ArduPlane/GCS_Mavlink.cpp index 223bc6615a..d3cb8741be 100644 --- a/ArduPlane/GCS_Mavlink.cpp +++ b/ArduPlane/GCS_Mavlink.cpp @@ -1,6 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "Plane.h" +#include "version.h" // default sensors are present and healthy: gyro, accelerometer, barometer, rate_control, attitude_stabilization, yaw_position, altitude control, x/y position control, motor_control #define MAVLINK_SENSOR_PRESENT_DEFAULT (MAV_SYS_STATUS_SENSOR_3D_GYRO | MAV_SYS_STATUS_SENSOR_3D_ACCEL | MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE | MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL | MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION | MAV_SYS_STATUS_SENSOR_YAW_POSITION | MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL | MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL | MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS | MAV_SYS_STATUS_AHRS | MAV_SYS_STATUS_SENSOR_RC_RECEIVER) diff --git a/ArduPlane/Log.cpp b/ArduPlane/Log.cpp index 7ae8f1e713..86f8d6ffdf 100644 --- a/ArduPlane/Log.cpp +++ b/ArduPlane/Log.cpp @@ -1,6 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "Plane.h" +#include "version.h" #if LOGGING_ENABLED == ENABLED diff --git a/ArduPlane/Plane.cpp b/ArduPlane/Plane.cpp index 2529166341..8d0e9bdfac 100644 --- a/ArduPlane/Plane.cpp +++ b/ArduPlane/Plane.cpp @@ -1,7 +1,4 @@ /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- - -#include "Plane.h" - /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,13 +13,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* - constructor for main Plane class - */ +#include "Plane.h" +#include "version.h" const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +/* + constructor for main Plane class + */ Plane::Plane(void) + : DataFlash{FIRMWARE_STRING} { // C++11 doesn't allow in-class initialisation of bitfields auto_state.takeoff_complete = true; diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 8283338ad1..0ea0e1d94f 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -1,12 +1,7 @@ /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- -#pragma once - -#define THISFIRMWARE "ArduPlane V3.6.0beta1" -#define FIRMWARE_VERSION 3,6,0,FIRMWARE_VERSION_TYPE_BETA - /* Lead developer: Andrew Tridgell - + Authors: Doug Weibel, Jose Julio, Jordi Munoz, Jason Short, Randy Mackay, Pat Hickey, John Arne Birkeland, Olivier Adler, Amilcar Lucas, Gregory Fletcher, Paul Riseborough, Brandon Jones, Jon Challinger, Tom Pittenger Thanks to: Chris Anderson, Michael Oborne, Paul Mather, Bill Premerlani, James Cohen, JB from rotorFX, Automatik, Fefenin, Peter Meister, Remzibi, Yury Smirnov, Sandro Benigno, Max Levine, Roberto Navoni, Lorenz Meier, Yury MonZon @@ -25,6 +20,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#pragma once //////////////////////////////////////////////////////////////////////////////// // Header includes @@ -171,7 +167,7 @@ private: // notification object for LEDs, buzzers etc (parameter set to false disables external leds) AP_Notify notify; - DataFlash_Class DataFlash{FIRMWARE_STRING}; + DataFlash_Class DataFlash; // has a log download started? bool in_log_download; diff --git a/ArduPlane/config.h b/ArduPlane/config.h index 890738085d..51b9d90b95 100644 --- a/ArduPlane/config.h +++ b/ArduPlane/config.h @@ -413,13 +413,3 @@ #ifndef PARACHUTE #define PARACHUTE ENABLED #endif - -/* - build a firmware version string. - GIT_VERSION comes from Makefile builds -*/ -#ifndef GIT_VERSION -#define FIRMWARE_STRING THISFIRMWARE -#else -#define FIRMWARE_STRING THISFIRMWARE " (" GIT_VERSION ")" -#endif diff --git a/ArduPlane/system.cpp b/ArduPlane/system.cpp index a4cf3f9f2a..53c5864913 100644 --- a/ArduPlane/system.cpp +++ b/ArduPlane/system.cpp @@ -1,6 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "Plane.h" +#include "version.h" /***************************************************************************** * The init_ardupilot function processes everything we need for an in - air restart diff --git a/ArduPlane/version.h b/ArduPlane/version.h new file mode 100644 index 0000000000..fdccefa562 --- /dev/null +++ b/ArduPlane/version.h @@ -0,0 +1,10 @@ +#pragma once + +#define THISFIRMWARE "ArduPlane V3.6.0beta1" +#define FIRMWARE_VERSION 3,6,0,FIRMWARE_VERSION_TYPE_BETA + +#ifndef GIT_VERSION +#define FIRMWARE_STRING THISFIRMWARE +#else +#define FIRMWARE_STRING THISFIRMWARE " (" GIT_VERSION ")" +#endif