From d3ee998fa6c089d5b5af016c4f60eb74a518cdab Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 5 May 2016 19:10:08 -0300 Subject: [PATCH] APMrover2: 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. --- APMrover2/GCS_Mavlink.cpp | 1 + APMrover2/Log.cpp | 1 + APMrover2/Rover.cpp | 2 ++ APMrover2/Rover.h | 7 ++----- APMrover2/config.h | 10 ---------- APMrover2/system.cpp | 1 + APMrover2/version.h | 10 ++++++++++ 7 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 APMrover2/version.h diff --git a/APMrover2/GCS_Mavlink.cpp b/APMrover2/GCS_Mavlink.cpp index 20e58e7871..92f28fd2ba 100644 --- a/APMrover2/GCS_Mavlink.cpp +++ b/APMrover2/GCS_Mavlink.cpp @@ -1,6 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "Rover.h" +#include "version.h" // default sensors are present and healthy: gyro, accelerometer, 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_ANGULAR_RATE_CONTROL | MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION | MAV_SYS_STATUS_SENSOR_YAW_POSITION | MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL | MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS | MAV_SYS_STATUS_AHRS) diff --git a/APMrover2/Log.cpp b/APMrover2/Log.cpp index ec82a6b19a..07940ac486 100644 --- a/APMrover2/Log.cpp +++ b/APMrover2/Log.cpp @@ -1,6 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "Rover.h" +#include "version.h" #if LOGGING_ENABLED == ENABLED diff --git a/APMrover2/Rover.cpp b/APMrover2/Rover.cpp index b482097560..491882cb15 100644 --- a/APMrover2/Rover.cpp +++ b/APMrover2/Rover.cpp @@ -18,12 +18,14 @@ */ #include "Rover.h" +#include "version.h" Rover::Rover(void) : param_loader(var_info), channel_steer(NULL), channel_throttle(NULL), channel_learn(NULL), + DataFlash{FIRMWARE_STRING}, in_log_download(false), modes(&g.mode1), L1_controller(ahrs), diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index 6e6f05fb67..b763ea7cb8 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -13,14 +13,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* +/* main Rover class, containing all vehicle specific state */ #pragma once -#define THISFIRMWARE "ArduRover v3.0.0" -#define FIRMWARE_VERSION 3,0,0,FIRMWARE_VERSION_TYPE_OFFICIAL - #include #include @@ -128,7 +125,7 @@ private: RC_Channel *channel_throttle; RC_Channel *channel_learn; - DataFlash_Class DataFlash{FIRMWARE_STRING}; + DataFlash_Class DataFlash; bool in_log_download; diff --git a/APMrover2/config.h b/APMrover2/config.h index 4c45ba8598..937e39caae 100644 --- a/APMrover2/config.h +++ b/APMrover2/config.h @@ -303,13 +303,3 @@ #ifndef SONAR_ENABLED # define SONAR_ENABLED DISABLED #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 \ No newline at end of file diff --git a/APMrover2/system.cpp b/APMrover2/system.cpp index f0953a8aa2..a441065dab 100644 --- a/APMrover2/system.cpp +++ b/APMrover2/system.cpp @@ -7,6 +7,7 @@ The init_ardupilot function processes everything we need for an in - air restart *****************************************************************************/ #include "Rover.h" +#include "version.h" #if CLI_ENABLED == ENABLED diff --git a/APMrover2/version.h b/APMrover2/version.h new file mode 100644 index 0000000000..d4b7dae4db --- /dev/null +++ b/APMrover2/version.h @@ -0,0 +1,10 @@ +#pragma once + +#define THISFIRMWARE "ArduRover v3.0.0" +#define FIRMWARE_VERSION 3,0,0,FIRMWARE_VERSION_TYPE_OFFICIAL + +#ifndef GIT_VERSION +#define FIRMWARE_STRING THISFIRMWARE +#else +#define FIRMWARE_STRING THISFIRMWARE " (" GIT_VERSION ")" +#endif