From b7fd046d59ca472e7fac9d762f5ea34fc1688662 Mon Sep 17 00:00:00 2001 From: Scott Lahteine <thinkyhead@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:48:14 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20date,=20version=20to=20Con?= =?UTF-8?q?fig=20Export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 6 +- Marlin/base.ini | 107 ------------------ Marlin/config.ini | 18 ++- .../share/PlatformIO/scripts/configuration.py | 5 +- buildroot/share/PlatformIO/scripts/schema.py | 2 +- .../share/PlatformIO/scripts/signature.py | 42 ++++--- 6 files changed, 50 insertions(+), 130 deletions(-) delete mode 100644 Marlin/base.ini diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6a82b0c000f..b076949a884 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -35,9 +35,9 @@ // @section develop /** - * Configuration Dump + * Configuration Export * - * Dump the configuration as part of the build. (See signature.py) + * Export the configuration as part of the build. (See signature.py) * Output files are saved with the build (e.g., .pio/build/mega2560). * * See `build_all_examples --ini` as an example of config.ini archiving. @@ -48,7 +48,7 @@ * 3 = schema.json - The entire configuration schema. (13 = pattern groups) * 4 = schema.yml - The entire configuration schema. */ -//#define CONFIG_DUMP // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] +//#define CONFIG_EXPORT // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] //=========================================================================== //============================= Thermal Settings ============================ diff --git a/Marlin/base.ini b/Marlin/base.ini deleted file mode 100644 index 2ffcdfb7c28..00000000000 --- a/Marlin/base.ini +++ /dev/null @@ -1,107 +0,0 @@ -# -# Marlin Firmware -# base.ini - A base ini to include for testing -# -[config:base] -motherboard = BOARD_RAMPS_14_EFB -serial_port = 0 -baudrate = 250000 - -use_watchdog = on -thermal_protection_hotends = on -thermal_protection_hysteresis = 4 -thermal_protection_period = 40 - -bufsize = 4 -block_buffer_size = 16 -max_cmd_size = 96 - -extruders = 1 -temp_sensor_0 = 1 - -temp_hysteresis = 3 -heater_0_mintemp = 5 -heater_0_maxtemp = 275 -preheat_1_temp_hotend = 180 - -bang_max = 255 -pidtemp = on -pid_k1 = 0.95 -pid_max = BANG_MAX -pid_functional_range = 10 - -default_kp = 22.20 -default_ki = 1.08 -default_kd = 114.00 - -x_driver_type = A4988 -y_driver_type = A4988 -z_driver_type = A4988 -e0_driver_type = A4988 - -x_bed_size = 200 -x_min_pos = 0 -x_max_pos = X_BED_SIZE - -y_bed_size = 200 -y_min_pos = 0 -y_max_pos = Y_BED_SIZE - -z_min_pos = 0 -z_max_pos = 200 - -x_home_dir = -1 -y_home_dir = -1 -z_home_dir = -1 - -use_xmin_plug = on -use_ymin_plug = on -use_zmin_plug = on - -x_min_endstop_inverting = false -y_min_endstop_inverting = false -z_min_endstop_inverting = false - -default_axis_steps_per_unit = { 80, 80, 400, 500 } -axis_relative_modes = { false, false, false, false } -default_max_feedrate = { 300, 300, 5, 25 } -default_max_acceleration = { 3000, 3000, 100, 10000 } - -homing_feedrate_mm_m = { (50*60), (50*60), (4*60) } -homing_bump_divisor = { 2, 2, 4 } - -x_enable_on = 0 -y_enable_on = 0 -z_enable_on = 0 -e_enable_on = 0 - -invert_x_dir = false -invert_y_dir = true -invert_z_dir = false -invert_e0_dir = false - -invert_e_step_pin = false -invert_x_step_pin = false -invert_y_step_pin = false -invert_z_step_pin = false - -disable_x = false -disable_y = false -disable_z = false -disable_e = false - -proportional_font_ratio = 1.0 -default_nominal_filament_dia = 1.75 - -junction_deviation_mm = 0.013 - -default_acceleration = 3000 -default_travel_acceleration = 3000 -default_retract_acceleration = 3000 - -default_minimumfeedrate = 0.0 -default_mintravelfeedrate = 0.0 - -minimum_planner_speed = 0.05 -min_steps_per_segment = 6 -default_minsegmenttime = 20000 diff --git a/Marlin/config.ini b/Marlin/config.ini index 532c982402f..0fb9fb0c930 100644 --- a/Marlin/config.ini +++ b/Marlin/config.ini @@ -4,12 +4,20 @@ # [config:base] ini_use_config = none -#ini_use_config = base.ini, another.ini -#ini_use_config = example/Creality/Ender-5 Plus -#ini_use_config = https://me.myserver.com/path/to/configs -#ini_use_config = base -#config_dump = 2 +# Load all config: sections in this file +;ini_use_config = all +# Load config file relative to Marlin/ +;ini_use_config = another.ini +# Download configurations from GitHub +;ini_use_config = example/Creality/Ender-5 Plus @ bugfix-2.1.x +# Download configurations from your server +;ini_use_config = https://me.myserver.com/path/to/configs +# Evaluate config:base and do a config dump +;ini_use_config = base +;config_export = 2 + +[config:minimal] motherboard = BOARD_RAMPS_14_EFB serial_port = 0 baudrate = 250000 diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 8e67b5a0017..3ab0295749a 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -18,7 +18,7 @@ def apply_opt(name, val, conf=None): if name == "lcd": name, val = val, "on" # Create a regex to match the option and capture parts of the line - regex = re.compile(r'^(\s*)(//\s*)?(#define\s+)(' + name + r'\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) + regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) # Find and enable and/or update all matches for file in ("Configuration.h", "Configuration_adv.h"): @@ -87,6 +87,9 @@ def fetch_example(path): if path.endswith("/"): path = path[:-1] + if '@' in path: + path, brch = map(strip, path.split('@')) + url = path.replace("%", "%25").replace(" ", "%20") if not path.startswith('http'): url = "https://raw.githubusercontent.com/MarlinFirmware/Configurations/bugfix-2.1.x/config/%s" % url diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index efe56ebe358..767748757e2 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -95,7 +95,7 @@ def extract(): # Regex for #define NAME [VALUE] [COMMENT] with sanitized line defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') # Defines to ignore - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_DUMP') + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') # Start with unknown state state = Parse.NORMAL # Serial ID diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index fc7c490d3d6..163b1505da6 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -1,8 +1,10 @@ # # signature.py # -import subprocess,re,json,hashlib import schema + +import subprocess,re,json,hashlib +from datetime import datetime from pathlib import Path # @@ -112,9 +114,9 @@ def compute_build_signature(env): defines[key] = value if len(value) else "" # - # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_DUMP + # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT # - if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_DUMP' in defines): + if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): return # Second step is to filter useless macro @@ -157,18 +159,32 @@ def compute_build_signature(env): except: return 0 - config_dump = tryint('CONFIG_DUMP') + config_dump = tryint('CONFIG_EXPORT') # - # Produce an INI file if CONFIG_DUMP == 2 + # Produce an INI file if CONFIG_EXPORT == 2 # if config_dump == 2: print("Generating config.ini ...") - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_DUMP') - filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } config_ini = build_path / 'config.ini' with config_ini.open('w') as outfile: - outfile.write('#\n# Marlin Firmware\n# config.ini - Options to apply before the build\n#\n') + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } + vers = defines["CONFIGURATION_H_VERSION"] + dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") + ini_fmt = '{0:40}{1}\n' + outfile.write( + '#\n' + + '# Marlin Firmware\n' + + '# config.ini - Options to apply before the build\n' + + '#\n' + + f'# Generated by Marlin build on {dt_string}\n' + + '#\n' + + '\n' + + '[config:base]\n' + + ini_fmt.format('ini_use_config', ' = all') + + ini_fmt.format('ini_config_vers', f' = {vers}') + ) # Loop through the data array of arrays for header in data: if header.startswith('__'): @@ -177,10 +193,10 @@ def compute_build_signature(env): for key in sorted(data[header]): if key not in ignore: val = 'on' if data[header][key] == '' else data[header][key] - outfile.write('{0:40}{1}'.format(key.lower(), ' = ' + val) + '\n') + outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) # - # Produce a schema.json file if CONFIG_DUMP == 3 + # Produce a schema.json file if CONFIG_EXPORT == 3 # if config_dump >= 3: try: @@ -191,7 +207,7 @@ def compute_build_signature(env): if conf_schema: # - # Produce a schema.json file if CONFIG_DUMP == 3 + # Produce a schema.json file if CONFIG_EXPORT == 3 # if config_dump in (3, 13): print("Generating schema.json ...") @@ -201,7 +217,7 @@ def compute_build_signature(env): schema.dump_json(conf_schema, build_path / 'schema_grouped.json') # - # Produce a schema.yml file if CONFIG_DUMP == 4 + # Produce a schema.yml file if CONFIG_EXPORT == 4 # elif config_dump == 4: print("Generating schema.yml ...") @@ -226,7 +242,7 @@ def compute_build_signature(env): pass # - # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_DUMP == 1 + # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 # if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: with marlin_json.open('w') as outfile: