Skip to content

Commit 0f0ba5c

Browse files
committed
Change the default build dir to 'build'
Also add '.mbedignore' to ensure that contents of build are not scanned/included by the build system and reflect the change in the documentation
1 parent 91bdb81 commit 0f0ba5c

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ Allocated Stack: 32768 bytes
339339
Total Static RAM memory (data + bss): 10788 bytes
340340
Total RAM memory (data + bss + heap + stack): 109096 bytes
341341
Total Flash memory (text + data + misc): 66014 bytes
342-
Image: .build/K64F/GCC_ARM/mbed-os-program.bin
342+
Image: build/K64F/GCC_ARM/mbed-os-program.bin
343343
```
344344

345345
The arguments for *compile* are:
346346

347347
* `-m <MCU>` to select a target.
348348
* `-t <TOOLCHAIN>` to select a toolchain (of those defined in `mbed_settings.py`, see above). The value can be either `ARM` (ARM Compiler 5), `GCC_ARM` (GNU ARM Embedded), or `IAR` (IAR Embedded Workbench for ARM).
349349
* `--source <SOURCE>` to select the source directory. The default is `.` (the current directorty). You can specify multiple source locations, even outside the program tree.
350-
* `--build <BUILD>` to select the build directory. Default: `.build/` inside your program.
350+
* `--build <BUILD>` to select the build directory. Default: `build/` inside your program.
351351
* `--options <OPTIONS>` to select compile options. Examples: "debug-info": will generate debugging information; "small-build" will use microlib/nanolib, but limit RTOS to single thread; "save-asm": will save the asm generated by the compiler
352352
* `--library` to compile the code as a [static .a/.ar library](#compiling-static-libraries).
353353
* `--config` to inspect the run-time compile configuration (see below).
@@ -357,7 +357,7 @@ The arguments for *compile* are:
357357
* `-v` or `--verbose` for verbose diagnostic output.
358358
* `-vv` or `--very_verbose` for very verbose diagnostic output.
359359

360-
The compiled binary, ELF image, memory usage and link statistics can be found in the `.build` subdirectory of your program.
360+
The compiled binary, ELF image, memory usage and link statistics can be found in the `build` subdirectory of your program.
361361

362362
### Compiling static libraries
363363

@@ -479,7 +479,7 @@ Allocated Stack: 32768 bytes
479479
Total Static RAM memory (data + bss): 6568 bytes
480480
Total RAM memory (data + bss + heap + stack): 104876 bytes
481481
Total Flash memory (text + data + misc): 48357 bytes
482-
Image: .build\tests\K64F\GCC_ARM\TESTS\mbedmicro-rtos-mbed\mutex\TESTS-unit-myclass.bin
482+
Image: build\tests\K64F\GCC_ARM\TESTS\mbedmicro-rtos-mbed\mutex\TESTS-unit-myclass.bin
483483
...[SNIP]...
484484
mbedgt: test suite report:
485485
+--------------+---------------+---------------------------------+--------+--------------------+-------------+
@@ -509,14 +509,14 @@ The arguments to `test` are:
509509
* `--run` to only run the tests
510510
* `-n <TESTS_BY_NAME>` to limit the tests built or ran to a comma separated list (ex. test1,test2,test3)
511511
* `--source <SOURCE>` to select the source directory. Default is `.` (the current dir). You can specify multiple source locations, even outside the program tree.
512-
* `--build <BUILD>` to select the build directory. Default: `.build/` inside your program.
512+
* `--build <BUILD>` to select the build directory. Default: `build/` inside your program.
513513
* `--options <OPTIONS>` to select compile options. Examples: "debug-info": will generate debugging information; "small-build" will use microlib/nanolib, but limit RTOS to single thread; "save-asm": will save the asm generated by the compiler
514514
* `-c or --clean` to clean the build directory before compiling,
515515
* `--test-spec <TEST_SPEC>` to set the path for the test spec file used when building and running tests (the default path is the build directory).
516516
* `-v` or `--verbose` for verbose diagnostic output.
517517
* `-vv` or `--very_verbose` for very verbose diagnostic output.
518518

519-
The compiled binaries and test artifacts can be found in the `.build/tests/<TARGET>/<TOOLCHAIN>` directory of your program.
519+
The compiled binaries and test artifacts can be found in the `build/tests/<TARGET>/<TOOLCHAIN>` directory of your program.
520520

521521
#### Finding available tests
522522

@@ -539,9 +539,9 @@ You can find the tests that are available for **running** by using the `--run-li
539539

540540
```
541541
$ mbed test --run-list
542-
mbedgt: test specification file '.\.build/tests\K64F\ARM\test_spec.json' (specified with --test-spec option)
543-
mbedgt: using '.\.build/tests\K64F\ARM\test_spec.json' from current directory!
544-
mbedgt: available tests for built 'K64F-ARM', location '.\.build/tests\K64F\ARM'
542+
mbedgt: test specification file '.\build\tests\K64F\ARM\test_spec.json' (specified with --test-spec option)
543+
mbedgt: using '.\build\tests\K64F\ARM\test_spec.json' from current directory!
544+
mbedgt: available tests for built 'K64F-ARM', location '.\build\tests\K64F\ARM'
545545
test 'TESTS-functional-test1'
546546
test 'TESTS-functional-test2'
547547
test 'TESTS-functional-test3'
@@ -594,7 +594,7 @@ mbed-os-program
594594
| `- host_tests # Python host tests script directory
595595
| |- host_test1.py
596596
| `- host_test2.py
597-
`- .build # Build directory
597+
`- build # Build directory
598598
|- <TARGET> # Target directory
599599
| `- <TOOLCHAIN> # Toolchain directory
600600
| |- TestCase1.bin # Test binary

