From 6f31674b28ae130d96bc1b882870d61c585dc021 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 7 May 2018 09:31:37 +0800 Subject: [PATCH] cmake: Add ESPORT/ESPBAUD environment variables to idf.py & docs --- docs/en/api-guides/build-system.rst | 2 ++ docs/en/api-guides/gnu-make-build-system.rst | 4 ++++ tools/idf.py | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 28789b3071..2135ca0a2a 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -88,6 +88,8 @@ Type ``idf.py --help`` for a full list of commands. Here are a summary of the mo Multiple ``idf.py`` commands can be combined into one. For example, ``idf.py -p COM4 clean flash monitor`` will clean the source tree, then build the project and flash it to the ESP32 before running the serial monitor. +.. note:: The environment variables ``ESPPORT`` and ``ESPBAUD`` can be used to set default values for the ``-p`` and ``-b`` options, respectively. Providing these options on the command line overrides the default. + Advanced Commands ^^^^^^^^^^^^^^^^^ diff --git a/docs/en/api-guides/gnu-make-build-system.rst b/docs/en/api-guides/gnu-make-build-system.rst index 1f9c5b9bdf..d1a8a41f90 100644 --- a/docs/en/api-guides/gnu-make-build-system.rst +++ b/docs/en/api-guides/gnu-make-build-system.rst @@ -40,11 +40,15 @@ To set the serial port for flashing/monitoring: - CMake based: ``idf.py -p (port) flash`` - GNU Make based: ``make flash ESPPORT=/dev/ttyUSB0``, or set in ``menuconfig``. +(Note: ``idf.py`` will also use the ``ESPPORT`` environment variable for a default serial port, if no ``-p`` argument is provided.) + To set the baud rate for flashing: - CMake based: ``idf.py -b 921600 flash`` - GNU Make based: ``make flash ESPBAUD=921600``, or set in ``menuconfig``. +(Note: ``idf.py`` will also use the ``ESPBAUD`` environment variable for a default baud rate, if no ``-b`` argument is provided.) + Porting GNU Make Based Components to CMake ========================================== diff --git a/tools/idf.py b/tools/idf.py index 3607a90033..d5fbf279a3 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -346,8 +346,10 @@ def get_commandline_options(): def main(): parser = argparse.ArgumentParser(description='ESP-IDF build management tool') - parser.add_argument('-p', '--port', help="Serial port", default=None) - parser.add_argument('-b', '--baud', help="Baud rate", default=460800) + parser.add_argument('-p', '--port', help="Serial port", + default=os.environ.get('ESPPORT', None)) + parser.add_argument('-b', '--baud', help="Baud rate", + default=os.environ.get('ESPBAUD', 460800)) parser.add_argument('-C', '--project-dir', help="Project directory", default=os.getcwd()) parser.add_argument('-B', '--build-dir', help="Build directory", default=None) parser.add_argument('-G', '--generator', help="Cmake generator", choices=GENERATOR_CMDS.keys()) -- 2.40.0