From b0b44f6c9e4c4d763a5c2df10db172930f5b8045 Mon Sep 17 00:00:00 2001
From: Terraneo Federico <fede.tft@miosix.org>
Date: Sat, 24 May 2014 10:44:09 +0000
Subject: [PATCH] Added versioning to miosix_settings.h and board_settings.h to
 prevent misconfiguration when they are updated

---
 miosix/_doc/textdoc/Changelog.txt              |  2 ++
 .../lpc2138_miosix_board/board_settings.h      |  8 +++++++-
 .../board_settings.h                           |  8 +++++++-
 .../stm32f103ve_mp3v2/board_settings.h         |  8 +++++++-
 .../stm32f103ve_strive_mini/board_settings.h   |  8 +++++++-
 .../stm32f103ze_redbull_v2/board_settings.h    |  8 +++++++-
 .../stm32f103ze_stm3210e-eval/board_settings.h |  8 +++++++-
 .../stm32f205rg_sony-newman/board_settings.h   |  8 +++++++-
 .../stm32f207ig_stm3220g-eval/board_settings.h |  8 +++++++-
 .../stm32f207ze_als_camboard/board_settings.h  |  8 +++++++-
 .../stm32f207zg_EthBoardV2/board_settings.h    |  8 +++++++-
 .../stm32l151c8_als_mainboard/board_settings.h |  8 +++++++-
 .../stm32f407vg_bitsboard/board_settings.h     |  8 +++++++-
 .../board_settings.h                           |  8 +++++++-
 .../board_settings.h                           |  6 ++++++
 miosix/config/miosix_settings.h                |  8 +++++++-
 miosix/util/version.cpp                        |  2 +-
 miosix/util/version.h                          | 18 +++++++++++++++---
 18 files changed, 122 insertions(+), 18 deletions(-)

diff --git a/miosix/_doc/textdoc/Changelog.txt b/miosix/_doc/textdoc/Changelog.txt
index 5a89dfb9..6d8ed164 100644
--- a/miosix/_doc/textdoc/Changelog.txt
+++ b/miosix/_doc/textdoc/Changelog.txt
@@ -1,5 +1,7 @@
 Changelog for Miosix np embedded OS
 
+- Added versioning to miosix_settings.h and board_settings.h to prevent
+  misconfiguration when those files are updated.
 - Moved board_settings.h in the config directory to allow out of git tree
   projects to tweak those files without editing files in the Miosix git repo.
 - Added miosix/_tools/init_project_out_of_git_tree.pl script to help set up
diff --git a/miosix/config/arch/arm7_lpc2000/lpc2138_miosix_board/board_settings.h b/miosix/config/arch/arm7_lpc2000/lpc2138_miosix_board/board_settings.h
index 5d2afdbc..b870be9d 100644
--- a/miosix/config/arch/arm7_lpc2000/lpc2138_miosix_board/board_settings.h
+++ b/miosix/config/arch/arm7_lpc2000/lpc2138_miosix_board/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2010 by Terraneo Federico                               *
+ *   Copyright (C) 2010, 2011, 2012, 2013, 2014 by Terraneo Federico       *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32/stm32f100rb_stm32vldiscovery/board_settings.h b/miosix/config/arch/cortexM3_stm32/stm32f100rb_stm32vldiscovery/board_settings.h
index 61b0cf3a..24e451e3 100644
--- a/miosix/config/arch/cortexM3_stm32/stm32f100rb_stm32vldiscovery/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32/stm32f100rb_stm32vldiscovery/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by Terraneo Federico                               *
+ *   Copyright (C) 2011, 2012, 2013, 2014 by Terraneo Federico             *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32/stm32f103ve_mp3v2/board_settings.h b/miosix/config/arch/cortexM3_stm32/stm32f103ve_mp3v2/board_settings.h
index fdfc344c..0281e722 100644
--- a/miosix/config/arch/cortexM3_stm32/stm32f103ve_mp3v2/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32/stm32f103ve_mp3v2/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by Terraneo Federico                               *
+ *   Copyright (C) 2011, 2012, 2013, 2014 by Terraneo Federico             *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32/stm32f103ve_strive_mini/board_settings.h b/miosix/config/arch/cortexM3_stm32/stm32f103ve_strive_mini/board_settings.h
index fdfc344c..0281e722 100644
--- a/miosix/config/arch/cortexM3_stm32/stm32f103ve_strive_mini/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32/stm32f103ve_strive_mini/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by Terraneo Federico                               *
+ *   Copyright (C) 2011, 2012, 2013, 2014 by Terraneo Federico             *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32/stm32f103ze_redbull_v2/board_settings.h b/miosix/config/arch/cortexM3_stm32/stm32f103ze_redbull_v2/board_settings.h
index 149922b7..766ee972 100644
--- a/miosix/config/arch/cortexM3_stm32/stm32f103ze_redbull_v2/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32/stm32f103ze_redbull_v2/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by Terraneo Federico                               *
+ *   Copyright (C) 2011, 2012, 2013, 2014 by Terraneo Federico             *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32/stm32f103ze_stm3210e-eval/board_settings.h b/miosix/config/arch/cortexM3_stm32/stm32f103ze_stm3210e-eval/board_settings.h
index ba50be4a..b90c72a2 100644
--- a/miosix/config/arch/cortexM3_stm32/stm32f103ze_stm3210e-eval/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32/stm32f103ze_stm3210e-eval/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2010 by Terraneo Federico                               *
+ *   Copyright (C) 2010, 2011, 2012, 2013, 2014 by Terraneo Federico       *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/board_settings.h b/miosix/config/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/board_settings.h
index d97f651c..84d3a9c9 100644
--- a/miosix/config/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2013 by Terraneo Federico                               *
+ *   Copyright (C) 2013, 2014 by Terraneo Federico                         *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32f2/stm32f207ig_stm3220g-eval/board_settings.h b/miosix/config/arch/cortexM3_stm32f2/stm32f207ig_stm3220g-eval/board_settings.h
index 076220d7..287a512e 100644
--- a/miosix/config/arch/cortexM3_stm32f2/stm32f207ig_stm3220g-eval/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32f2/stm32f207ig_stm3220g-eval/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32f2/stm32f207ze_als_camboard/board_settings.h b/miosix/config/arch/cortexM3_stm32f2/stm32f207ze_als_camboard/board_settings.h
index 8d1088ba..67e97676 100644
--- a/miosix/config/arch/cortexM3_stm32f2/stm32f207ze_als_camboard/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32f2/stm32f207ze_als_camboard/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32f2/stm32f207zg_EthBoardV2/board_settings.h b/miosix/config/arch/cortexM3_stm32f2/stm32f207zg_EthBoardV2/board_settings.h
index a7a1512a..d40698f8 100644
--- a/miosix/config/arch/cortexM3_stm32f2/stm32f207zg_EthBoardV2/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32f2/stm32f207zg_EthBoardV2/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM3_stm32l1/stm32l151c8_als_mainboard/board_settings.h b/miosix/config/arch/cortexM3_stm32l1/stm32l151c8_als_mainboard/board_settings.h
index f2e7a54f..0af59606 100644
--- a/miosix/config/arch/cortexM3_stm32l1/stm32l151c8_als_mainboard/board_settings.h
+++ b/miosix/config/arch/cortexM3_stm32l1/stm32l151c8_als_mainboard/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_bitsboard/board_settings.h b/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_bitsboard/board_settings.h
index ddccb966..a74f82dd 100644
--- a/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_bitsboard/board_settings.h
+++ b/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_bitsboard/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/board_settings.h b/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/board_settings.h
index ddccb966..a74f82dd 100644
--- a/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/board_settings.h
+++ b/miosix/config/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/board_settings.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Terraneo Federico                               *
+ *   Copyright (C) 2012, 2013, 2014 by Terraneo Federico                   *
  *                                                                         *
  *   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  *
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/board_settings.h b/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/board_settings.h
index ac70a6db..8295e783 100644
--- a/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/board_settings.h
+++ b/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/board_settings.h
@@ -28,6 +28,12 @@
 #ifndef BOARD_SETTINGS_H
 #define	BOARD_SETTINGS_H
 
