0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-15 02:36:19 +00:00

🔨 Build scripts cleanup (#27157)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Andrew 2024-06-14 17:01:34 -04:00 committed by GitHub
parent ae2843940f
commit 959be66cc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 130 additions and 151 deletions

View file

@ -11,7 +11,7 @@ if pioutil.is_pio_build():
if current_OS == 'Windows':
Import("env")
env = pioutil.env
# Use bossac.exe on Windows
env.Replace(

View file

@ -13,9 +13,9 @@ if pioutil.is_pio_build():
target_drive = "REARM"
import platform
current_OS = platform.system()
Import("env")
env = pioutil.env
def print_error(e):
print('\nUnable to find destination disk (%s)\n' \

View file

@ -1,56 +0,0 @@
from __future__ import print_function
import sys
#dynamic build flags for generic compile options
if __name__ == "__main__":
args = " ".join([ "-std=gnu++14",
"-Os",
"-mcpu=cortex-m3",
"-mthumb",
"-fsigned-char",
"-fno-move-loop-invariants",
"-fno-strict-aliasing",
"-fsingle-precision-constant",
"--specs=nano.specs",
"--specs=nosys.specs",
"-IMarlin/src/HAL/STM32F1",
"-MMD",
"-MP",
"-DTARGET_STM32F1"
])
for i in range(1, len(sys.argv)):
args += " " + sys.argv[i]
print(args)
# extra script for linker options
else:
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
ARFLAGS=["rcs"],
ASFLAGS=["-x", "assembler-with-cpp"],
CXXFLAGS=[
"-fabi-version=0",
"-fno-use-cxa-atexit",
"-fno-threadsafe-statics"
],
LINKFLAGS=[
"-Os",
"-mcpu=cortex-m3",
"-ffreestanding",
"-mthumb",
"--specs=nano.specs",
"--specs=nosys.specs",
"-u_printf_float",
],
)

View file

@ -6,8 +6,7 @@ import pioutil
if pioutil.is_pio_build():
from os.path import join, isfile
import shutil
Import("env")
env = pioutil.env
mf = env["MARLIN_FEATURES"]
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"

View file

@ -6,8 +6,7 @@ import pioutil
if pioutil.is_pio_build():
from os.path import join, isfile
import shutil
Import("env")
env = pioutil.env
mf = env["MARLIN_FEATURES"]
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"

View file

@ -3,8 +3,7 @@
#
import pioutil
if pioutil.is_pio_build():
Import("env", "projenv")
env = pioutil.env
flash_size = 0
vect_tab_addr = 0

View file

@ -3,9 +3,8 @@
#
import pioutil
if pioutil.is_pio_build():
from os.path import join
from os.path import expandvars
Import("env")
from os.path import join, expandvars
env = pioutil.env
# Custom HEX from ELF
env.AddPostAction(

View file

@ -0,0 +1,63 @@
#!/usr/bin/env python
#
# STM32F1_build_flags.py
# Add build_flags for the base STM32F1_maple environment (stm32f1-maple.ini)
#
from __future__ import print_function
import sys
# Dynamic build flags for generic compile options
if __name__ == "__main__":
# Print these plus the given args when running directly on the command-line
args = [
"-std=gnu++14",
"-Os",
"-mcpu=cortex-m3",
"-mthumb",
"-fsigned-char",
"-fno-move-loop-invariants",
"-fno-strict-aliasing",
"-fsingle-precision-constant",
"--specs=nano.specs",
"--specs=nosys.specs",
"-MMD", "-MP",
"-IMarlin/src/HAL/STM32F1",
"-DTARGET_STM32F1",
"-DARDUINO_ARCH_STM32",
"-DPLATFORM_M997_SUPPORT"
] + sys.argv[1:]
print(" ".join(args))
else:
# Extra script for stm32f1-maple.ini build_flags
import pioutil
if pioutil.is_pio_build():
pioutil.env.Append(
ARFLAGS=["rcs"],
ASFLAGS=["-x", "assembler-with-cpp"],
CXXFLAGS=[
"-fabi-version=0",
"-fno-use-cxa-atexit",
"-fno-threadsafe-statics"
],
LINKFLAGS=[
"-Os",
"-mcpu=cortex-m3",
"-ffreestanding",
"-mthumb",
"--specs=nano.specs",
"--specs=nosys.specs",
"-u_printf_float",
],
)

View file

@ -3,10 +3,9 @@
#
import pioutil
if pioutil.is_pio_build():
import shutil,marlin
import shutil, marlin
from pathlib import Path
Import("env")
env = pioutil.env
platform = env.PioPlatform()
board = env.BoardConfig()

View file

@ -1,6 +0,0 @@
#
# add_nanolib.py
#
Import("env")
env.Append(LINKFLAGS=["--specs=nano.specs"])

View file

@ -4,9 +4,9 @@
#
import pioutil
if pioutil.is_pio_build():
import struct,uuid,marlin
import struct, uuid, marlin
board = marlin.env.BoardConfig()
board = pioutil.env.BoardConfig()
def calculate_crc(contents, seed):
accumulating_xor_value = seed

View file

@ -7,8 +7,7 @@ import pioutil
if pioutil.is_pio_build():
import os, re
Import("env")
Import("projenv")
env = pioutil.env
os.environ['PATH'] = f"./buildroot/bin/:./buildroot/tests/:{os.environ['PATH']}"

View file

@ -5,7 +5,7 @@
import pioutil
if pioutil.is_pio_build():
Import("env")
env = pioutil.env
cxxflags = [
# "-Wno-incompatible-pointer-types",

View file

@ -4,7 +4,9 @@
#
import pioutil
if pioutil.is_pio_build():
Import("env", "projenv")
env = pioutil.env
projenv = env
Import("projenv") # src_dir environment. Only for post: scripts!
def apply_board_build_flags():
if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']:

View file

@ -5,10 +5,10 @@
import pioutil
if pioutil.is_pio_build():
import subprocess,os,re,fnmatch,glob
import os, re, fnmatch, glob
srcfilepattern = re.compile(r".*[.](cpp|c)$")
marlinbasedir = os.path.join(os.getcwd(), "Marlin/")
Import("env")
env = pioutil.env
from platformio.package.meta import PackageSpec
from platformio.project.config import ProjectConfig

View file

@ -11,7 +11,7 @@ def blab(str,level=1):
if verbose >= level: print(f"[config] {str}")
def config_path(cpath):
return Path("Marlin", cpath, encoding='utf-8')
return Path("Marlin", cpath)
# Apply a single name = on/off ; name = value ; etc.
# TODO: Limit to the given (optional) configuration
@ -223,7 +223,7 @@ def apply_config_ini(cp):
sect = 'base'
if '@' in ckey: sect, ckey = map(str.strip, ckey.split('@'))
cp2 = configparser.ConfigParser()
cp2.read(config_path(ckey))
cp2.read(config_path(ckey), encoding='utf-8')
apply_sections(cp2, sect)
ckey = 'base'
@ -270,7 +270,7 @@ if __name__ == "__main__":
if ini_file:
user_ini = configparser.ConfigParser()
user_ini.read(ini_file)
user_ini.read(ini_file, encoding='utf-8')
apply_config_ini(user_ini)
else:
@ -279,11 +279,8 @@ else:
#
import pioutil
if pioutil.is_pio_build():
Import("env")
try:
verbose = int(env.GetProjectOption('custom_verbose'))
verbose = int(pioutil.env.GetProjectOption('custom_verbose'))
except:
pass

View file

@ -7,7 +7,7 @@
import pioutil
if pioutil.is_pio_build():
import marlin
board = marlin.env.BoardConfig()
board = pioutil.env.BoardConfig()
address = board.get("build.address", "")
if address:

View file

@ -4,10 +4,10 @@
#
import pioutil
if pioutil.is_pio_build():
Import("env")
import requests,zipfile,tempfile,shutil
import requests, zipfile, tempfile, shutil
from pathlib import Path
env = pioutil.env
url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR"))
zip_path = deps_path / "mks-assets.zip"

View file

@ -8,8 +8,7 @@ if pioutil.is_pio_build():
from os.path import join, isfile
from pprint import pprint
Import("env")
env = pioutil.env
if env.MarlinHas("POSTMORTEM_DEBUGGING"):
FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")

View file

@ -8,14 +8,14 @@
import pioutil, re
marlin_variant_pattern = re.compile("marlin_.*")
if pioutil.is_pio_build():
import shutil,marlin
import shutil, marlin
from pathlib import Path
#
# Get the platform name from the 'platform_packages' option,
# or look it up by the platform.class.name.
#
env = marlin.env
env = pioutil.env
platform = env.PioPlatform()
from platformio.package.meta import PackageSpec

View file

@ -7,7 +7,7 @@
#
import pioutil
if pioutil.is_pio_build():
import os,marlin
import os, marlin
board = marlin.env.BoardConfig()

View file

@ -2,9 +2,7 @@
#
# Create a Configuration from marlin_config.json
#
import json
import sys
import shutil
import json, sys, shutil
opt_output = '--opt' in sys.argv
output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen'

View file

@ -4,8 +4,7 @@
import pioutil
if pioutil.is_pio_build():
from os.path import join
Import("env")
env = pioutil.env
board = env.BoardConfig()
board_keys = board.get("build").keys()

View file

@ -2,10 +2,11 @@
# pioutil.py
#
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
# Make sure 'vscode init' is not the current command
def is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
if "IsCleanTarget" in dir(env) and env.IsCleanTarget(): return False
return not env.IsIntegrationDump()

View file

@ -5,9 +5,9 @@
import pioutil
if pioutil.is_pio_build():
import re,sys
import re, sys
from pathlib import Path
Import("env")
env = pioutil.env
def get_envs_for_board(board):
ppath = Path("Marlin/src/pins/pins.h")

View file

@ -6,7 +6,7 @@
import pioutil
if pioutil.is_pio_build():
# Get the environment thus far for the build
Import("env")
env = pioutil.env
#print(env.Dump())

View file

@ -3,7 +3,7 @@
#
import pioutil
if pioutil.is_pio_build():
Import("env")
env = pioutil.env
# Get a build flag's value or None
def getBuildFlagValue(name):

View file

@ -7,9 +7,7 @@ if pioutil.is_pio_build():
import marlin, os
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env = pioutil.env
# Check whether the "update" folder exists
outpath = "update"

View file

@ -206,12 +206,12 @@ class Entry():
'''
__slots__ = ('width', 'height', 'offset', 'length', 'filename')
def __init__(self, w=0, h=0, length=0, offset=0):
def __init__(self, w=0, h=0, length=0, offset=0, filename=None):
self.width = w
self.height = h
self.offset = offset
self.length = length
self.filename = None
self.filename = filename
def parseRawData(self, rawEntryBytes):
if len(rawEntryBytes) != 16:

View file

@ -181,7 +181,7 @@ class Protocol(object):
except ReadTimeout:
self.errors += 1
#print("Packetloss detected..")
except serial.serialutil.SerialException:
except serial.SerialException:
return
self.packet_transit = None
@ -201,7 +201,7 @@ class Protocol(object):
def transmit_packet(self, packet):
packet = bytearray(packet)
if(self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)):
if (self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)):
if random.random() > 0.9:
#random data drop
start = random.randint(0, len(packet))

View file

@ -22,7 +22,7 @@ from __future__ import print_function
from __future__ import division
from math import *
import sys,getopt
import sys, getopt
"Constants"
ZERO = 273.15 # zero point of Kelvin scale

View file

@ -22,7 +22,7 @@
# Generate Marlin TFT Images from bitmaps/PNG/JPG
import sys,struct
import sys, struct
from PIL import Image
def image2bin(image, output_file):

View file

@ -17,7 +17,7 @@ TODO: Use the defines and comments above the namespace from existing language fi
"""
import sys, re, requests, csv, datetime
from languageUtil import namebyid
#from languageUtil import namebyid
LANGHOME = "Marlin/src/lcd/language"
OUTDIR = 'out-language'
@ -76,10 +76,10 @@ for row in reader:
# Add the named string for all the included languages
name = row[0]
for i in range(1, numcols):
str = row[i]
if str:
str_key = row[i]
if str_key:
col = columns[i]
strings_per_lang[col['lang']][col['style']][name] = str
strings_per_lang[col['lang']][col['style']][name] = str_key
# Create a folder for the imported language outfiles
from pathlib import Path
@ -199,11 +199,11 @@ for i in range(1, numcols):
comm = ''
if lang != 'en' and 'en' in strings_per_lang:
en = strings_per_lang['en']
if name in en[style]: str = en[style][name]
elif name in en['Narrow']: str = en['Narrow'][name]
if str:
if name in en[style]: str_key = en[style][name]
elif name in en['Narrow']: str_key = en['Narrow'][name]
if str_key:
cfmt = '%%%ss// %%s' % (50 - len(val) if len(val) < 50 else 1)
comm = cfmt % (' ', str)
comm = cfmt % (' ', str_key)
# Write out the string definition
f.write(lstr_fmt % (name, val, comm))

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# marlang.py
# languageUtil.py
#
# A dictionary to contain language names

View file

@ -5,7 +5,7 @@
#
# Usage: rle16_compress_cpp_image_data.py INPUT_FILE.cpp OUTPUT_FILE.cpp
#
import sys,struct
import sys, struct
import re
def addCompressedData(input_file, output_file):

View file

@ -6,7 +6,7 @@
#
# Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE
#
import sys,struct
import sys, struct
import re
def addCompressedData(input_file, output_file):

View file

@ -1,11 +1,6 @@
import argparse
import sys
import os
import time
import random
import serial
Import("env")
import argparse, sys, os, time, random, serial
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
import MarlinBinaryProtocol

View file

@ -72,7 +72,7 @@
from __future__ import print_function
from __future__ import division
import sys,os,re
import sys, os, re
pwd = os.getcwd() # make sure we're executing from the correct directory level
pwd = pwd.replace('\\', '/')
@ -103,7 +103,7 @@ current_OS = platform.system()
target_env = ''
board_name = ''
from datetime import datetime, date, time
from datetime import datetime
#########
# Python 2 error messages:
@ -151,8 +151,6 @@ def get_answer(board_name, question_txt, options, default_value=1):
root_get_answer.protocol("WM_DELETE_WINDOW", disable_event)
root_get_answer.resizable(False, False)
root_get_answer.radio_state = default_value # declare variables used by TK and enable
global get_answer_val
get_answer_val = default_value # return get_answer_val, set default to match radio_state default
@ -880,7 +878,6 @@ def run_PIO(dummy):
print('build_type: ', build_type)
import subprocess
import sys
print('starting platformio')
@ -965,7 +962,6 @@ def run_PIO(dummy):
########################################################################
import time
import threading
if python_ver == 2:
import Tkinter as tk
@ -978,7 +974,6 @@ else:
import tkinter as tk
import queue as queue
from tkinter import ttk, Tk, Frame, Text, Menu
import subprocess
import sys
que = queue.Queue()
#IO_queue = queue.Queue()

View file

@ -13,7 +13,7 @@
from __future__ import print_function
from __future__ import division
import subprocess,os,platform
import subprocess, os, platform
from SCons.Script import DefaultEnvironment
current_OS = platform.system()

View file

@ -9,9 +9,9 @@
# Will continue on if a COM port isn't found so that the compilation can be done.
#
import os
import os, platform
from SCons.Script import DefaultEnvironment
import platform
current_OS = platform.system()
env = DefaultEnvironment()

View file

@ -25,13 +25,13 @@
[STM32F1_maple]
platform = ststm32@~12.1
board_build.core = maple
build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py
build_flags = !python buildroot/share/PlatformIO/scripts/STM32F1_build_flags.py
${common.build_flags} -DARDUINO_ARCH_STM32 -DMAPLE_STM32F1 -DPLATFORM_M997_SUPPORT
build_unflags = -std=gnu11 -std=gnu++11
build_src_filter = ${common.default_src_filter} +<src/HAL/STM32F1> -<src/HAL/STM32F1/tft>
lib_ignore = SPI, FreeRTOS701, FreeRTOS821
lib_deps = ${common.lib_deps}
SoftwareSerialM
SoftwareSerialM
platform_packages = tool-stm32duino
extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py