🔨 Build scripts cleanup (#27157)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@@ -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"
|
||||
|
@@ -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"
|
||||
|
@@ -3,8 +3,7 @@
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
Import("env", "projenv")
|
||||
env = pioutil.env
|
||||
|
||||
flash_size = 0
|
||||
vect_tab_addr = 0
|
||||
|
@@ -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(
|
||||
|
63
buildroot/share/PlatformIO/scripts/STM32F1_build_flags.py
Executable file
63
buildroot/share/PlatformIO/scripts/STM32F1_build_flags.py
Executable 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",
|
||||
],
|
||||
)
|
@@ -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()
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# add_nanolib.py
|
||||
#
|
||||
Import("env")
|
||||
|
||||
env.Append(LINKFLAGS=["--specs=nano.specs"])
|
@@ -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
|
||||
|
@@ -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']}"
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
Import("env")
|
||||
env = pioutil.env
|
||||
|
||||
cxxflags = [
|
||||
# "-Wno-incompatible-pointer-types",
|
||||
|
@@ -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']:
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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"
|
||||
|
@@ -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")
|
||||
|
@@ -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
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import os,marlin
|
||||
import os, marlin
|
||||
|
||||
board = marlin.env.BoardConfig()
|
||||
|
||||
|
@@ -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'
|
||||
|
@@ -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()
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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")
|
||||
|
@@ -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())
|
||||
|
||||
|
@@ -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):
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user