mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 21:36:21 +00:00
✨🔧 Minimal configuration with Config.h (#27338)
This commit is contained in:
parent
69f69606e6
commit
986344640f
27
.github/workflows/update-base-configs.yml
vendored
Normal file
27
.github/workflows/update-base-configs.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# update-base-configs.yml
|
||||
# Generate new base config files if needed
|
||||
#
|
||||
|
||||
name: Update Base Configs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */6 * * *'
|
||||
|
||||
jobs:
|
||||
bump_date:
|
||||
name: Update Base Configs
|
||||
if: github.repository == 'MarlinFirmware/Marlin'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout bugfix-2.1.x
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: bugfix-2.1.x
|
||||
|
||||
- name: Update Base Configs
|
||||
run: make base-configs
|
7
Makefile
7
Makefile
@ -9,6 +9,7 @@ help:
|
||||
@echo "make marlin : Build marlin for the configured board"
|
||||
@echo "make format-pins -j : Reformat all pins files (-j for parallel execution)"
|
||||
@echo "make validate-pins -j : Validate all pins files, fails if any require reformatting"
|
||||
@echo "make base-configs : Regenerate the base configs in Marlin/src/inc"
|
||||
@echo "make tests-single-ci : Run a single test from inside the CI"
|
||||
@echo "make tests-single-local : Run a single test locally"
|
||||
@echo "make tests-single-local-docker : Run a single test locally, using docker"
|
||||
@ -102,3 +103,9 @@ format-pins: $(PINS)
|
||||
validate-pins: format-pins
|
||||
@echo "Validating pins files"
|
||||
@git diff --exit-code || (git status && echo "\nError: Pins files are not formatted correctly. Run \"make format-pins\" to fix.\n" && exit 1)
|
||||
|
||||
base-configs:
|
||||
@echo "Generating base configs"
|
||||
@python $(SCRIPTS_DIR)/makeBaseConfigs.py 2>/dev/null \
|
||||
&& git add Marlin/src/inc/BaseConfiguration.h Marlin/src/inc/BaseConfiguration_adv.h \
|
||||
&& git commit -m "[cron] Update Base Configurations"
|
||||
|
@ -849,6 +849,8 @@
|
||||
// FIND YOUR OWN: "M303 E-2 C8 S50" to run autotune on the chamber at 50 degreesC for 8 cycles.
|
||||
#endif // PIDTEMPCHAMBER
|
||||
|
||||
// @section pid temp
|
||||
|
||||
#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER)
|
||||
//#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
|
||||
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
|
||||
|
@ -47,8 +47,9 @@
|
||||
* 2 = config.ini - File format for PlatformIO preprocessing.
|
||||
* 3 = schema.json - The entire configuration schema. (13 = pattern groups)
|
||||
* 4 = schema.yml - The entire configuration schema.
|
||||
* 5 = Config.h - Minimal configuration by popular demand.
|
||||
*/
|
||||
//#define CONFIG_EXPORT 2 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml']
|
||||
//#define CONFIG_EXPORT 105 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml', 5:'Config.h']
|
||||
|
||||
//===========================================================================
|
||||
//============================= Thermal Settings ============================
|
||||
@ -303,7 +304,7 @@
|
||||
* If you get false positives for "Thermal Runaway", increase
|
||||
* THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
|
||||
*/
|
||||
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
||||
#if ALL(HAS_HOTEND, THERMAL_PROTECTION_HOTENDS)
|
||||
#define THERMAL_PROTECTION_PERIOD 40 // (seconds)
|
||||
#define THERMAL_PROTECTION_HYSTERESIS 4 // (°C)
|
||||
|
||||
@ -334,7 +335,7 @@
|
||||
/**
|
||||
* Thermal Protection parameters for the bed are just as above for hotends.
|
||||
*/
|
||||
#if ENABLED(THERMAL_PROTECTION_BED)
|
||||
#if TEMP_SENSOR_BED && ENABLED(THERMAL_PROTECTION_BED)
|
||||
#define THERMAL_PROTECTION_BED_PERIOD 20 // (seconds)
|
||||
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // (°C)
|
||||
|
||||
@ -348,7 +349,7 @@
|
||||
/**
|
||||
* Thermal Protection parameters for the heated chamber.
|
||||
*/
|
||||
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
|
||||
#if TEMP_SENSOR_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER)
|
||||
#define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // (seconds)
|
||||
#define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // (°C)
|
||||
|
||||
@ -362,7 +363,7 @@
|
||||
/**
|
||||
* Thermal Protection parameters for the laser cooler.
|
||||
*/
|
||||
#if ENABLED(THERMAL_PROTECTION_COOLER)
|
||||
#if TEMP_SENSOR_COOLER && ENABLED(THERMAL_PROTECTION_COOLER)
|
||||
#define THERMAL_PROTECTION_COOLER_PERIOD 10 // (seconds)
|
||||
#define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // (°C)
|
||||
|
||||
|
1572
Marlin/src/inc/BaseConfiguration.h
Normal file
1572
Marlin/src/inc/BaseConfiguration.h
Normal file
File diff suppressed because it is too large
Load Diff
2753
Marlin/src/inc/BaseConfiguration_adv.h
Normal file
2753
Marlin/src/inc/BaseConfiguration_adv.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1534,12 +1534,6 @@
|
||||
#if ANY(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE)
|
||||
#define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe
|
||||
#endif
|
||||
#ifndef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_BETWEEN_PROBES 5
|
||||
#endif
|
||||
#ifndef Z_CLEARANCE_MULTI_PROBE
|
||||
#define Z_CLEARANCE_MULTI_PROBE 5
|
||||
#endif
|
||||
#ifndef Z_PROBE_ERROR_TOLERANCE
|
||||
#define Z_PROBE_ERROR_TOLERANCE Z_CLEARANCE_MULTI_PROBE
|
||||
#endif
|
||||
@ -1558,6 +1552,8 @@
|
||||
#undef HOMING_Z_WITH_PROBE
|
||||
#undef Z_CLEARANCE_MULTI_PROBE
|
||||
#undef Z_PROBE_ERROR_TOLERANCE
|
||||
#undef Z_AFTER_PROBING
|
||||
#undef Z_PROBE_LOW_POINT
|
||||
#undef MULTIPLE_PROBING
|
||||
#undef EXTRA_PROBING
|
||||
#undef PROBE_OFFSET_ZMIN
|
||||
@ -1567,6 +1563,8 @@
|
||||
#undef PROBING_HEATERS_OFF
|
||||
#undef WAIT_FOR_BED_HEATER
|
||||
#undef WAIT_FOR_HOTEND
|
||||
#undef PROBING_FANS_OFF
|
||||
#undef PROBING_ESTEPPERS_OFF
|
||||
#undef PROBING_STEPPERS_OFF
|
||||
#undef DELAY_BEFORE_PROBING
|
||||
#undef PREHEAT_BEFORE_PROBING
|
||||
@ -1575,13 +1573,6 @@
|
||||
#undef NOZZLE_TO_PROBE_OFFSET
|
||||
#endif
|
||||
|
||||
#ifndef Z_CLEARANCE_DEPLOY_PROBE
|
||||
#define Z_CLEARANCE_DEPLOY_PROBE 10
|
||||
#endif
|
||||
#ifndef Z_PROBE_LOW_POINT
|
||||
#define Z_PROBE_LOW_POINT -5
|
||||
#endif
|
||||
|
||||
#if ENABLED(BELTPRINTER) && !defined(HOME_Y_BEFORE_X)
|
||||
#define HOME_Y_BEFORE_X
|
||||
#endif
|
||||
@ -1642,6 +1633,71 @@
|
||||
#undef MESH_INSET
|
||||
#endif
|
||||
|
||||
#if NONE(PROBE_SELECTED, AUTO_BED_LEVELING_UBL)
|
||||
#undef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#endif
|
||||
|
||||
#if NONE(PROBE_SELECTED, DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU)
|
||||
#undef PROBING_MARGIN
|
||||
#undef PROBING_MARGIN_LEFT
|
||||
#undef PROBING_MARGIN_RIGHT
|
||||
#undef PROBING_MARGIN_FRONT
|
||||
#undef PROBING_MARGIN_BACK
|
||||
#undef XY_PROBE_FEEDRATE
|
||||
#endif
|
||||
|
||||
#if !(ANY(HAS_BED_PROBE, HAS_LEVELING) || ALL(AUTO_BED_LEVELING_UBL, HAS_MARLINUI_MENU))
|
||||
#undef Z_CLEARANCE_DEPLOY_PROBE
|
||||
#endif
|
||||
|
||||
#if !(ANY(HAS_BED_PROBE, BACKLASH_GCODE) || (ENABLED(EXTENSIBLE_UI) && ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)))
|
||||
#undef Z_PROBE_FEEDRATE_FAST
|
||||
#undef Z_PROBE_FEEDRATE_SLOW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Z_CLEARANCE_FOR_HOMING
|
||||
*/
|
||||
#ifndef Z_CLEARANCE_FOR_HOMING
|
||||
#ifdef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_FOR_HOMING Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define Z_CLEARANCE_FOR_HOMING 5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Z_CLEARANCE_BETWEEN_PROBES
|
||||
*/
|
||||
#if PROBE_SELECTED || (HAS_MARLINUI_MENU && ANY(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION))
|
||||
#ifndef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_BETWEEN_PROBES Z_CLEARANCE_FOR_HOMING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Z_CLEARANCE_BETWEEN_MANUAL_PROBES / Z_CLEARANCE_MULTI_PROBE
|
||||
*/
|
||||
#if PROBE_SELECTED
|
||||
#if ANY(MESH_BED_LEVELING, PROBE_MANUALLY)
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > Z_CLEARANCE_FOR_HOMING
|
||||
#define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_FOR_HOMING
|
||||
#endif
|
||||
#endif
|
||||
#ifndef Z_CLEARANCE_MULTI_PROBE
|
||||
#ifdef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define Z_CLEARANCE_MULTI_PROBE 5
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if TOTAL_PROBING < 2
|
||||
#undef Z_CLEARANCE_MULTI_PROBE
|
||||
#endif
|
||||
|
||||
#if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
#undef DEFAULT_LEVELING_FADE_HEIGHT
|
||||
#endif
|
||||
|
@ -746,9 +746,6 @@
|
||||
#elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999
|
||||
#define TEMP_SENSOR_BED_IS_DUMMY 1
|
||||
#endif
|
||||
#else
|
||||
#undef BED_MINTEMP
|
||||
#undef BED_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_CHAMBER == -4
|
||||
@ -766,10 +763,6 @@
|
||||
#elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999
|
||||
#define TEMP_SENSOR_CHAMBER_IS_DUMMY 1
|
||||
#endif
|
||||
#else
|
||||
#undef THERMAL_PROTECTION_CHAMBER
|
||||
#undef CHAMBER_MINTEMP
|
||||
#undef CHAMBER_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_COOLER == -4
|
||||
@ -787,10 +780,6 @@
|
||||
#if TEMP_SENSOR_COOLER == 1000
|
||||
#define TEMP_SENSOR_COOLER_IS_CUSTOM 1
|
||||
#endif
|
||||
#else
|
||||
#undef THERMAL_PROTECTION_COOLER
|
||||
#undef COOLER_MINTEMP
|
||||
#undef COOLER_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_PROBE == -4
|
||||
@ -836,6 +825,46 @@
|
||||
#undef TEMP_SENSOR_AD8495_OFFSET
|
||||
#endif
|
||||
|
||||
#if !HAS_HOTEND
|
||||
#undef THERMAL_PROTECTION_PERIOD
|
||||
#undef THERMAL_PROTECTION_HYSTERESIS
|
||||
#undef WATCH_TEMP_PERIOD
|
||||
#undef WATCH_TEMP_INCREASE
|
||||
#undef ADAPTIVE_FAN_SLOWING
|
||||
#undef REPORT_ADAPTIVE_FAN_SLOWING
|
||||
#undef TEMP_TUNING_MAINTAIN_FAN
|
||||
#endif
|
||||
|
||||
#if !TEMP_SENSOR_BED
|
||||
#undef THERMAL_PROTECTION_BED
|
||||
#undef THERMAL_PROTECTION_BED_PERIOD
|
||||
#undef THERMAL_PROTECTION_BED_HYSTERESIS
|
||||
#undef WATCH_BED_TEMP_PERIOD
|
||||
#undef WATCH_BED_TEMP_INCREASE
|
||||
#undef BED_MINTEMP
|
||||
#undef BED_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if !TEMP_SENSOR_CHAMBER
|
||||
#undef THERMAL_PROTECTION_CHAMBER
|
||||
#undef THERMAL_PROTECTION_CHAMBER_PERIOD
|
||||
#undef THERMAL_PROTECTION_CHAMBER_HYSTERESIS
|
||||
#undef WATCH_CHAMBER_TEMP_PERIOD
|
||||
#undef WATCH_CHAMBER_TEMP_INCREASE
|
||||
#undef CHAMBER_MINTEMP
|
||||
#undef CHAMBER_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if !TEMP_SENSOR_COOLER
|
||||
#undef THERMAL_PROTECTION_COOLER
|
||||
#undef THERMAL_PROTECTION_COOLER_PERIOD
|
||||
#undef THERMAL_PROTECTION_COOLER_HYSTERESIS
|
||||
#undef WATCH_COOLER_TEMP_PERIOD
|
||||
#undef WATCH_COOLER_TEMP_INCREASE
|
||||
#undef COOLER_MINTEMP
|
||||
#undef COOLER_MAXTEMP
|
||||
#endif
|
||||
|
||||
#if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND || HAS_PRUSA_MMU2 || (ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1)
|
||||
#define HAS_TOOLCHANGE 1
|
||||
#endif
|
||||
|
@ -3383,34 +3383,6 @@
|
||||
#undef SOUND_ON_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Z_CLEARANCE_FOR_HOMING / Z_CLEARANCE_BETWEEN_PROBES
|
||||
*/
|
||||
#ifndef Z_CLEARANCE_FOR_HOMING
|
||||
#ifdef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_FOR_HOMING Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define Z_CLEARANCE_FOR_HOMING 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_BETWEEN_PROBES Z_CLEARANCE_FOR_HOMING
|
||||
#endif
|
||||
#if PROBE_SELECTED
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > Z_CLEARANCE_FOR_HOMING
|
||||
#define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_FOR_HOMING
|
||||
#endif
|
||||
#ifndef Z_CLEARANCE_MULTI_PROBE
|
||||
#define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES
|
||||
#endif
|
||||
#if ENABLED(BLTOUCH) && !defined(BLTOUCH_DELAY)
|
||||
#define BLTOUCH_DELAY 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define a starting height for measuring manual probe points
|
||||
#ifndef MANUAL_PROBE_START_Z
|
||||
#if ANY(MESH_BED_LEVELING, PROBE_MANUALLY)
|
||||
|
@ -25,6 +25,11 @@
|
||||
#define __MARLIN_FIRMWARE__
|
||||
#endif
|
||||
|
||||
#if __has_include("../../Config.h")
|
||||
#define USE_BASE_CONFIGS 1
|
||||
#include "../../Config.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Prefix header to acquire configurations
|
||||
//
|
||||
@ -36,7 +41,12 @@
|
||||
|
||||
#include "../core/macros.h"
|
||||
#include "../core/boards.h"
|
||||
|
||||
#if USE_BASE_CONFIGS
|
||||
#include "BaseConfiguration.h"
|
||||
#else
|
||||
#include "../../Configuration.h"
|
||||
#endif
|
||||
|
||||
#ifdef CUSTOM_VERSION_FILE
|
||||
#if __has_include(STRINGIFY(../../CUSTOM_VERSION_FILE))
|
||||
@ -53,7 +63,12 @@
|
||||
#endif
|
||||
|
||||
#include "../core/drivers.h"
|
||||
|
||||
#if USE_BASE_CONFIGS
|
||||
#include "BaseConfiguration_adv.h"
|
||||
#else
|
||||
#include "../../Configuration_adv.h"
|
||||
#endif
|
||||
|
||||
#include "Conditionals_adv.h"
|
||||
|
||||
|
@ -60,6 +60,21 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_BASE_CONFIGS
|
||||
#if __has_include("../../Configuration.h")
|
||||
#define HAS_IGNORED_CONFIGS
|
||||
#elif __has_include("../../Configuration_adv.h")
|
||||
#define HAS_IGNORED_CONFIGS
|
||||
#endif
|
||||
#ifdef HAS_IGNORED_CONFIGS
|
||||
#warning "Configuration.h and Configuration_adv.h are being ignored, overridden by Config.h."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXPORT % 100 == 5
|
||||
#warning "Rename 'Config-export.h' to 'Config.h' to override Configuration.h and Configuration_adv.h."
|
||||
#endif
|
||||
|
||||
#if DISABLED(DEBUG_FLAGS_GCODE)
|
||||
#warning "DEBUG_FLAGS_GCODE is recommended if you have space. Some hosts rely on it."
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../../module/delta.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/probe.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
@ -41,10 +42,6 @@
|
||||
#include "../extui/ui_api.h"
|
||||
#endif
|
||||
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
#include "../../module/probe.h"
|
||||
#endif
|
||||
|
||||
void _man_probe_pt(const xy_pos_t &xy) {
|
||||
if (!ui.wait_for_move) {
|
||||
ui.wait_for_move = true;
|
||||
|
@ -158,8 +158,11 @@ if ((AUTO_BUILD)); then
|
||||
*) SYS='uni' ;;
|
||||
esac
|
||||
echo ; echo -n "Auto " ; ((AUTO_BUILD == 2)) && echo "Upload..." || echo "Build..."
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' )
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h 2>/dev/null | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' )
|
||||
[[ -z $MB ]] && {
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Config.h 2>/dev/null | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' )
|
||||
[[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
|
||||
}
|
||||
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
|
||||
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||
|
@ -7,6 +7,7 @@ import schema
|
||||
import subprocess,re,json,hashlib
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from functools import reduce
|
||||
|
||||
def enabled_defines(filepath):
|
||||
'''
|
||||
@ -208,7 +209,29 @@ def compute_build_signature(env):
|
||||
conf_schema = None
|
||||
|
||||
#
|
||||
# Produce an INI file if CONFIG_EXPORT == 2
|
||||
# CONFIG_EXPORT 2 = config.ini, 5 = Config.h
|
||||
# Get sections using the schema class
|
||||
#
|
||||
if extended_dump and config_dump in (2, 5):
|
||||
if not conf_schema: exit(1)
|
||||
|
||||
# Start with a preferred @section ordering
|
||||
preorder = ('info','machine','extruder','stepper drivers','geometry','homing','endstops','probes','lcd','interface','host','reporting')
|
||||
sections = { key:{} for key in preorder }
|
||||
|
||||
# Group options by schema @section
|
||||
for header in real_config:
|
||||
for name in real_config[header]:
|
||||
#print(f" name: {name}")
|
||||
if name in ignore: continue
|
||||
ddict = real_config[header][name]
|
||||
#print(f" real_config[{header}][{name}]:", ddict)
|
||||
sect = ddict['section']
|
||||
if sect not in sections: sections[sect] = {}
|
||||
sections[sect][name] = ddict
|
||||
|
||||
#
|
||||
# CONFIG_EXPORT 2 = config.ini
|
||||
#
|
||||
if config_dump == 2:
|
||||
print(yellow + "Generating config.ini ...")
|
||||
@ -333,6 +356,54 @@ f'''#
|
||||
if val == '': val = 'on'
|
||||
outfile.write(ini_fmt.format(name.lower(), val) + '\n')
|
||||
|
||||
#
|
||||
# CONFIG_EXPORT 5 = Config.h
|
||||
#
|
||||
if config_dump == 5:
|
||||
print(yellow + "Generating Config-export.h ...")
|
||||
|
||||
config_h = Path('Marlin', 'Config-export.h')
|
||||
with config_h.open('w') as outfile:
|
||||
filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' }
|
||||
vers = build_defines["CONFIGURATION_H_VERSION"]
|
||||
dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S")
|
||||
|
||||
out_text = f'''/**
|
||||
* Config.h - Marlin Firmware distilled configuration
|
||||
* Usage: Place this file in the 'Marlin' folder with the name 'Config.h'.
|
||||
*
|
||||
* Exported by Marlin build on {dt_string}.
|
||||
*/
|
||||
'''
|
||||
|
||||
subs = (('Bltouch','BLTouch'),('hchop','hChop'),('Eeprom','EEPROM'),('Gcode','G-code'),('lguard','lGuard'),('Idex','IDEX'),('Lcd','LCD'),('Mpc','MPC'),('Pid','PID'),('Psu','PSU'),('Scara','SCARA'),('Spi','SPI'),('Tmc','TMC'),('Tpara','TPARA'))
|
||||
define_fmt = '#define {0:40} {1}'
|
||||
if extended_dump:
|
||||
# Loop through the sections
|
||||
for skey in sections:
|
||||
#print(f" skey: {skey}")
|
||||
opts = sections[skey]
|
||||
headed = False
|
||||
for name in sorted(opts):
|
||||
if name in ignore: continue
|
||||
val = opts[name]['value']
|
||||
if not headed:
|
||||
head = reduce(lambda s, r: s.replace(*r), subs, skey.title())
|
||||
out_text += f"\n//\n// {head}\n//\n"
|
||||
headed = True
|
||||
out_text += define_fmt.format(name, val).strip() + '\n'
|
||||
|
||||
else:
|
||||
# Dump config options in just two sections, by file
|
||||
for header in real_config:
|
||||
out_text += f'\n/**\n * Overrides for {header}\n */\n'
|
||||
for name in sorted(real_config[header]):
|
||||
if name in ignore: continue
|
||||
val = real_config[header][name]['value']
|
||||
out_text += define_fmt.format(name, val).strip() + '\n'
|
||||
|
||||
outfile.write(out_text)
|
||||
|
||||
#
|
||||
# CONFIG_EXPORT 3 = schema.json, 4 = schema.yml
|
||||
#
|
||||
|
94
buildroot/share/scripts/makeBaseConfigs.py
Executable file
94
buildroot/share/scripts/makeBaseConfigs.py
Executable file
@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# makeBaseConfigs.py
|
||||
#
|
||||
# Create "base" config files that can be overridden by a minimal config file.
|
||||
# The intention is to include base config files as part of the Marlin package
|
||||
# so users can use a minimal configuration with the familiar header format.
|
||||
# This provides an Arduino-compatible way to apply configurations without the
|
||||
# complications that come from a plain config.ini solution.
|
||||
#
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
def make_base_configs():
|
||||
no_disabled = True
|
||||
|
||||
# Create a regex to match options and capture line parts
|
||||
define_patt = re.compile(r'^(\s*)((//\s*)?#define\s+)([A-Z0-9_]+\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE)
|
||||
ifndef_patt = re.compile(r'^(\s*#ifndef\s*.*?)(\s*//.*)?$', re.IGNORECASE)
|
||||
ifstat_patt = re.compile(r'^(\s*#(if|ifn?def|else|elif|endif)\s*.*?)(\s*//.*)?$', re.IGNORECASE)
|
||||
coment_patt = re.compile(r'/\*.*?\*/', re.DOTALL)
|
||||
contin_patt = re.compile(r'\\\n\s*')
|
||||
|
||||
# Wrap all config options in #ifndef
|
||||
for file in ('Configuration.h', 'Configuration_adv.h'):
|
||||
fullpath = Path('Marlin', file)
|
||||
fulltext = fullpath.read_text(encoding='utf-8')
|
||||
fulltext = coment_patt.sub('', fulltext)
|
||||
fulltext = contin_patt.sub(' ', fulltext)
|
||||
|
||||
is_ifndef = False
|
||||
|
||||
lines_out = []
|
||||
for line in fulltext.split('\n'):
|
||||
|
||||
was_ifndef = is_ifndef # Previous line was #ifndef?
|
||||
is_ifndef = ifndef_patt.match(line) # This line is #ifndef?
|
||||
|
||||
m = ifstat_patt.match(line)
|
||||
if m: lines_out += [m[1]] ; continue
|
||||
|
||||
m = define_patt.match(line)
|
||||
if m:
|
||||
if no_disabled and line.strip().startswith('//'): continue
|
||||
|
||||
name = m[4]
|
||||
if name in ('CONFIG_EXAMPLES_DIR', 'CONFIG_EXPORT'): continue
|
||||
if name.startswith('_'): continue
|
||||
|
||||
if not was_ifndef: lines_out += [f'{m[1]}#ifndef {name}']
|
||||
|
||||
entab = '' if was_ifndef else ' '
|
||||
indented = f'{entab}{m[1]}{m[2]}{m[4]} {m[6]}'.rstrip()
|
||||
lines_out += [indented]
|
||||
|
||||
if not was_ifndef: lines_out += [f'{m[1]}#endif']
|
||||
|
||||
# Final text needs some additional cleanup to remove empty blocks
|
||||
empty_patt = re.compile(r'(\s*#if.+)(\n\s*#el.+)*(\n\s*#endif.*)')
|
||||
ifelse_patt = re.compile(r'(\s*#(el)?if\s+)(.+)\n\s*#else')
|
||||
ifelif_patt = re.compile(r'(\s*#if\s+)(.+)\n\s*#elif\s*(.+)')
|
||||
out_text = '\n'.join(lines_out)
|
||||
old_text = ''
|
||||
while out_text != old_text:
|
||||
old_text = out_text
|
||||
out_text = ifelse_patt.sub(r'\1!(\3)', out_text)
|
||||
out_text = ifelif_patt.sub(r'\1!(\2) && (\3)\n', out_text)
|
||||
out_text = empty_patt.sub('', out_text)
|
||||
|
||||
# Store the final result to Marlin/src/inc/BaseConfiguration.h BaseConfiguration_adv.h
|
||||
outname = f'Base{file}'
|
||||
outpath = Path('Marlin', 'src', 'inc', outname)
|
||||
|
||||
with outpath.open('w') as outfile:
|
||||
|
||||
from datetime import datetime
|
||||
header_tpl = Path('buildroot', 'share', 'extras', 'file_header.h').read_text(encoding='utf-8')
|
||||
header_tpl = re.sub(r'(\(c\))\s*\d+\s*(MarlinFirmware)', rf'\1 {datetime.now().year} \2', header_tpl)
|
||||
header_tpl = re.sub(r'\*/\n+/\*\*', '*/\n#pragma once\n\n/**', header_tpl)
|
||||
header_tpl = header_tpl.replace(r'$(filename)', f"{outname} - Generated using makeBaseConfigs.py")
|
||||
|
||||
outfile.write(header_tpl + out_text + '\n')
|
||||
|
||||
# Always run from the command line.
|
||||
# Later we can add a "minimal" flag to config to do this automatically.
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
args = sys.argv[1:]
|
||||
if len(args) > 0:
|
||||
print(f"Usage: {sys.argv[0]}")
|
||||
elif not Path('Marlin', 'src').is_dir():
|
||||
print(f"Please run {sys.argv[0]} from the root of the Marlin workspace.")
|
||||
else:
|
||||
make_base_configs()
|
14
docs/Maintenance.md
Normal file
14
docs/Maintenance.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Marlin Code Maintenance
|
||||
|
||||
In addition to the general work of fixing bugs, supporting new hardware, developing new features, and refining existing features we have to also maintain supporting files that change in tandem with the codebase. Some of this maintenance can be done as part of CI, and we may even generate commits to the development branch using periodic checks whenever any auto-generated files need to be regenerated. (See `bump-date.yml` for one example.)
|
||||
|
||||
## Configuration Tasks
|
||||
|
||||
- Add CI build tests and Unit Testing to catch future breaking changes.
|
||||
- Periodically run `buildroot/bin/build_all_examples` to make sure configs and code are buildable.
|
||||
- Periodically run `buildroot/share/scripts/makeBaseConfigs.py` to generate new base configurations.
|
||||
|
||||
## Documentation Tasks
|
||||
|
||||
- For any G-code command changes update G-code pages and the RepRap wiki G-code page.
|
||||
- For a new feature or changes to an existing feature update Configuration page and any articles about the feature.
|
Loading…
Reference in New Issue
Block a user