Skip to content

Generalize flag handling #1976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 24, 2016
Merged

Generalize flag handling #1976

merged 17 commits into from
Jun 24, 2016

Conversation

theotherjimmy
Copy link
Contributor

@theotherjimmy theotherjimmy commented Jun 20, 2016

affects all flags in:

  • memap.py
  • build.py
  • detect_targets.py
  • get_config.py
  • make.py
  • test.py

All flags that accept a member of list of things now validate that the argument passed is in the list after converting the argument to the appropriate case and replacing "-" with "_" or vice versa, whichever is correct.

All flags that accept file paths (except for build directories) now validate that the file or directory exists.

for example:

$ python tools/build.py --source foo
[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"
usage: build.py [-h] [-m MCU] [-t TOOLCHAIN] [-c] [-o OPTIONS]
                [--source SOURCE_DIR] [--build BUILD_DIR] [--no-archive] [-r]
                [--rpc] [-e] [-U] [-u] [-d] [-F] [-b] [--cpputest] [-D MACROS]
                [-S] [-f GENERAL_FILTER_REGEX] [--cppcheck] [-j JOBS]
                [-N ARTIFACT_NAME] [-v] [--silent] [-x]
build.py: error: argument --source: foo does not exist in the filesystem.

and
python tools/build.py -t gcc-arm -m k64f is the same as python tools/build.py -t GCC_ARM -m K64F is the same as python tools/bulid.py -t GcC-ArM -m K64f

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 21, 2016

cc @mlnx

@MarceloSalazar
Copy link

@theotherjimmy thanks for looking into this. It looks good to me.

@theotherjimmy
Copy link
Contributor Author

@0xc0170, @mlnx would you like to see similar changes across the tools, making them all have a similar interface?

@theotherjimmy
Copy link
Contributor Author

Well, I did it anyway. Let's see if this breaks anything.

@theotherjimmy theotherjimmy changed the title Generalize flag handling in memap.py Generalize flag handling Jun 21, 2016
@geky
Copy link
Contributor

geky commented Jun 21, 2016

+1 from me, this is nice stuff

@MarceloSalazar
Copy link

+1

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jun 21, 2016

Working on more porting of argument parsing to the more liberal style.

Targets:

  • all of the things that use get_default_test_options_parser
  • project.py

@theotherjimmy
Copy link
Contributor Author

I think I got everything I wanted to for now. LGTM? @0xc0170 @bogdanm

for i in sorted(self.modules):
for k in self.print_sections:
csv_module_section += [i+k]
csv_sizes += [self.modules[i][k]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look like pretty significant changes to memap.py? Should this be in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said, it only looks significant. I just moved each export format to it's own function and called them with a 'python case statement' (a dict lookup). I can move it to another PR if that's more appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried doing some builds from master and from this PR and it looks like the output was affected.

Master

Building project detect (RZ_A1H, ARM)
Compile: main.cpp
Compile: test_env.cpp
Link: detect
Elf2Bin: detect
+-----------+-------+-------+--------+
| Module    | .text | .data |  .bss  |
+-----------+-------+-------+--------+
| Misc      | 40479 |  246  | 626804 |
| Subtotals | 40479 |  246  | 626804 |
+-----------+-------+-------+--------+
Static RAM memory (data + bss): 627050
Heap: 0
Stack: 0
Total RAM memory (data + bss + heap + stack): 627050
Total Flash memory (text + data + misc): 40725

PR

Building project detect (RZ_A1H, ARM)
Compile: main.cpp
Compile: test_env.cpp
Link: detect
Elf2Bin: detect
+-----------+-------+-------+------+
| Module    | .text | .data | .bss |
+-----------+-------+-------+------+
| Subtotals |   0   |   0   |  0   |
+-----------+-------+-------+------+
Static RAM memory (data + bss): 0
Heap: 0
Stack: 0
Total RAM memory (data + bss + heap + stack): 0
Total Flash memory (text + data + misc): 0

So even if it shouldn't change anything, it looks like it is. So perhaps this change should be in another PR?

@bridadan
Copy link
Contributor

At first glance, these changes look good, thanks @theotherjimmy.

One thing that stands out to me is in make.py and project.py, if an incorrect test name or number was provided (via -n or -p respectively), a list of available tests were printed to help the user. As far as I can, tell this has capability was removed? Here in make.py: https://github.com/mbedmicro/mbed/pull/1976/files. And here in project.py: https://github.com/mbedmicro/mbed/pull/1976/files. Unless this is handled by argparse?

I'd like to test this locally too, but so far it's looking good.

@theotherjimmy
Copy link
Contributor Author

outputs!

$  python tools/make.py -p -1
[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"
usage: make.py [-h] [-m MCU] [-t TOOLCHAIN] [-c] [-o OPTIONS]
               (-p PROGRAM | -n PROGRAM) [-j JOBS] [-v] [--silent] [-D MACROS]
               [-S] [-f GENERAL_FILTER_REGEX] [--automated] [--host HOST_TEST]
               [--extra EXTRA] [--peripherals PERIPHERALS]
               [--dep DEPENDENCIES] [--source SOURCE_DIR]
               [--duration DURATION] [--build BUILD_DIR] [-N ARTIFACT_NAME]
               [-d DISK] [-s SERIAL] [-b BAUD] [-L] [--rtos] [--rpc] [--eth]
               [--usb_host] [--usb] [--dsp] [--fat] [--ublox] [--testlib]
               [-l LINKER_SCRIPT]
make.py: error: argument -p: -1 does not index a test. The accepted range is 0 to 135

and

$ python tools/project.py -n foo
[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"
usage: project.py [-h] -m MCU -i IDE [-c] (-p PROGRAM | -n PROGRAM) [-b] [-L]
                  [-S] [-E] [--source [SOURCE_DIR [SOURCE_DIR ...]]]
                  [-D MACROS]
project.py: error: argument -n: Program with name 'foo' not found. Supported tests are KL25Z_2, KL25Z_3, NET_11, NET_10, NET_13, NET_12, USB_6, NET_14, USB_4, USB_5, BENCHMARK_3, BENCHMARK_2, BENCHMARK_1, BENCHMARK_5, BENCHMARK_4, NET_9, NET_8, NET_1, NET_3, NET_2, NET_5, NET_4, NET_7, NET_6, USB_1, UT_SPI_ASYNCH, USB_2, UT_SERIAL_ASYNCH, USB_3, MBED_A24, MBED_A25, MBED_A26, MBED_A27, MBED_A20, MBED_A21, MBED_A22, MBED_A23, USB_7, MBED_A1, RTOS_2, EXAMPLE_2, EXAMPLE_1, RTOS_1, MBED_A2, RTOS_7, RTOS_6, RTOS_5, RTOS_4, CMSIS_RTOS_8, DTCT_1, CMSIS_RTOS_3, CMSIS_RTOS_2, CMSIS_RTOS_1, UT_LP_TICKER, CMSIS_RTOS_7, CMSIS_RTOS_6, CMSIS_RTOS_5, CMSIS_RTOS_4, MBED_37, MBED_36, MBED_35, MBED_34, MBED_33, MBED_32, MBED_31, MBED_30, MBED_39, MBED_38, MBED_BLINKY, UT_I2C_EEPROM_ASYNCH, UT_2, UB_1, UB_2, UT_3, MBED_24, MBED_25, MBED_26, MBED_27, MBED_20, MBED_21, MBED_22, MBED_23, UT_1, MBED_28, MBED_29, MBED_A19, MBED_A18, MBED_A15, MBED_A14, MBED_A17, MBED_A16, MBED_A11, MBED_A10, MBED_A13, MBED_A12, UT_BUSIO, MBED_11, MBED_10, MBED_13, MBED_12, MBED_15, MBED_14, MBED_17, MBED_16, MBED_19, MBED_18, MBED_BUS, MBED_AT30TSE75X, CMSIS_DSP_1, MBED_5, MBED_4, MBED_7, MBED_6, MBED_1, MBED_3, MBED_2, KL25Z_4, KL25Z_5, MBED_9, MBED_8, KL25Z_1, RTOS_3, PERF_2, PERF_3, MBED_A3, PERF_1, MBED_A5, MBED_A4, MBED_A7, MBED_A6, MBED_A9, MBED_A8, RTOS_9, RTOS_8, DSP_1, MBED_BUSOUT

@theotherjimmy
Copy link
Contributor Author

Better looking outputs:

$  python tools/project.py -m foo 
[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"
usage: project.py [-h] -m MCU -i IDE [-c] (-p PROGRAM | -n PROGRAM) [-b] [-L]
                  [-S] [-E] [--source [SOURCE_DIR [SOURCE_DIR ...]]]
                  [-D MACROS]
project.py: error: argument -m/--mcu: foo is not a supported MCU. Supported MCUs are:
ARCH_BLE,              ARCH_BLE_BOOT,         ARCH_BLE_OTA, 
ARCH_GPRS,             ARCH_LINK,             ARCH_LINK_BOOT, 
ARCH_LINK_OTA,         ARCH_MAX,              ARCH_PRO, 
ARM_BEETLE_SOC,        ARM_IOTSS_BEID,        ARM_MPS2_M0, 
ARM_MPS2_M0P,          ARM_MPS2_M1,           ARM_MPS2_M3, 
ARM_MPS2_M4,           ARM_MPS2_M7,           B96B_F446VE, 
DELTA_DFCM_NNN40,      DELTA_DFCM_NNN40_BOOT, DELTA_DFCM_NNN40_OTA, 
DISCO_F051R8,          DISCO_F100RB,          DISCO_F303VC, 
DISCO_F334C8,          DISCO_F401VC,          DISCO_F407VG, 
DISCO_F429ZI,          DISCO_F469NI,          DISCO_F746NG, 
DISCO_L053C8,          DISCO_L476VG,          EFM32GG_STK3700, 
EFM32HG_STK3400,       EFM32LG_STK3600,       EFM32PG_STK3401, 
EFM32WG_STK3800,       EFM32ZG_STK3200,       ELEKTOR_COCORICO, 
ELMO_F411RE,           HEXIWEAR,              HRM1017, 
HRM1017_BOOT,          HRM1017_OTA,           K20D50M, 
K22F,                  K64F,                  KL05Z, 
KL25Z,                 KL26Z,                 KL27Z, 
KL43Z,                 KL46Z,                 LPC1114, 
LPC11C24,              LPC11U24,              LPC11U24_301, 
LPC11U34_421,          LPC11U35_401,          LPC11U35_501, 
LPC11U35_501_IBDAP,    LPC11U35_Y5_MBUG,      LPC11U37H_401, 
LPC11U37_501,          LPC11U68,              LPC1347, 
LPC1549,               LPC1768,               LPC2368, 
LPC2460,               LPC4088,               LPC4088_DM, 
LPC4330_M0,            LPC4330_M4,            LPC4337, 
LPC810,                LPC812,                LPC824, 
LPCCAPPUCCINO,         MAX32600MBED,          MAXWSNENV, 
MICRONFCBOARD,         MOTE_L152RC,           MTS_DRAGONFLY_F411RE, 
MTS_GAMBIT,            MTS_MDOT_F405RG,       MTS_MDOT_F411RE, 
NRF51822,              NRF51822_BOOT,         NRF51822_OTA, 
NRF51822_Y5_MBUG,      NRF51_DK,              NRF51_DK_BOOT, 
NRF51_DK_OTA,          NRF51_DONGLE,          NRF51_DONGLE_BOOT, 
NRF51_DONGLE_OTA,      NRF51_MICROBIT,        NRF51_MICROBIT_B, 
NRF51_MICROBIT_BOOT,   NRF51_MICROBIT_B_BOOT, NRF51_MICROBIT_B_OTA, 
NRF51_MICROBIT_OTA,    NUCLEO_F030R8,         NUCLEO_F031K6, 
NUCLEO_F042K6,         NUCLEO_F070RB,         NUCLEO_F072RB, 
NUCLEO_F091RC,         NUCLEO_F103RB,         NUCLEO_F302R8, 
NUCLEO_F303K8,         NUCLEO_F303RE,         NUCLEO_F334R8, 
NUCLEO_F401RE,         NUCLEO_F410RB,         NUCLEO_F411RE, 
NUCLEO_F446RE,         NUCLEO_F746ZG,         NUCLEO_L011K4, 
NUCLEO_L031K6,         NUCLEO_L053R8,         NUCLEO_L073RZ, 
NUCLEO_L152RE,         NUCLEO_L476RG,         NZ32_SC151, 
OC_MBUINO,             RBLAB_BLENANO,         RBLAB_BLENANO_BOOT, 
RBLAB_BLENANO_OTA,     RBLAB_NRF51822,        RBLAB_NRF51822_BOOT, 
RBLAB_NRF51822_OTA,    RZ_A1H,                SAMD21G18A, 
SAMD21J18A,            SAMG55J19,             SAML21J18A, 
SAMR21G18A,            SEEED_TINY_BLE,        SEEED_TINY_BLE_BOOT, 
SEEED_TINY_BLE_OTA,    SSCI824,               STM32F3XX, 
STM32F407,             TEENSY3_1,             TY51822R3, 
TY51822R3_BOOT,        TY51822R3_OTA,         UBLOX_C027, 
UBLOX_C029,            VK_RZ_A1H,             WALLBOT_BLE, 
WALLBOT_BLE_BOOT,      WALLBOT_BLE_OTA,       WIZWIKI_W7500, 
WIZWIKI_W7500ECO,      WIZWIKI_W7500P,        XADOW_M0, 
XBED_LPC1768           

and

$  python tools/project.py -i bar 
usage: project.py [-h] -m MCU -i IDE [-c] (-p PROGRAM | -n PROGRAM) [-b] [-L]
                  [-S] [-E] [--source [SOURCE_DIR [SOURCE_DIR ...]]]
                  [-D MACROS]
project.py: error: argument -i: bar is not a supported toolchain. Supported toolchains are:
atmelstudio,  coide,        ds5_5,        e2studio,     emblocks, 
gcc_arm,      iar,          kds,          lpcxpresso,   simplicityv3, 
sw4stm32,     uvision,      uvision4,     uvision5      

and

$  python tools/project.py -n foo
usage: project.py [-h] -m MCU -i IDE [-c] (-p PROGRAM | -n PROGRAM) [-b] [-L]
                  [-S] [-E] [--source [SOURCE_DIR [SOURCE_DIR ...]]]
                  [-D MACROS]
project.py: error: argument -n: Program with name 'foo' not found. Supported tests are: 
MBED_A1,              MBED_A2,              MBED_A3, 
MBED_A4,              MBED_AT30TSE75X,      MBED_A5, 
MBED_A6,              MBED_A7,              MBED_A8, 
MBED_A9,              MBED_A10,             MBED_A11, 
MBED_A12,             MBED_A13,             MBED_A14, 
MBED_A15,             MBED_A16,             MBED_A17, 
MBED_A18,             MBED_A19,             MBED_A20, 
MBED_A21,             MBED_A22,             MBED_A23, 
MBED_A24,             MBED_A25,             MBED_A26, 
MBED_A27,             MBED_BLINKY,          MBED_BUS, 
MBED_BUSOUT,          BENCHMARK_1,          BENCHMARK_2, 
BENCHMARK_3,          BENCHMARK_4,          BENCHMARK_5, 
PERF_1,               PERF_2,               PERF_3, 
MBED_1,               MBED_2,               MBED_3, 
MBED_4,               MBED_5,               MBED_6, 
MBED_7,               MBED_8,               MBED_9, 
MBED_10,              MBED_11,              MBED_12, 
MBED_13,              MBED_14,              MBED_15, 
MBED_16,              MBED_17,              MBED_18, 
MBED_19,              MBED_20,              MBED_21, 
MBED_22,              MBED_23,              MBED_24, 
MBED_25,              MBED_26,              MBED_27, 
MBED_28,              MBED_29,              MBED_30, 
MBED_31,              MBED_32,              MBED_33, 
MBED_34,              MBED_35,              MBED_36, 
MBED_37,              MBED_38,              MBED_39, 
CMSIS_RTOS_1,         CMSIS_RTOS_2,         CMSIS_RTOS_3, 
CMSIS_RTOS_4,         CMSIS_RTOS_5,         CMSIS_RTOS_6, 
CMSIS_RTOS_7,         CMSIS_RTOS_8,         RTOS_1, 
RTOS_2,               RTOS_3,               RTOS_4, 
RTOS_5,               RTOS_6,               RTOS_7, 
RTOS_8,               RTOS_9,               NET_1, 
NET_2,                NET_3,                NET_4, 
NET_5,                NET_6,                NET_7, 
NET_8,                NET_9,                NET_10, 
NET_11,               NET_12,               NET_13, 
NET_14,               UB_1,                 UB_2, 
USB_1,                USB_2,                USB_3, 
USB_4,                USB_5,                USB_6, 
USB_7,                CMSIS_DSP_1,          DSP_1, 
KL25Z_1,              KL25Z_2,              KL25Z_3, 
KL25Z_4,              KL25Z_5,              EXAMPLE_1, 
EXAMPLE_2,            UT_1,                 UT_2, 
UT_3,                 UT_BUSIO,             UT_I2C_EEPROM_ASYNCH, 
UT_SERIAL_ASYNCH,     UT_SPI_ASYNCH,        UT_LP_TICKER, 
DTCT_1                

and

$  python tools/project.py -p -1 
usage: project.py [-h] -m MCU -i IDE [-c] (-p PROGRAM | -n PROGRAM) [-b] [-L]
                  [-S] [-E] [--source [SOURCE_DIR [SOURCE_DIR ...]]]
                  [-D MACROS]
project.py: error: argument -p: -1 does not index a test. The accepted range is 0 to 135
The test mapping is:
0:MBED_A1,                1:MBED_A2,                2:MBED_A3, 
3:MBED_A4,                4:MBED_AT30TSE75X,        5:MBED_A5, 
6:MBED_A6,                7:MBED_A7,                8:MBED_A8, 
9:MBED_A9,                10:MBED_A10,              11:MBED_A11, 
12:MBED_A12,              13:MBED_A13,              14:MBED_A14, 
15:MBED_A15,              16:MBED_A16,              17:MBED_A17, 
18:MBED_A18,              19:MBED_A19,              20:MBED_A20, 
21:MBED_A21,              22:MBED_A22,              23:MBED_A23, 
24:MBED_A24,              25:MBED_A25,              26:MBED_A26, 
27:MBED_A27,              28:MBED_BLINKY,           29:MBED_BUS, 
30:MBED_BUSOUT,           31:BENCHMARK_1,           32:BENCHMARK_2, 
33:BENCHMARK_3,           34:BENCHMARK_4,           35:BENCHMARK_5, 
36:PERF_1,                37:PERF_2,                38:PERF_3, 
39:MBED_1,                40:MBED_2,                41:MBED_3, 
42:MBED_4,                43:MBED_5,                44:MBED_6, 
45:MBED_7,                46:MBED_8,                47:MBED_9, 
48:MBED_10,               49:MBED_11,               50:MBED_12, 
51:MBED_13,               52:MBED_14,               53:MBED_15, 
54:MBED_16,               55:MBED_17,               56:MBED_18, 
57:MBED_19,               58:MBED_20,               59:MBED_21, 
60:MBED_22,               61:MBED_23,               62:MBED_24, 
63:MBED_25,               64:MBED_26,               65:MBED_27, 
66:MBED_28,               67:MBED_29,               68:MBED_30, 
69:MBED_31,               70:MBED_32,               71:MBED_33, 
72:MBED_34,               73:MBED_35,               74:MBED_36, 
75:MBED_37,               76:MBED_38,               77:MBED_39, 
78:CMSIS_RTOS_1,          79:CMSIS_RTOS_2,          80:CMSIS_RTOS_3, 
81:CMSIS_RTOS_4,          82:CMSIS_RTOS_5,          83:CMSIS_RTOS_6, 
84:CMSIS_RTOS_7,          85:CMSIS_RTOS_8,          86:RTOS_1, 
87:RTOS_2,                88:RTOS_3,                89:RTOS_4, 
90:RTOS_5,                91:RTOS_6,                92:RTOS_7, 
93:RTOS_8,                94:RTOS_9,                95:NET_1, 
96:NET_2,                 97:NET_3,                 98:NET_4, 
99:NET_5,                 100:NET_6,                101:NET_7, 
102:NET_8,                103:NET_9,                104:NET_10, 
105:NET_11,               106:NET_12,               107:NET_13, 
108:NET_14,               109:UB_1,                 110:UB_2, 
111:USB_1,                112:USB_2,                113:USB_3, 
114:USB_4,                115:USB_5,                116:USB_6, 
117:USB_7,                118:CMSIS_DSP_1,          119:DSP_1, 
120:KL25Z_1,              121:KL25Z_2,              122:KL25Z_3, 
123:KL25Z_4,              124:KL25Z_5,              125:EXAMPLE_1, 
126:EXAMPLE_2,            127:UT_1,                 128:UT_2, 
129:UT_3,                 130:UT_BUSIO,             131:UT_I2C_EEPROM_ASYNCH, 
132:UT_SERIAL_ASYNCH,     133:UT_SPI_ASYNCH,        134:UT_LP_TICKER, 
135:DTCT_1       

@theotherjimmy
Copy link
Contributor Author

I'm pretty much done here. @0xc0170 @mlnx @bridadan @bogdanm LGTM?

@bogdanm
Copy link
Contributor

bogdanm commented Jun 22, 2016

Looks good. I'm not completely sold on the replacing "-" with "_" or vice versa (I find that it can be more confusing than helpful), but all in all looks good. +1.

@theotherjimmy
Copy link
Contributor Author

(I find that it can be more confusing than helpful)

I'm curious, confusing for the user of the tools or the developer of the tools?

@theotherjimmy
Copy link
Contributor Author

cc @screamerbg


if __name__ == '__main__':
# Parse Options
parser = get_default_options_parser()
parser.add_option("-p",
type="int",
group = parser.add_mutually_exclusive_group(required=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This required causes an issue when the -L <--list-tests> option is specified:

$ python tools\make.py -L
usage: make.py [-h] [-m MCU] [-t TOOLCHAIN] [-c] [-o OPTIONS]
               (-p PROGRAM | -n PROGRAM) [-j JOBS] [-v] [--silent] [-D MACROS]
               [-S] [-f GENERAL_FILTER_REGEX] [--automated] [--host HOST_TEST]
               [--extra EXTRA] [--peripherals PERIPHERALS]
               [--dep DEPENDENCIES] [--source SOURCE_DIR]
               [--duration DURATION] [--build BUILD_DIR] [-N ARTIFACT_NAME]
               [-d DISK] [-s SERIAL] [-b BAUD] [-L] [--rtos] [--rpc] [--eth]
               [--usb_host] [--usb] [--dsp] [--fat] [--ublox] [--testlib]
               [-l LINKER_SCRIPT]
make.py: error: one of the arguments -p -n is required

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add this comment, here are the valid combinations of arguments for make.py (the top level bullets are exclusive):

  • -L <--list-tests> - This should not require any other arguments to be set (ex. -m, -t, etc)
  • -S <--supported-toolchains> - This should not require any other arguments to be set (ex. -m, -t, etc)
    • NOTE: This command also has historically accepted the -f <--filter> option as well, so this capability should not be lost if at all possible.
  • One of the following commands (exclusively). All of the following should require all the build-related arguments (ex. -m, -t, etc):
    • Exactly one instance of -n
    • Exactly one instance of -p
    • At least one instance of --source (potentially more than one)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requiring the -m and -t would break -S and -L with the current implementation. Really all of these mutually exclusive arguments should be subcommands.

@bridadan
Copy link
Contributor

One thing I noticed is if you don't supply -t or -m to build.py, it by default builds the mbed lib for all targets and toolchains. This is actually really awesome! It's basically a release script, but I wanted to make sure that this was intended. If this is unintended then there might be other unintended behavior.

$ python tools/build.py -m K64F

...[SNIP]...

Completed in: (68.20)s

Build successes:
  * ARM::K64F
  * GCC_ARM::K64F
  * IAR::K64F
Build skipped:
  * uARM::K64F
  * GCC_CR::K64F

@@ -42,24 +42,24 @@
# Parse Options
parser = get_default_options_parser()
Copy link
Contributor

@bridadan bridadan Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is pulling in the following unneeded options: -m, -t, -c <--clean, and -o <--options>. Perhaps this should just be a new instantiation of argparse?

This should probably be in a separate PR though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a PR to fix this @bridadan ?

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jun 24, 2016

Instead of predicting what you meant and doing it for you, the parsers now predict and tell you what you should have typed. For example:

$  python tools/build.py -t gcc-arm
usage: build.py [-h] [-m MCU] [-t TOOLCHAIN] [-c] [-o OPTIONS]
                [--source SOURCE_DIR] [--build BUILD_DIR] [--no-archive] [-r]
                [--rpc] [-e] [-U] [-u] [-d] [-F] [-b] [--cpputest] [-D MACROS]
                [-S] [-f GENERAL_FILTER_REGEX] [--cppcheck] [-j JOBS]
                [-N ARTIFACT_NAME] [-v] [--silent] [-x]
build.py: error: argument -t/--tool: gcc-arm is not a supported toolchain. Did you mean GCC_ARM?

or

$ python tools/build.py -m k64f
usage: build.py [-h] [-m MCU] [-t TOOLCHAIN] [-c] [-o [OPTIONS [OPTIONS ...]]]
                [--source [SOURCE_DIR [SOURCE_DIR ...]]] [--build BUILD_DIR]
                [--no-archive] [-r] [--rpc] [-e] [-U] [-u] [-d] [-F] [-b]
                [--cpputest] [-D [MACROS [MACROS ...]]] [-S]
                [-f GENERAL_FILTER_REGEX] [--cppcheck] [-j JOBS]
                [-N ARTIFACT_NAME] [-v] [--silent] [-x]
build.py: error: argument -m/--mcu: k64f is not a supported MCU. Did you mean K64F?

@geky
Copy link
Contributor

geky commented Jun 24, 2016

Why moving away from autocorrecting name casing? That change seemed like a great way to resolve naming issues between tools.

@screamerbg
Copy link
Contributor

make.py: error: argument -t/--tool: GCC-ARM is not a supported toolchain. Did you mean GCC_ARM?

Great!
+1

@screamerbg
Copy link
Contributor

Why moving away from autocorrecting name casing? That change seemed like a great way to resolve naming issues between tools.

Too much magic. Perhaps solve the issue between tools by fixing the tools?

@screamerbg
Copy link
Contributor

screamerbg commented Jun 24, 2016

And FYI, here is how git handles it

$ git config -global
error: did you mean `--global` (with two dashes ?)

It doesn't auto-correct it for you. It teaches you by showing you the right name, but you still have to type it.

@geky
Copy link
Contributor

geky commented Jun 24, 2016

No I agree it would be magic to change arguments that are not character-equivalent. But being case insensitive isn't magic.

There's no penalty to avoiding confusion between -t GCC_ARM and -i gcc_arm.

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jun 24, 2016

Maybe magic in mbed-cli in particular when the --build option is not specified to test adds a penalty.

@theotherjimmy
Copy link
Contributor Author

build is green; @sg- LGTM.

@sg-
Copy link
Contributor

sg- commented Jun 24, 2016

I think I took it to far by saying that - should be equivalent to _ where I think case sensitivity should be stripped is generally accepted.

I hate SHIFT + anything!!

@sg- sg- merged commit 6dd11c7 into ARMmbed:master Jun 24, 2016
@screamerbg
Copy link
Contributor

Agree that case sensitivity makes much more sense than '-' and '', but then we should propagate across TARGET, TOOLCHAIN_ and FEATURE_ as well?

@geky
Copy link
Contributor

geky commented Jun 24, 2016

I still think - <-> _ is reasonable, but it's debatable.

Agree that case sensitivity makes much more sense than '-' and '', but then we should propagate across TARGET, TOOLCHAIN_ and FEATURE_ as well?

At this point no for backwards compatibility. But the convention for macro names is all uppercase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants