generate_version 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/usr/bin/env bash
  2. #
  3. # generate_version
  4. #
  5. # Make a Version.h file to accompany CUSTOM_VERSION_FILE
  6. #
  7. # Authors: jbrazio, thinkyhead, InsanityAutomation, rfinnie
  8. #
  9. set -e
  10. DIR="${1:-Marlin}"
  11. READ_FILE="${READ_FILE:-${DIR}/Version.h}"
  12. WRITE_FILE="${WRITE_FILE:-${READ_FILE}}"
  13. BRANCH="$(git -C "${DIR}" symbolic-ref -q --short HEAD 2>/dev/null || true)"
  14. VERSION="$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null || true)"
  15. STRING_DISTRIBUTION_DATE="${STRING_DISTRIBUTION_DATE:-$(date '+%Y-%m-%d %H:%M')}"
  16. SHORT_BUILD_VERSION="${SHORT_BUILD_VERSION:-${BRANCH}}"
  17. DETAILED_BUILD_VERSION="${DETAILED_BUILD_VERSION:-${BRANCH}-${VERSION}}"
  18. PROTOCOL_VERSION="1.0"
  19. # Gets some misc options from their defaults
  20. DEFAULT_MACHINE_UUID="${DEFAULT_MACHINE_UUID:-$(awk -F'"' \
  21. '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${READ_FILE}")}"
  22. MACHINE_NAME="${MACHINE_NAME:-$(awk -F'"' \
  23. '/#define MACHINE_NAME/{ print $2 }' < "${READ_FILE}")}"
  24. PROTOCOL_VERSION="${PROTOCOL_VERSION:-$(awk -F'"' \
  25. '/#define PROTOCOL_VERSION/{ print $2 }' < "${READ_FILE}")}"
  26. SOURCE_CODE_URL="${SOURCE_CODE_URL:-$(awk -F'"' \
  27. '/#define SOURCE_CODE_URL/{ print $2 }' < "${READ_FILE}")}"
  28. WEBSITE_URL="${WEBSITE_URL:-$(awk -F'"' \
  29. '/#define WEBSITE_URL/{ print $2 }' < "${READ_FILE}")}"
  30. cat > "${WRITE_FILE}" <<EOF
  31. /**
  32. * Marlin 3D Printer Firmware
  33. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  34. *
  35. * Based on Sprinter and grbl.
  36. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  37. *
  38. * This program is free software: you can redistribute it and/or modify
  39. * it under the terms of the GNU General Public License as published by
  40. * the Free Software Foundation, either version 3 of the License, or
  41. * (at your option) any later version.
  42. *
  43. * This program is distributed in the hope that it will be useful,
  44. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  45. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  46. * GNU General Public License for more details.
  47. *
  48. * You should have received a copy of the GNU General Public License
  49. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  50. *
  51. */
  52. #pragma once
  53. /**
  54. * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
  55. * IT DOES NOT GET COMMITTED TO THE REPOSITORY.
  56. *
  57. * Branch: ${BRANCH}
  58. * Version: ${VERSION}
  59. */
  60. /**
  61. * Marlin release version identifier
  62. */
  63. #define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
  64. /**
  65. * Verbose version identifier which should contain a reference to the location
  66. * from where the binary was downloaded or the source code was compiled.
  67. */
  68. #define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
  69. /**
  70. * The STRING_DISTRIBUTION_DATE represents when the binary file was built,
  71. * here we define this default string as the date where the latest release
  72. * version was tagged.
  73. */
  74. #define STRING_DISTRIBUTION_DATE "${STRING_DISTRIBUTION_DATE}"
  75. /**
  76. * The protocol for communication to the host. Protocol indicates communication
  77. * standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
  78. * (Other behaviors are given by the firmware version and capabilities report.)
  79. */
  80. #define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
  81. /**
  82. * Defines a generic printer name to be output to the LCD after booting Marlin.
  83. */
  84. #define MACHINE_NAME "${MACHINE_NAME}"
  85. /**
  86. * The SOURCE_CODE_URL is the location where users will find the Marlin Source
  87. * Code which is installed on the device. In most cases —unless the manufacturer
  88. * has a distinct Github fork— the Source Code URL should just be the main
  89. * Marlin repository.
  90. */
  91. #define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
  92. /**
  93. * Default generic printer UUID.
  94. */
  95. #define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
  96. /**
  97. * The WEBSITE_URL is the location where users can get more information such as
  98. * documentation about a specific Marlin release.
  99. */
  100. #define WEBSITE_URL "${WEBSITE_URL}"
  101. EOF