diff --git a/.circleci/config.yml b/.circleci/config.yml index 5369e2f4d..d474f034b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,8 +51,8 @@ jobs: export PATH=`pwd`/buildroot/bin/:${PATH} # Generate custom version include - generate_version ./Marlin/src/inc - cat ./Marlin/src/inc/_Version.h + generate_version ./Marlin/ + cat ./Marlin/Version.h # # Back up pins_RAMPS.h # diff --git a/.travis.yml b/.travis.yml index 16e48856e..d3acf40cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,8 +75,8 @@ before_script: - cd ${TRAVIS_BUILD_DIR} # # Generate custom version include - - generate_version ${TRAVIS_BUILD_DIR}/Marlin/src/inc - - cat ${TRAVIS_BUILD_DIR}/Marlin/src/inc/_Version.h + - generate_version ${TRAVIS_BUILD_DIR}/Marlin/ + - cat ${TRAVIS_BUILD_DIR}/Marlin/Version.h # script: - run_tests ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM} diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e682f132e..155605f60 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -72,6 +72,7 @@ // Author info of this build printed to the host during boot and M115 #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. +//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) /** * *** VENDORS PLEASE READ *** diff --git a/Marlin/Version.h b/Marlin/Version.h new file mode 100644 index 000000000..d18176f27 --- /dev/null +++ b/Marlin/Version.h @@ -0,0 +1,76 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +//////////////////////////// +// VENDOR VERSION EXAMPLE // +//////////////////////////// + +/** + * Marlin release version identifier + */ +//#define SHORT_BUILD_VERSION "bugfix-2.0.x" + +/** + * Verbose version identifier which should contain a reference to the location + * from where the binary was downloaded or the source code was compiled. + */ +//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (Github)" + +/** + * The STRING_DISTRIBUTION_DATE represents when the binary file was built, + * here we define this default string as the date where the latest release + * version was tagged. + */ +//#define STRING_DISTRIBUTION_DATE "2019-07-10" + +/** + * Defines a generic printer name to be output to the LCD after booting Marlin. + */ +//#define MACHINE_NAME "3D Printer" + +/** + * The SOURCE_CODE_URL is the location where users will find the Marlin Source + * Code which is installed on the device. In most cases —unless the manufacturer + * has a distinct Github fork— the Source Code URL should just be the main + * Marlin repository. + */ +//#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin" + +/** + * Default generic printer UUID. + */ +//#define DEFAULT_MACHINE_UUID "cede2a2f-41a2-4748-9b12-c55c62f367ff" + +/** + * The WEBSITE_URL is the location where users can get more information such as + * documentation about a specific Marlin release. + */ +//#define WEBSITE_URL "http://marlinfw.org" + +/** + * Set the vendor info the serial USB interface, if changable + * Currently only supported by DUE platform + */ +//#define USB_DEVICE_VENDOR_ID 0x0000 +//#define USB_DEVICE_PRODUCT_ID 0x0000 +//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL diff --git a/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h b/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h index 6934494e5..8d5924d37 100644 --- a/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h +++ b/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h @@ -48,9 +48,7 @@ #define _CONF_USB_H_ #undef UNUSED /* To avoid a macro clash as macros.h already defines it */ -#include "../../../core/macros.h" /* For ENABLED()/DISABLED() */ -#include "../../../core/boards.h" /* For MB() */ -#include "../../../../Configuration.h" /* For CUSTOM_MACHINE_NAME definition - We just need the name, no C++ allowed! */ +#include "../../../inc/MarlinConfigPre.h" #include "compiler.h" /** @@ -59,8 +57,6 @@ */ //! Device definition (mandatory) -#define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */ -#define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */ #define USB_DEVICE_MAJOR_VERSION 1 #define USB_DEVICE_MINOR_VERSION 0 #define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA) @@ -70,15 +66,6 @@ // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED) // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED) -//! USB Device string definitions (Optional) -#define USB_DEVICE_MANUFACTURE_NAME "marlinfw.org" -#ifdef CUSTOM_MACHINE_NAME - #define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME -#else - #define USB_DEVICE_PRODUCT_NAME "3D Printer" -#endif -#define USB_DEVICE_SERIAL_NAME "123985739853" - /** * Device speeds support * Low speed not supported by CDC and MSC diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index fcc361ad4..5214ac607 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1768,23 +1768,25 @@ #define Z_STEPPER_COUNT 1 #endif -// Get LCD character width/height, which may be overridden by pins, configs, etc. -#ifndef LCD_WIDTH - #if HAS_GRAPHICAL_LCD - #define LCD_WIDTH 21 - #elif ENABLED(ULTIPANEL) - #define LCD_WIDTH 20 - #elif HAS_SPI_LCD - #define LCD_WIDTH 16 - #endif -#endif -#ifndef LCD_HEIGHT - #if HAS_GRAPHICAL_LCD - #define LCD_HEIGHT 5 - #elif ENABLED(ULTIPANEL) - #define LCD_HEIGHT 4 - #elif HAS_SPI_LCD - #define LCD_HEIGHT 2 +#if HAS_SPI_LCD + // Get LCD character width/height, which may be overridden by pins, configs, etc. + #ifndef LCD_WIDTH + #if HAS_GRAPHICAL_LCD + #define LCD_WIDTH 21 + #elif ENABLED(ULTIPANEL) + #define LCD_WIDTH 20 + #else + #define LCD_WIDTH 16 + #endif + #endif + #ifndef LCD_HEIGHT + #if HAS_GRAPHICAL_LCD + #define LCD_HEIGHT 5 + #elif ENABLED(ULTIPANEL) + #define LCD_HEIGHT 4 + #else + #define LCD_HEIGHT 2 + #endif #endif #endif diff --git a/Marlin/src/inc/MarlinConfigPre.h b/Marlin/src/inc/MarlinConfigPre.h index e34b70376..a7dea37a9 100644 --- a/Marlin/src/inc/MarlinConfigPre.h +++ b/Marlin/src/inc/MarlinConfigPre.h @@ -34,9 +34,21 @@ #include "../core/boards.h" #include "../core/macros.h" -#include "Version.h" #include "../../Configuration.h" + +#ifdef CUSTOM_VERSION_FILE + #if defined(__has_include) + #if __has_include(CUSTOM_VERSION_FILE) + #include XSTR(../../CUSTOM_VERSION_FILE) + #endif + #else + #include XSTR(../../CUSTOM_VERSION_FILE) + #endif +#endif + +#include "Version.h" + #include "Conditionals_LCD.h" #include HAL_PATH(../HAL, inc/Conditionals_LCD.h) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5aa0cd6f7..d4dcf13f5 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -74,7 +74,9 @@ #elif defined(CUSTOM_MENDEL_NAME) #error "CUSTOM_MENDEL_NAME is now CUSTOM_MACHINE_NAME. Please update your configuration." #elif defined(HAS_AUTOMATIC_VERSIONING) - #error "HAS_AUTOMATIC_VERSIONING is now USE_AUTOMATIC_VERSIONING. Please update your configuration." + #error "HAS_AUTOMATIC_VERSIONING is now CUSTOM_VERSION_FILE. Please update your configuration." +#elif defined(USE_AUTOMATIC_VERSIONING) + #error "USE_AUTOMATIC_VERSIONING is now CUSTOM_VERSION_FILE. Please update your configuration." #elif defined(SDSLOW) #error "SDSLOW deprecated. Set SPI_SPEED to SPI_HALF_SPEED instead." #elif defined(SDEXTRASLOW) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 0e02b0be3..259d7a02c 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -21,77 +21,102 @@ */ #pragma once -#include "../core/macros.h" // for ENABLED - /** - * This file is the standard Marlin version identifier file. - * Use -DUSE_AUTOMATIC_VERSIONING=1 and a custom _Version.h - * to override these values. + * Release version. Leave the Marlin version or apply a custom scheme. */ - -#if ENABLED(USE_AUTOMATIC_VERSIONING) - - #include "_Version.h" - -#else - - /** - * Marlin release version identifier - */ +#ifndef SHORT_BUILD_VERSION #define SHORT_BUILD_VERSION "bugfix-2.0.x" +#endif - /** - * Verbose version identifier which should contain a reference to the location - * from where the binary was downloaded or the source code was compiled. - */ - #define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (Github)" +/** + * Verbose version identifier containing a unique identifier, such as the + * vendor name, download location, GitHub account, etc. + */ +#ifndef DETAILED_BUILD_VERSION + #define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (GitHub)" +#endif - /** - * The STRING_DISTRIBUTION_DATE represents when the binary file was built, - * here we define this default string as the date where the latest release - * version was tagged. - */ +/** + * The STRING_DISTRIBUTION_DATE represents when the binary file was built, + * here we define this default string as the date where the latest release + * version was tagged. + */ +#ifndef STRING_DISTRIBUTION_DATE #define STRING_DISTRIBUTION_DATE "2019-10-10" +#endif - /** - * Required minimum Configuration.h and Configuration_adv.h file versions. - * - * You must increment this version number for every significant change such as, - * but not limited to: ADD, DELETE RENAME OR REPURPOSE any directive/option on - * the configuration files. - */ - #define REQUIRED_CONFIGURATION_H_VERSION 020000 - #define REQUIRED_CONFIGURATION_ADV_H_VERSION 020000 +/** + * Minimum Configuration.h and Configuration_adv.h file versions. + * Set based on the release version number. Used to catch an attempt to use + * older configurations. Override these if using a custom versioning scheme + * to alert users to major changes. + */ - /** - * The protocol for communication to the host. Protocol indicates communication - * standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc. - * (Other behaviors are given by the firmware version and capabilities report.) - */ +#define MARLIN_HEX_VERSION 020000 +#ifndef REQUIRED_CONFIGURATION_H_VERSION + #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION +#endif +#ifndef REQUIRED_CONFIGURATION_ADV_H_VERSION + #define REQUIRED_CONFIGURATION_ADV_H_VERSION MARLIN_HEX_VERSION +#endif + +/** + * The protocol for communication to the host. Protocol indicates communication + * standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc. + * (Other behaviors are given by the firmware version and capabilities report.) + */ +#ifndef PROTOCOL_VERSION #define PROTOCOL_VERSION "1.0" +#endif - /** - * Defines a generic printer name to be output to the LCD after booting Marlin. - */ +/** + * Define a generic printer name to be output to the LCD after booting Marlin. + */ +#ifndef MACHINE_NAME #define MACHINE_NAME "3D Printer" +#endif - /** - * The SOURCE_CODE_URL is the location where users will find the Marlin Source - * Code which is installed on the device. In most cases —unless the manufacturer - * has a distinct Github fork— the Source Code URL should just be the main - * Marlin repository. - */ +/** + * Website where users can find Marlin source code for the binary installed on the + * device. Override this if you provide public source code download. (GPLv3 requires + * providing the source code to your customers.) + */ +#ifndef SOURCE_CODE_URL #define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin" +#endif - /** - * Default generic printer UUID. - */ +/** + * Default generic printer UUID. + */ +#ifndef DEFAULT_MACHINE_UUID #define DEFAULT_MACHINE_UUID "cede2a2f-41a2-4748-9b12-c55c62f367ff" +#endif /** * The WEBSITE_URL is the location where users can get more information such as * documentation about a specific Marlin release. Displayed in the Info Menu. */ +#ifndef WEBSITE_URL #define WEBSITE_URL "http://marlinfw.org" +#endif -#endif // USE_AUTOMATIC_VERSIONING +/** + * Set the vendor info the serial USB interface, if changable + * Currently only supported by DUE platform + */ +#ifndef USB_DEVICE_VENDOR_ID + #define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */ +#endif +#ifndef USB_DEVICE_PRODUCT_ID + #define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */ +#endif +//! USB Device string definitions (Optional) +#ifndef USB_DEVICE_MANUFACTURE_NAME + #define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL +#endif +#ifdef CUSTOM_MACHINE_NAME + #define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME +#else + #define USB_DEVICE_PRODUCT_NAME MACHINE_NAME +#endif +#define USB_DEVICE_SERIAL_NAME "123985739853" diff --git a/buildroot/bin/generate_version b/buildroot/bin/generate_version index 5a07ef5b1..c2bcbdc75 100755 --- a/buildroot/bin/generate_version +++ b/buildroot/bin/generate_version @@ -2,10 +2,10 @@ # # generate_version # -# Make a _Version.h file +# Make a Version.h file to accompany CUSTOM_VERSION_FILE # -DIR=${1:-"Marlin/src/inc"} +DIR=${1:-"Marlin"} # MRCC3=$( git merge-base HEAD upstream/bugfix-2.0.x 2>/dev/null ) # MRCC2=$( git merge-base HEAD upstream/bugfix-1.1.x 2>/dev/null ) @@ -44,7 +44,30 @@ SOURCE_CODE_URL=$(awk -F'"' \ WEBSITE_URL=$(awk -F'"' \ '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h") -cat > "${DIR}/_Version.h" < "${DIR}/Version.h" <. + * + */ +#pragma once + /** * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT. * IT DOES NOT GET COMMITTED TO THE REPOSITORY. @@ -53,15 +76,69 @@ cat > "${DIR}/_Version.h" <