Skip to content

Commit 7611f84

Browse files
authored
Merge pull request #348 from screamerbg/change_build_dir
Change the default build dir to 'build'
2 parents 930cdcc + 881d496 commit 7611f84

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

README.md

+10-10
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'
@@ -603,7 +603,7 @@ mbed-os-program
603603
| `- host_tests # Python host tests script directory
604604
| |- host_test1.py
605605
| `- host_test2.py
606-
`- .build # Build directory
606+
`- build # Build directory
607607
|- <TARGET> # Target directory
608608
| `- <TOOLCHAIN> # Toolchain directory
609609
| |- TestCase1.bin # Test binary

mbed/mbed.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
# Application version
38-
ver = '0.9.5'
38+
ver = '0.9.7'
3939

4040
# Default paths to Mercurial and Git
4141
hg_cmd = 'hg'
@@ -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'),
@@ -2018,6 +2032,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20182032
# Find the root of the program
20192033
program = Program(os.getcwd(), True)
20202034
program.check_requirements(True)
2035+
program.ignore_build_dir()
20212036
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
20222037
orig_path = os.getcwd()
20232038

@@ -2054,7 +2069,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20542069
elif compile_library:
20552070
# Compile as a library (current dir is default)
20562071
if not build:
2057-
build = os.path.join(os.path.relpath(program.path, orig_path), '.build', 'libraries', os.path.basename(orig_path), target, tchain)
2072+
build = os.path.join(os.path.relpath(program.path, orig_path), program.build_dir, 'libraries', os.path.basename(orig_path), target, tchain)
20582073

20592074
popen(['python', '-u', os.path.join(tools_dir, 'build.py')]
20602075
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
@@ -2070,7 +2085,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20702085
else:
20712086
# Compile as application (root is default)
20722087
if not build:
2073-
build = os.path.join(os.path.relpath(program.path, orig_path), '.build', target, tchain)
2088+
build = os.path.join(os.path.relpath(program.path, orig_path), program.build_dir, target, tchain)
20742089

20752090
popen(['python', '-u', os.path.join(tools_dir, 'make.py')]
20762091
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
@@ -2098,7 +2113,7 @@ def compile_(toolchain=None, target=None, options=False, compile_library=False,
20982113
dict(name='--run', dest='run_only', action='store_true', help='Only run tests'),
20992114
dict(name=['-n', '--tests-by-name'], dest='tests_by_name', help='Limit the tests to a list (ex. test1,test2,test3)'),
21002115
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
2101-
dict(name='--build', help='Build directory. Default: .build/'),
2116+
dict(name='--build', help='Build directory. Default: build/'),
21022117
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'),
21032118
dict(name=['-c', '--clean'], action='store_true', help='Clean the build directory before compiling'),
21042119
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)"),
@@ -2111,6 +2126,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
21112126
# Find the root of the program
21122127
program = Program(os.getcwd(), True)
21132128
program.check_requirements(True)
2129+
program.ignore_build_dir()
21142130
# Save original working directory
21152131
orig_path = os.getcwd()
21162132

@@ -2130,7 +2146,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
21302146

21312147
# Setup the build path if not specified
21322148
if not build:
2133-
build = os.path.join(program.path, '.build/tests', target, tchain)
2149+
build = os.path.join(program.path, program.build_dir, 'tests', target, tchain)
21342150

21352151

21362152
if test_spec:
@@ -2201,6 +2217,7 @@ def export(ide=None, target=None, source=False, clean=False, supported=False):
22012217
# Find the root of the program
22022218
program = Program(os.getcwd(), True)
22032219
program.check_requirements(True)
2220+
program.ignore_build_dir()
22042221
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
22052222
orig_path = os.getcwd()
22062223
# Change directories to the program root to use mbed OS tools

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
setup(
2020
name="mbed-cli",
21-
version="0.9.5",
21+
version="0.9.7",
2222
description="ARM mbed command line tool for repositories version control, publishing and updating code from remotely hosted repositories (GitHub, GitLab and mbed.org), and invoking mbed OS own build system and export functions, among other operations",
2323
long_description=LONG_DESC,
2424
url='http://github.com/ARMmbed/mbed-cli',

0 commit comments

Comments
 (0)