Skip to content

Modify "mbed new" to create mbed_app.json with default content. #818

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 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ commands:
- change_mbed_os_version:
version: "5.2.3"
- check_inspection
- run:
name: Removing mbed_app.json for 5.1.5
working_directory: integration_tests/supported-tests
command: rm mbed_app.json
- change_mbed_os_version:
version: "5.1.5"
- check_inspection
Expand Down
9 changes: 9 additions & 0 deletions mbed/mbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import re
import subprocess
import os
import json
import platform
import contextlib
import shutil
Expand Down Expand Up @@ -221,6 +222,13 @@ def hide_progress(max_width=80):
if sys.stdout.isatty():
sys.stdout.write("\r%s\r" % (' ' * max_width))

def create_default_mbed_app():
# Default data content
data = {'target_overrides':{'K64F':{'platform.stdio-baud-rate': 9600}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you feel about swapping the K64F for * so it would be generic for all targets?

Suggested change
data = {'target_overrides':{'K64F':{'platform.stdio-baud-rate': 9600}}}
data = {'target_overrides':{'*':{'platform.stdio-baud-rate': 9600}}}

Copy link
Contributor

Choose a reason for hiding this comment

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

@bridadan There are targets that have non-9600 default baud rates because they can't support 9600, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good point (pretty sure some silicon lab targets do that).

filehandler = open("mbed_app.json","w")
json.dump(data, filehandler, indent=4)
filehandler.close()

# Process execution
class ProcessException(Exception):
pass
Expand Down Expand Up @@ -2088,6 +2096,7 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
try:
with cd(d_path):
add(url, path=d, depth=depth, protocol=protocol, top=False)
create_default_mbed_app()
except Exception as e:
if os.path.isdir(os.path.join(d_path, d)):
rmtree_readonly(os.path.join(d_path, d))
Expand Down