{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4215","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4215/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4215/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4215/events","html_url":"https://github.com/ARMmbed/mbed-os/pull/4215","id":223495279,"number":4215,"title":"Add script to lint targets.json","user":{"login":"theotherjimmy","id":685409,"avatar_url":"https://avatars1.githubusercontent.com/u/685409?v=3","gravatar_id":"","url":"https://api.github.com/users/theotherjimmy","html_url":"https://github.com/theotherjimmy","followers_url":"https://api.github.com/users/theotherjimmy/followers","following_url":"https://api.github.com/users/theotherjimmy/following{/other_user}","gists_url":"https://api.github.com/users/theotherjimmy/gists{/gist_id}","starred_url":"https://api.github.com/users/theotherjimmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theotherjimmy/subscriptions","organizations_url":"https://api.github.com/users/theotherjimmy/orgs","repos_url":"https://api.github.com/users/theotherjimmy/repos","events_url":"https://api.github.com/users/theotherjimmy/events{/privacy}","received_events_url":"https://api.github.com/users/theotherjimmy/received_events","type":"User","site_admin":false},"labels":[{"id":515347831,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/component:%20tools","name":"component: tools","color":"5319e7","default":false},{"id":147112891,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/needs:%20review","name":"needs: review","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2017-04-21T20:58:54Z","updated_at":"2017-06-19T16:19:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/4215","html_url":"https://github.com/ARMmbed/mbed-os/pull/4215","diff_url":"https://github.com/ARMmbed/mbed-os/pull/4215.diff","patch_url":"https://github.com/ARMmbed/mbed-os/pull/4215.patch"},"body":"# Description\r\n\r\nThe linting script for targets.json (tools/targets/lint.py) is a utility for\r\navoiding common pit-falls of defining targets, and detecting style \r\ninconsistencies between targets. \r\n\r\n## Rules Enforced\r\nA target's inheritance must look like one of these:\r\n```\r\nMCU -> Board\r\nMCU -> Module -> Board\r\nFamily -> MCU -> Board\r\nFamily -> MCU -> Module -> Board\r\nFamily -> SubFamily -> MCU -> Board\r\nFamily -> SubFamily -> MCU -> Module -> Board\r\n```\r\n\r\nFor each of these target roles, some rules are in place:\r\n1. For Family, MCU and SubFamily, the following keys are allowed\r\n  - `core`\r\n  - `extra_labels`\r\n  - `features`\r\n  - `bootloader_supported`\r\n  - `device_name`\r\n  - `post_binary_hook`\r\n  - `default_tool chain`\r\n  - `config`\r\n  - `target_overrides`\r\n2. MCU's are required to have, and Families and SubFamilies may have:\r\n  - `release_versions`\r\n  - `supported_toolchains`\r\n  - `default_lib`\r\n  - `public`\r\n  - `device_has`\r\n3. For Module and Board, the following keys are allowed:\r\n  - `supported_form_factors`\r\n  - `is_disk_virtual`\r\n  - `detect_code`\r\n  - `extra_labels`\r\n  - `public`\r\n  - `config`\r\n  - `forced_reset_timeout`\r\n  - `target_overrides`\r\n\r\n`macros` is missing from this list. That is intentional: they do not provide any benefit over `config` and `target_overrides` but can be very difficult to use. In practice it is very difficult to override the value of a macro with a value. `config` on the other hand, was designed for this.\r\n  \r\n`extra_labels` may not contain any target names.\r\n\r\nif `release_versions` contains 5, then `supported_toolchains` must contain all \r\nof `GCC_ARM`, `ARM` and `IAR`.\r\n\r\n\r\n# Sample output\r\nThere are three commands, `targets`, `all-targets` and `orphans`. The `targets` \r\nand `all-targets` commands both show errors within public inheritance \r\nhierarchies. The `orphans` command shows all targets that are not reachable from\r\na public target.\r\n\r\n`python tools/targets/lint.py targets EFM32GG_STK3700 EFM32WG_STK3800 LPC11U24_301`\r\n\r\n```yaml\r\nhierarchy: Family (EFM32) -> MCU (EFM32GG990F1024) -> Board (EFM32GG_STK3700)\r\ntarget errors:\r\n  EFM32:\r\n  - EFM32 is not allowed in extra_labels\r\n  EFM32GG990F1024:\r\n  - macros found, and is not allowed\r\n  - default_lib not found, and is required\r\n  - device_has not found, and is required\r\n  EFM32GG_STK3700:\r\n  - progen found, and is not allowed\r\n  - device_has found, and is not allowed\r\n---\r\nhierarchy: Family (EFM32) -> MCU (EFM32WG990F256) -> Board (EFM32WG_STK3800)\r\ntarget errors:\r\n  EFM32:\r\n  - EFM32 is not allowed in extra_labels\r\n  EFM32WG990F256:\r\n  - macros found, and is not allowed\r\n  - default_lib not found, and is required\r\n  - device_has not found, and is required\r\n  EFM32WG_STK3800:\r\n  - progen found, and is not allowed\r\n  - device_has found, and is not allowed\r\n---\r\nhierarchy: Family (LPCTarget) -> MCU (LPC11U24_301) -> ???\r\nhierarchy errors:\r\n- no boards found in heirarchy\r\ntarget errors:\r\n  LPC11U24_301:\r\n  - release_versions not found, and is required\r\n  - default_lib not found, and is required\r\n  - public not found, and is required\r\n```\r\n\r\n`python tools/targets/lint.py orphans`\r\n\r\n```yaml\r\n- CM4_UARM\r\n- CM4_ARM\r\n- CM4F_UARM\r\n- CM4F_ARM\r\n- LPC1800\r\n- EFR32MG1P132F256GM48\r\n- EFR32MG1_BRD4150\r\n```\r\n\r\n\r\n# TODO\r\n\r\n- [x] Documentation"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/309491268","html_url":"https://github.com/ARMmbed/mbed-os/pull/4215#issuecomment-309491268","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4215","id":309491268,"user":{"login":"theotherjimmy","id":685409,"avatar_url":"https://avatars1.githubusercontent.com/u/685409?v=3","gravatar_id":"","url":"https://api.github.com/users/theotherjimmy","html_url":"https://github.com/theotherjimmy","followers_url":"https://api.github.com/users/theotherjimmy/followers","following_url":"https://api.github.com/users/theotherjimmy/following{/other_user}","gists_url":"https://api.github.com/users/theotherjimmy/gists{/gist_id}","starred_url":"https://api.github.com/users/theotherjimmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theotherjimmy/subscriptions","organizations_url":"https://api.github.com/users/theotherjimmy/orgs","repos_url":"https://api.github.com/users/theotherjimmy/repos","events_url":"https://api.github.com/users/theotherjimmy/events{/privacy}","received_events_url":"https://api.github.com/users/theotherjimmy/received_events","type":"User","site_admin":false},"created_at":"2017-06-19T16:19:59Z","updated_at":"2017-06-19T16:19:59Z","body":"@theotherjimmy Get this review please."}}
{"actor":{"display_login":"theotherjimmy"}}