mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-29 09:10:03 +02:00
Added python build-all and build-machine scripts
This commit is contained in:
39
build-all.py
Normal file
39
build-all.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
# Compile Grbl_ESP32 for each of the machines defined in Machines/ .
|
||||
# Add-on files are built on top of a single base.
|
||||
# This is useful for automated testing, to make sure you haven't broken something
|
||||
|
||||
# The output is filtered so that the only lines you see are a single
|
||||
# success or failure line for each build, plus any preceding lines that
|
||||
# contain the word "error". If you need to see everything, for example to
|
||||
# see the details of an errored build, include -v on the command line.
|
||||
|
||||
from __future__ import print_function
|
||||
import os, subprocess, sys
|
||||
|
||||
env = dict(os.environ)
|
||||
verbose = '-v' in sys.argv
|
||||
|
||||
def buildMachine(baseName, addName=None):
|
||||
displayName = baseName
|
||||
flags = '-DMACHINE_FILENAME=' + baseName
|
||||
if addName:
|
||||
displayName += ' + ' + addName
|
||||
flags += ' -DMACHINE_FILENAME2=' + addName
|
||||
print('Building machine ' + displayName)
|
||||
env['PLATFORMIO_BUILD_FLAGS'] = flags
|
||||
app = subprocess.Popen(['platformio','run'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, env=env)
|
||||
for line in app.stdout:
|
||||
if verbose or "Took" in line or "error" in line.lower():
|
||||
print(line, end='')
|
||||
print()
|
||||
|
||||
adderBase = '3axis_v4.h'
|
||||
for name in os.listdir('Grbl_Esp32/Machines'):
|
||||
if name.startswith('add_'):
|
||||
buildMachine(adderBase, name)
|
||||
else:
|
||||
buildMachine(name)
|
||||
|
||||
|
51
build-machine.py
Normal file
51
build-machine.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
# Compile Grbl_ESP32 for the machine listed on the command line, as in
|
||||
# ./build-machine.py 3xis_v4.h
|
||||
|
||||
# Add-ons can be built by listing both the base name and the adder, as in
|
||||
# ./build-machine.py 3axis_v4.h add_esc_spindle.h
|
||||
|
||||
# -q suppresses most messages
|
||||
# -u uploads the firmware to the target machine
|
||||
|
||||
from __future__ import print_function
|
||||
import os, subprocess, sys
|
||||
|
||||
cmd=['platformio','run']
|
||||
verbose = '-v' in sys.argv or '-q' not in sys.argv
|
||||
if '-v' in sys.argv:
|
||||
sys.argv.remove('-v')
|
||||
if '-q' in sys.argv:
|
||||
sys.argv.remove('-q')
|
||||
if '-u' in sys.argv:
|
||||
sys.argv.remove('-u')
|
||||
cmd.append('--target=upload')
|
||||
|
||||
env = dict(os.environ)
|
||||
|
||||
def buildMachine(baseName, addName=None):
|
||||
displayName = baseName
|
||||
flags = '-DMACHINE_FILENAME=' + baseName
|
||||
if addName:
|
||||
displayName += ' + ' + addName
|
||||
flags += ' -DMACHINE_FILENAME2=' + addName
|
||||
print('Building machine ' + displayName)
|
||||
env['PLATFORMIO_BUILD_FLAGS'] = flags
|
||||
if verbose:
|
||||
subprocess.Popen(cmd, env=env).wait()
|
||||
else:
|
||||
app = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, env=env)
|
||||
for line in app.stdout:
|
||||
if "Took" in line or 'Uploading' in line or "error" in line.lower():
|
||||
print(line, end='')
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
buildMachine(sys.argv[1], None)
|
||||
elif len(sys.argv) == 3:
|
||||
buildMachine(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
print("Usage: ./build-machine.py [-q] [-u] machine_name.h [add_name.h]")
|
||||
print(' Build for the given machine and optional add-on regardless of machine.h')
|
||||
print(' -q suppresses most messages')
|
||||
print(' -u uploads to the target after compilation')
|
Reference in New Issue
Block a user