+#include "util/version.h"
+
+#if BOARD_SETTINGS_VERSION != 100
+#error You need to update board_settings.h to match the version in the kernel.
+#endif
+
 namespace miosix {
 
 /**
diff --git a/miosix/config/miosix_settings.h b/miosix/config/miosix_settings.h
index 3ea47333..a73f5c00 100644
--- a/miosix/config/miosix_settings.h
+++ b/miosix/config/miosix_settings.h
@@ -1,5 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by Terraneo Federico *
+ *   Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014                *
+ *   by Terraneo Federico                                                  *
  *                                                                         *
  *   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  *
@@ -42,6 +43,11 @@
  */
 #include "arch_settings.h"
 #include "board_settings.h"
+#include "util/version.h"
+
+#if SETTINGS_VERSION != 100
+#error You need to update miosix_settings.h to match the version in the kernel.
+#endif
 
 namespace miosix {
 
diff --git a/miosix/util/version.cpp b/miosix/util/version.cpp
index 05252432..2c008607 100644
--- a/miosix/util/version.cpp
+++ b/miosix/util/version.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2010, 2011, 2012 by Terraneo Federico                   *
+ *   Copyright (C) 2010, 2011, 2012, 2013, 2014 by Terraneo Federico       *
  *                                                                         *
  *   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  *
diff --git a/miosix/util/version.h b/miosix/util/version.h
index 1dbd4441..c05ae646 100644
--- a/miosix/util/version.h
+++ b/miosix/util/version.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2010, 2011 by Terraneo Federico                         *
+ *   Copyright (C) 2010, 2011, 2012, 2013, 2014 by Terraneo Federico       *
  *                                                                         *
  *   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  *
@@ -39,10 +39,10 @@ namespace miosix {
  * Allows to know the version of the kernel at runtime.
  * \return a string with the kernel version.
  * The format is "Miosix vX.XX (board, builddate, compiler)" where
- * vX.XX is the kernel version number, like "v1.59"
+ * vX.XX is the kernel version number, like "v2.0"
  * board is the board name, like "stm32f103ze_stm3210e-eval"
  * builddate is the date the kernel was built, like "Oct 30 2011 00:58:10"
- * compiler is the compiler version, like "gcc 4.5.2"
+ * compiler is the compiler version, like "gcc 4.7.3"
  */
 const char *getMiosixVersion();
 
@@ -52,4 +52,16 @@ const char *getMiosixVersion();
 
 } //namespace miosix
 
+/**
+ * \internal
+ * Versioning for miosix_settings.h for out of git tree projects
+ */
+#define SETTINGS_VERSION 100
+
+/**
+ * \internal
+ * Versioning for board_settings.h for out of git tree projects
+ */
+#define BOARD_SETTINGS_VERSION 100
+
 #endif	/* VERSION_H */
-- 
GitLab