@@ -506,7 +506,7 @@ def isdetached():
506
506
return Git .getbranch () == "HEAD"
507
507
508
508
# Finds default remote
509
- def getremote (rtype = 'fetch' ):
509
+ def getremote ():
510
510
remote = None
511
511
remotes = Git .getremotes ('push' )
512
512
for r in remotes :
@@ -825,7 +825,7 @@ class Program(object):
825
825
is_cwd = False
826
826
is_repo = False
827
827
828
- def __init__ (self , path = None , warnings = False ):
828
+ def __init__ (self , path = None , print_warning = False ):
829
829
path = os .path .abspath (path or os .getcwd ())
830
830
831
831
self .path = os .getcwd ()
@@ -843,11 +843,12 @@ def __init__(self, path=None, warnings=False):
843
843
844
844
self .name = os .path .basename (self .path )
845
845
846
- if warnings :
847
- if self .is_cwd :
848
- warning (
849
- "Could not mbed program in current path. Assuming current dir.\n "
850
- "You can fix this by calling \" mbed new .\" in the root dir of your program" )
846
+ # is_cwd flag indicates that current dir is assumed to be root, not root repo
847
+ if self .is_cwd :
848
+ err = (
849
+ "Could not find mbed program in current path. Assuming current dir.\n "
850
+ "You can fix this by calling \" mbed new .\" in the root dir of your program" )
851
+ return warning (err ) if print_warning else error (err )
851
852
852
853
# Sets config value
853
854
def set_cfg (self , var , val ):
@@ -1381,7 +1382,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
1381
1382
# Gather remaining arguments
1382
1383
args = remainder
1383
1384
# Find the root of the program
1384
- program = Program (os .getcwd (), True )
1385
+ program = Program (os .getcwd (), False )
1385
1386
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
1386
1387
orig_path = os .getcwd ()
1387
1388
@@ -1410,6 +1411,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
1410
1411
1411
1412
if not source or len (source ) == 0 :
1412
1413
source = [os .path .relpath (root_path , orig_path )]
1414
+
1413
1415
if compile_tests :
1414
1416
# Compile tests
1415
1417
if not build :
@@ -1459,7 +1461,7 @@ def test(tlist=False):
1459
1461
# Gather remaining arguments
1460
1462
args = remainder
1461
1463
# Find the root of the program
1462
- program = Program (os .getcwd (), True )
1464
+ program = Program (os .getcwd (), False )
1463
1465
# Change directories to the program root to use mbed OS tools
1464
1466
with cd (program .path ):
1465
1467
if not program .get_tools_dir ():
@@ -1485,7 +1487,7 @@ def export(ide=None, mcu=None):
1485
1487
# Gather remaining arguments
1486
1488
args = remainder
1487
1489
# Find the root of the program
1488
- program = Program (os .getcwd (), True )
1490
+ program = Program (os .getcwd (), False )
1489
1491
# Change directories to the program root to use mbed OS tools
1490
1492
with cd (program .path ):
1491
1493
if not program .get_tools_dir ():
@@ -1515,7 +1517,7 @@ def export(ide=None, mcu=None):
1515
1517
help = 'Set default target for the current program.' )
1516
1518
def target_ (name = None ):
1517
1519
# Find the root of the program
1518
- program = Program (os .getcwd (), True )
1520
+ program = Program (os .getcwd (), False )
1519
1521
# Change directories to the program root to use mbed OS tools
1520
1522
with cd (program .path ):
1521
1523
if name is None :
@@ -1530,7 +1532,7 @@ def target_(name=None):
1530
1532
help = 'Sets default toolchain for the current program.' )
1531
1533
def toolchain_ (name = None ):
1532
1534
# Find the root of the program
1533
- program = Program (os .getcwd (), True )
1535
+ program = Program (os .getcwd (), False )
1534
1536
# Change directories to the program root to use mbed OS tools
1535
1537
with cd (program .path ):
1536
1538
if name is None :
0 commit comments