Skip to content

Commit 09a8cdc

Browse files
committed
Allow compiling and exporting from current dir if program (root repository) is not found. #106
1 parent 6e7e3b2 commit 09a8cdc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

mbed/mbed.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,10 +1070,7 @@ def __init__(self, path=None, print_warning=False):
10701070
err = (
10711071
"Could not find mbed program in current path. Assuming current dir.\n"
10721072
"You can fix this by calling \"mbed new .\" in the root dir of your program")
1073-
if print_warning:
1074-
warning(err)
1075-
else:
1076-
error(err, 1)
1073+
warning(err) if print_warning else error(err, 1)
10771074

10781075
# Sets config value
10791076
def set_cfg(self, var, val):
@@ -1664,7 +1661,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
16641661
# Gather remaining arguments
16651662
args = remainder
16661663
# Find the root of the program
1667-
program = Program(os.getcwd(), False)
1664+
program = Program(os.getcwd(), True)
16681665
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
16691666
orig_path = os.getcwd()
16701667

@@ -1743,11 +1740,11 @@ def test(tlist=False):
17431740
# Gather remaining arguments
17441741
args = remainder
17451742
# Find the root of the program
1746-
program = Program(os.getcwd(), False)
1743+
program = Program(os.getcwd(), True)
17471744
# Change directories to the program root to use mbed OS tools
17481745
with cd(program.path):
17491746
if not program.get_tools_dir():
1750-
error('The mbed OS codebase or tools were not found in "%s".' % program.path, -1)
1747+
error('The mbed tools were not found in "%s".' % program.path, -1)
17511748

17521749
# Prepare environment variables
17531750
env = os.environ.copy()
@@ -1769,11 +1766,11 @@ def export(ide=None, mcu=None):
17691766
# Gather remaining arguments
17701767
args = remainder
17711768
# Find the root of the program
1772-
program = Program(os.getcwd(), False)
1769+
program = Program(os.getcwd(), True)
17731770
# Change directories to the program root to use mbed OS tools
17741771
with cd(program.path):
17751772
if not program.get_tools_dir():
1776-
error('The mbed OS codebase or tools were not found in "%s".' % program.path, -1)
1773+
error('The mbed tools were not found in "%s".' % program.path, -1)
17771774

17781775
target = mcu if mcu else program.get_cfg('TARGET')
17791776
if target is None:
@@ -1813,7 +1810,7 @@ def toolchain_(name=None):
18131810
help='Sets or get program default options.')
18141811
def default_(name, value=None):
18151812
# Find the root of the program
1816-
program = Program(os.getcwd(), False)
1813+
program = Program(os.getcwd())
18171814
# Change current dir to program root
18181815
with cd(program.path):
18191816
var = str(name).upper()

0 commit comments

Comments
 (0)