1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Rework CI workflows (#8688)

- split workflows into separate files to trigger by path
  this should help out documentation and boards / eboot / pkg files
  updates, since those *wont* trigger usual build stuff anymore
- build*.sh whatever merged into just common.sh and build.sh
  trigger different parity builds, mod % rem and allow to set .ino list
  through the environment variable
- removes unnecessary temporary files, try to use more pipes
  move remaining ones into cache dir instead of PWD
- remove legacy TRAVIS env vars, use ESP8266_ARDUINO prefix for config
- remove Windows path workarounds
- hardware/ and ide/ directories are set through envionment
  do not force specific paths, simplify builds on local machine
- sketch list is set through environment. expicit paths for Windows and
  macOS builders. platformio also gets a real shuffled list instead of
  mod and rem magic numbers
- detect root of the repo through git cli, not base{name,dir} or relative paths
This commit is contained in:
Max Prokhorov
2022-10-31 21:13:40 +03:00
committed by GitHub
parent 2360d1cff1
commit 0aab6ecee2
28 changed files with 925 additions and 772 deletions

View File

@ -30,34 +30,25 @@ import tempfile
import shutil
# Arduino-builder needs forward-slash paths for passed in params or it cannot
# launch the needed toolset.
def windowsize_paths(l):
"""Convert forward-slash paths to backslash paths referenced from C:"""
out = []
for i in l:
if i.startswith('/'):
i = 'C:' + i
out += [i.replace('/', '\\')]
return out
def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
def compile(tmp_dir, sketch, cache, ide_path, f, args):
cmd = []
cmd += [ide_path + '/arduino-builder']
cmd += [os.path.join(ide_path, 'arduino-builder')]
cmd += ['-compile', '-logger=human']
cmd += ['-build-path', tmp_dir]
cmd += ['-tools', ide_path + '/tools-builder']
if cache != "":
cmd += ['-build-cache', cache ]
if args.library_path:
for lib_dir in args.library_path:
cmd += ['-libraries', lib_dir]
cmd += ['-hardware', ide_path + '/hardware']
if args.hardware_dir:
for hw_dir in args.hardware_dir:
cmd += ['-hardware', hw_dir]
else:
cmd += ['-hardware', hardware_dir]
cmd += ['-tools', os.path.join(ide_path, 'tools-builder')]
cmd += ['-hardware', os.path.join(ide_path, 'hardware')]
flag_paths = [
['-tools', args.tool_path],
['-libraries', args.library_path],
['-hardware', args.hardware_path]]
for flag, paths in flag_paths:
for path in paths or []:
cmd += [flag, path]
# Debug=Serial,DebugLevel=Core____
fqbn = '-fqbn=esp8266com:esp8266:{board_name}:' \
'xtal={cpu_freq},' \
@ -72,16 +63,13 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
if args.waveform_phase:
fqbn += ',waveform=phase'
cmd += [fqbn]
cmd += ['-built-in-libraries', ide_path + '/libraries']
cmd += ['-built-in-libraries', os.path.join(ide_path, 'libraries')]
cmd += ['-ide-version=10802']
cmd += ['-warnings={warnings}'.format(**vars(args))]
if args.verbose:
cmd += ['-verbose']
cmd += [sketch]
if platform.system() == "Windows":
cmd = windowsize_paths(cmd)
if args.verbose:
print('Building: ' + " ".join(cmd), file=f)
@ -95,12 +83,14 @@ def parse_args():
action='store_true')
parser.add_argument('-i', '--ide_path', help='Arduino IDE path')
parser.add_argument('-p', '--build_path', help='Build directory')
parser.add_argument('-t', '--tool_path', help='Additional tool path',
action='append')
parser.add_argument('-d', '--hardware_path', help='Additional hardware path',
action='append')
parser.add_argument('-l', '--library_path', help='Additional library path',
action='append')
parser.add_argument('-d', '--hardware_dir', help='Additional hardware path',
action='append')
parser.add_argument('-b', '--board_name', help='Board name', default='generic')
parser.add_argument('-s', '--flash_size', help='Flash size', default='512K64',
parser.add_argument('-s', '--flash_size', help='Flash size', default='4M1M',
choices=['512K0', '512K64', '1M512', '4M1M', '4M3M'])
parser.add_argument('-f', '--cpu_freq', help='CPU frequency', default=80,
choices=[80, 160], type=int)
@ -112,7 +102,7 @@ def parse_args():
default='none', choices=['none', 'all', 'more'])
parser.add_argument('-o', '--output_binary', help='File name for output binary')
parser.add_argument('-k', '--keep', action='store_true',
help='Don\'t delete temporary build directory')
help="Don't delete temporary build directory")
parser.add_argument('--flash_freq', help='Flash frequency', default=40,
type=int, choices=[40, 80])
parser.add_argument('--debug_port', help='Debug port',
@ -121,6 +111,9 @@ def parse_args():
help='Select waveform locked on phase')
parser.add_argument('--debug_level', help='Debug level')
parser.add_argument('--build_cache', help='Build directory to cache core.a', default='')
parser.add_argument('--log', nargs='?', help='Redirect output to a file',
type=argparse.FileType('w'),
default=sys.stdout)
parser.add_argument('sketch_path', help='Sketch file path')
return parser.parse_args()
@ -128,25 +121,17 @@ def main():
args = parse_args()
ide_path = args.ide_path
if not ide_path:
ide_path = os.environ.get('ARDUINO_IDE_PATH')
if not ide_path:
print("Please specify Arduino IDE path via --ide_path option"
"or ARDUINO_IDE_PATH environment variable.", file=sys.stderr)
return 2
sketch_path = args.sketch_path
tmp_dir = args.build_path
created_tmp_dir = False
if not tmp_dir:
tmp_dir = tempfile.mkdtemp()
created_tmp_dir = True
tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools'
# this is not the correct hardware folder to add.
hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores'
file = os.path.realpath(__file__)
output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin'
output_name = os.path.join(tmp_dir, f'{os.path.basename(sketch_path)}.bin')
if args.verbose:
print("Sketch: ", sketch_path)
@ -154,12 +139,7 @@ def main():
print("Cache dir: ", args.build_cache)
print("Output: ", output_name)
if args.verbose:
f = sys.stdout
else:
f = open(tmp_dir + '/build.log', 'w')
res = compile(tmp_dir, sketch_path, args.build_cache, tools_dir, hardware_dir, ide_path, f, args)
res = compile(tmp_dir, sketch_path, args.build_cache, ide_path, args.log, args)
if res != 0:
return res