mbed/mbed.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"*.orig",
5454

5555
# mbed Tools
56+
"build",
5657
".build",
5758
".export",
5859

@@ -1118,6 +1119,7 @@ class Program(object):
11181119
is_cwd = False
11191120
is_repo = False
11201121
is_classic = False
1122+
build_dir = "build"
11211123

11221124
def __init__(self, path=None, print_warning=False):
11231125
path = os.path.abspath(path or os.getcwd())
@@ -1343,6 +1345,18 @@ def get_macros(self):
13431345
macros = f.read().splitlines()
13441346
return macros
13451347

1348+
def ignore_build_dir(self):
1349+
build_path = os.path.join(self.path, self.build_dir)
1350+
if not os.path.exists(build_path):
1351+
os.mkdir(build_path)
1352+
if not os.path.exists(os.path.join(build_path, '.mbedignore')):
1353+
try:
1354+
with open(os.path.join(build_path, '.mbedignore'), 'w') as f:
1355+
f.write('*\n')
1356+
except IOError:
1357+
error("Unable to write build ignore file in \"%s\"" % os.path.join(build_path, '.mbedignore'), 1)
1358+
1359+
13461360
# Global class used for global config
13471361
class Global(object):
13481362
def __init__(self):
@@ -2005,7 +2019,7 @@ def status_(ignore=False):
20052019
dict(name='--config', dest='compile_config', action='store_true', help='Show run-time compile configuration'),
20062020
dict(name='--prefix', dest='config_prefix', action='append', help='Restrict listing to parameters that have this prefix'),
20072021
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
2008-
dict(name='--build', help='Build directory. Default: .build/'),
2022+
dict(name='--build', help='Build directory. Default: build/'),
20092023
dict(name=['-c', '--clean'], action='store_true', help='Clean the build directory before compiling'),
20102024
dict(name=['-N', '--artifact-name'], help='Name of the built program or library'),
20112025
dict(name=['-S', '--supported'], dest='supported', action='store_true', help='Shows supported matrix of targets and toolchains'),
@@ -2017,6 +2031,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20172031
# Find the root of the program
20182032
program = Program(os.getcwd(), True)
20192033
program.check_requirements(True)
2034+
program.ignore_build_dir()
20202035
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
20212036
orig_path = os.getcwd()
20222037

@@ -2052,7 +2067,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20522067
elif compile_library:
20532068
# Compile as a library (current dir is default)
20542069
if not build:
2055-
build = os.path.join(os.path.relpath(program.path, orig_path), '.build', 'libraries', os.path.basename(orig_path), target, tchain)
2070+
build = os.path.join(os.path.relpath(program.path, orig_path), program.build_dir, 'libraries', os.path.basename(orig_path), target, tchain)
20562071

20572072
popen(['python', '-u', os.path.join(tools_dir, 'build.py')]
20582073
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
@@ -2068,7 +2083,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20682083
else:
20692084
# Compile as application (root is default)
20702085
if not build:
2071-
build = os.path.join(os.path.relpath(program.path, orig_path), '.build', target, tchain)
2086+
build = os.path.join(os.path.relpath(program.path, orig_path), program.build_dir, target, tchain)
20722087

20732088
popen(['python', '-u', os.path.join(tools_dir, 'make.py')]
20742089
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
@@ -2095,7 +2110,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20952110
dict(name='--run', dest='run_only', action='store_true', help='Only run tests'),
20962111
dict(name=['-n', '--tests-by-name'], dest='tests_by_name', help='Limit the tests to a list (ex. test1,test2,test3)'),
20972112
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
2098-
dict(name='--build', help='Build directory. Default: .build/'),
2113+
dict(name='--build', help='Build directory. Default: build/'),
20992114
dict(name=['-o', '--options'], action='append', help='Compile options. Examples: "debug-info": generate debugging information; "small-build" to use microlib/nanolib, but limit RTOS to single thread; "save-asm": save the asm generated by the compiler'),
21002115
dict(name=['-c', '--clean'], action='store_true', help='Clean the build directory before compiling'),
21012116
dict(name='--test-spec', dest="test_spec", help="Path used for the test spec file used when building and running tests (the default path is the build directory)"),
@@ -2107,6 +2122,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
21072122
# Find the root of the program
21082123
program = Program(os.getcwd(), True)
21092124
program.check_requirements(True)
2125+
program.ignore_build_dir()
21102126
# Save original working directory
21112127
orig_path = os.getcwd()
21122128

@@ -2126,7 +2142,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
21262142

21272143
# Setup the build path if not specified
21282144
if not build:
2129-
build = os.path.join(program.path, '.build/tests', target, tchain)
2145+
build = os.path.join(program.path, program.build_dir, 'tests', target, tchain)
21302146

21312147

21322148
if test_spec:
@@ -2193,6 +2209,7 @@ def export(ide=None, target=None, source=False, clean=False, supported=False):
21932209
# Find the root of the program
21942210
program = Program(os.getcwd(), True)
21952211
program.check_requirements(True)
2212+
program.ignore_build_dir()
21962213
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
21972214
orig_path = os.getcwd()
21982215
# Change directories to the program root to use mbed OS tools

0 commit comments

Comments
 (0)