Skip to content

Commit 014dbce

Browse files
authored
Merge pull request #13477 from jamesbeyond/dummy_cmake
CMake: add CI testing
2 parents 4746a9f + 8ce6c74 commit 014dbce

File tree

4 files changed

+198
-135
lines changed

4 files changed

+198
-135
lines changed

.travis.yml

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -110,110 +110,6 @@ matrix:
110110
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*' \
111111
':!*events/tests/*' ':!*drivers/tests/*'
112112
113-
- &cmake-build-test
114-
stage: "CMake"
115-
name: "CMake blinky example - develop (K64F)"
116-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=develop
117-
language: python
118-
python: 3.8
119-
install:
120-
# Install gcc
121-
- source_pkg gcc
122-
- arm-none-eabi-gcc --version
123-
- pip install --upgrade cmake
124-
- pip install --upgrade mbed-tools
125-
# We use manual clone, with depth and single branch = the fastest
126-
# Because of this, we need to create .mbed file as the current tools require it
127-
- git clone --depth=1 --single-branch --branch feature-cmake https://github.com/ARMmbed/${EXAMPLE_NAME}.git;
128-
- >-
129-
if [ -z ${SUBEXAMPLE_NAME} ]; then
130-
cd ${EXAMPLE_NAME};
131-
else
132-
cd ${EXAMPLE_NAME}/${SUBEXAMPLE_NAME};
133-
fi
134-
- >-
135-
git clone --depth=1 --single-branch https://github.com/ARMmbed/mbed-os.git;
136-
cd mbed-os;
137-
- to_fetch=("${TRAVIS_COMMIT}")
138-
- if [ false != "${TRAVIS_PULL_REQUEST-}" ]; then to_fetch+=("+refs/pull/${TRAVIS_PULL_REQUEST}/merge:"); fi
139-
- git fetch -q -- origin "${to_fetch[@]}"
140-
- git checkout -qf "${TRAVIS_COMMIT}" --
141-
- >-
142-
cd -;
143-
# Replace the content of mbed-os.lib to stay on ${TRAVIS_PULL_REQUEST}
144-
- echo “” > mbed-os.lib
145-
- mbedtools checkout;
146-
- mbedtools configure -t GCC_ARM -m ${TARGET_NAME};
147-
- mkdir -p build
148-
script:
149-
- cd build && cmake .. -GNinja -DCMAKE_BUILD_TYPE=${PROFILE} && cmake --build .
150-
151-
- <<: *cmake-build-test
152-
name: "CMake blinky example - release (K64F)"
153-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=release
154-
155-
- <<: *cmake-build-test
156-
name: "CMake blinky example - debug (K64F)"
157-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=debug
158-
159-
- <<: *cmake-build-test
160-
name: "CMake blinky example - develop (DISCO_L475VG_IOT01A)"
161-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=develop
162-
163-
- <<: *cmake-build-test
164-
name: "CMake blinky example - release (DISCO_L475VG_IOT01A)"
165-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=release
166-
167-
- <<: *cmake-build-test
168-
name: "CMake blinky example - debug (DISCO_L475VG_IOT01A)"
169-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=debug
170-
171-
- <<: *cmake-build-test
172-
name: "CMake blinky example - develop (NRF52840_DK)"
173-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=develop
174-
175-
- <<: *cmake-build-test
176-
name: "CMake blinky example - release (NRF52840_DK)"
177-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=release
178-
179-
- <<: *cmake-build-test
180-
name: "CMake blinky example - debug (NRF52840_DK)"
181-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=debug
182-
183-
- <<: *cmake-build-test
184-
name: "CMake kvstore example (K64F)"
185-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-kvstore TARGET_NAME=K64F
186-
187-
- <<: *cmake-build-test
188-
name: "CMake ble example (NRF52840_DK)"
189-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-ble TARGET_NAME=NRF52840_DK SUBEXAMPLE_NAME=BLE_LED
190-
191-
- <<: *cmake-build-test
192-
name: "CMake cellular example (WIO_3G)"
193-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-cellular TARGET_NAME=WIO_3G
194-
195-
- <<: *cmake-build-test
196-
name: "CMake devicekey example (K66F)"
197-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-devicekey TARGET_NAME=K66F
198-
199-
- <<: *cmake-build-test
200-
name: "CMake lorawan example (K66F)"
201-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-lorawan TARGET_NAME=K66F
202-
203-
- <<: *cmake-build-test
204-
name: "CMake crypto example (K64F)"
205-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-mbed-crypto TARGET_NAME=K64F SUBEXAMPLE_NAME=getting-started
206-
207-
- <<: *cmake-build-test
208-
name: "CMake nfc example (DISCO_L475VG_IOT01A)"
209-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-nfc TARGET_NAME=DISCO_L475VG_IOT01A SUBEXAMPLE_NAME=NFC_EEPROM
210-
211-
- <<: *cmake-build-test
212-
name: "CMake sockets example (K64F)"
213-
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-sockets TARGET_NAME=K64F
214-
215-
216-
217113
### Docs Tests ###
218114
- &docs-vm
219115
stage: "Docs"

tools/test/examples/examples.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ def parse_args():
8080
official_target_names, "MCU")),
8181
default=official_target_names)
8282

83-
compile_cmd.add_argument(
84-
"--profiles",
85-
nargs='+',
86-
metavar="profile",
87-
help="build profile(s)")
83+
compile_cmd.add_argument("--profiles",
84+
nargs='+',
85+
metavar="profile",
86+
help="build profile(s)")
8887

8988
compile_cmd.add_argument("-j", "--jobs",
9089
dest='jobs',
@@ -160,7 +159,7 @@ def do_deploy(_, config, examples):
160159

161160
def do_compile(args, config, examples):
162161
"""Do the compile step"""
163-
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.jobs)
162+
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.cmake, args.jobs)
164163
failures = lib.get_build_summary(results)
165164
return failures
166165

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"examples": [
3+
{
4+
"name": "mbed-os-example-blinky",
5+
"github": "https://github.com/ARMmbed/mbed-os-example-blinky",
6+
"sub-repo-example": false,
7+
"subs": [],
8+
"features" : [],
9+
"targets" : [],
10+
"toolchains" : [],
11+
"exporters": [],
12+
"compile" : true,
13+
"export": true,
14+
"test" : false,
15+
"baud_rate": 9600,
16+
"auto-update" : true
17+
},
18+
{
19+
"name": "mbed-os-example-sockets",
20+
"github":"https://github.com/ARMmbed/mbed-os-example-sockets",
21+
"sub-repo-example": false,
22+
"subs": [],
23+
"features" : [],
24+
"targets" : ["K64F", "K66F"],
25+
"toolchains" : [],
26+
"exporters": [],
27+
"compile" : true,
28+
"export": true,
29+
"test" : true,
30+
"baud_rate": 9600,
31+
"compare_log": ["mbed-os-example-sockets/tests/sockets.log"],
32+
"auto-update" : true
33+
},
34+
{
35+
"name": "mbed-os-example-cellular",
36+
"github":"https://github.com/ARMmbed/mbed-os-example-cellular",
37+
"sub-repo-example": false,
38+
"subs": [],
39+
"features" : [],
40+
"targets" : ["WIO_3G"],
41+
"toolchains" : [],
42+
"exporters": [],
43+
"compile" : true,
44+
"export": true,
45+
"test" : false,
46+
"auto-update" : true
47+
},
48+
{
49+
"name": "mbed-os-example-lorawan",
50+
"github":"https://github.com/ARMmbed/mbed-os-example-lorawan",
51+
"sub-repo-example": false,
52+
"subs": [],
53+
"features" : [],
54+
"targets" : ["K64F"],
55+
"toolchains" : [],
56+
"exporters": [],
57+
"compile" : true,
58+
"export": false,
59+
"test" : false,
60+
"auto-update" : true
61+
},
62+
{
63+
"name": "mbed-os-example-devicekey",
64+
"github":"https://github.com/ARMmbed/mbed-os-example-devicekey",
65+
"sub-repo-example": false,
66+
"subs": [],
67+
"features" : [],
68+
"targets" : ["K66F"],
69+
"toolchains" : [],
70+
"exporters": [],
71+
"compile" : true,
72+
"export": true,
73+
"test" : true,
74+
"baud_rate": 9600,
75+
"compare_log": ["mbed-os-example-devicekey/tests/devicekey.log"],
76+
"auto-update" : true
77+
},
78+
{
79+
"name": "mbed-os-example-mbed-crypto",
80+
"github":"https://github.com/ARMmbed/mbed-os-example-mbed-crypto",
81+
"sub-repo-example": true,
82+
"subs": ["getting-started"],
83+
"features" : [],
84+
"targets" : ["K64F"],
85+
"toolchains" : [],
86+
"exporters": [],
87+
"compile" : true,
88+
"export": true,
89+
"test" : true,
90+
"baud_rate": 9600,
91+
"compare_log": ["mbed-os-example-mbed-crypto/tests/getting-started.log"],
92+
"auto-update" : true
93+
},
94+
{
95+
"name": "mbed-os-example-nfc",
96+
"github": "https://github.com/ARMmbed/mbed-os-example-nfc",
97+
"sub-repo-example": true,
98+
"subs": [
99+
"NFC_EEPROM",
100+
"NFC_SmartPoster"
101+
],
102+
"features" : [],
103+
"targets" : ["NUCLEO_F401RE"],
104+
"toolchains" : [],
105+
"exporters": [],
106+
"compile" : true,
107+
"export": true,
108+
"test" : true,
109+
"baud_rate": 9600,
110+
"compare_log": [
111+
"mbed-os-example-nfc/tests/EEPROM.log",
112+
"mbed-os-example-nfc/tests/SmartPoster_noShield.log"
113+
],
114+
"auto-update" : true
115+
},
116+
{
117+
"name": "mbed-os-example-ble",
118+
"github":"https://github.com/ARMmbed/mbed-os-example-ble",
119+
"sub-repo-example": true,
120+
"subs": [
121+
"BLE_LED"
122+
123+
],
124+
"features" : [],
125+
"targets" : ["NRF52840_DK", "DISCO_L475VG_IOT01A"],
126+
"toolchains" : [],
127+
"exporters": [],
128+
"compile" : true,
129+
"export": true,
130+
"test" : false,
131+
"auto-update" : true
132+
},
133+
{
134+
"name": "mbed-os-example-kvstore",
135+
"github":"https://github.com/ARMmbed/mbed-os-example-kvstore",
136+
"sub-repo-example": false,
137+
"subs": [],
138+
"features" : [],
139+
"targets" : ["K64F", "DISCO_L475VG_IOT01A"],
140+
"toolchains" : [],
141+
"exporters": [],
142+
"compile" : true,
143+
"export": true,
144+
"test" : true,
145+
"baud_rate": 9600,
146+
"compare_log": ["mbed-os-example-kvstore/tests/kvstore.log"],
147+
"auto-update" : true
148+
}
149+
]
150+
}

tools/test/examples/examples_lib.py

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def export_repos(config, ides, targets, exp_filter):
329329
return results
330330

331331

332-
def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jobs=0):
332+
def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, cmake=False ,jobs=0):
333333
"""Compiles combinations of example programs, targets and compile chains.
334334
335335
The results are returned in a [key: value] dictionary format:
@@ -382,27 +382,36 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo
382382
summary_string = "%s %s %s" % (name, target, toolchain)
383383
logging.info("Compiling %s" % summary_string)
384384

385-
build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target, "-j", str(jobs)] + (['-vv'] if verbose else [])
386-
if profiles:
387-
for profile in profiles:
388-
build_command.extend(["--profile", profile])
389-
390-
logging.info("Executing command '%s'..." % " ".join(build_command))
391-
proc = subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
392-
393-
std_out, std_err = proc.communicate()
394-
std_out = std_out.decode()
395-
std_err = std_err.decode()
396-
print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err))
397-
398-
if proc.returncode:
399-
failures.append(example_summary)
385+
if cmake:
386+
build_command_seq = ["mbed-tools build -t {} -m {} -c".format(toolchain, target)]
400387
else:
388+
build_command_seq = ["mbed-cli compile -t {} -m {} -j {} {}".format(toolchain, target, str(jobs), '-vv' if verbose else '') ]
389+
if profiles:
390+
for profile in profiles:
391+
build_command_seq[0] += " --profile {}".format(profile)
392+
393+
failed_flag = False
394+
for build_command in build_command_seq:
395+
logging.info("Executing command '%s'..." % build_command)
396+
proc = subprocess.Popen(build_command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
397+
398+
std_out, std_err = proc.communicate()
399+
std_out = std_out.decode()
400+
std_err = std_err.decode()
401+
print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err))
402+
403+
if proc.returncode:
404+
failures.append(example_summary)
405+
failed_flag = True
406+
break
407+
408+
409+
if not failed_flag:
401410
if example['test']:
402411
log = example['compare_log'].pop(0)
403412
# example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
404413
# pop the log file out of list regardless the compilation for each example pass of fail
405-
image = fetch_output_image(std_out)
414+
image = fetch_output_image(std_out,cmake)
406415
if image:
407416
image_info = [{"binary_type": "bootable","path": normpath(join(name,image)),"compare_log":log}]
408417
test_group = "{}-{}-{}".format(target, toolchain, example['baud_rate'])
@@ -450,9 +459,8 @@ def update_example_version(config, tag, exp_filter):
450459
"""
451460
print("\nUpdating example to version(branch) '%s'\n" % tag)
452461
for example in config['examples']:
453-
if example['name'] not in exp_filter:
454-
continue
455-
for name in get_sub_examples_list(example):
462+
name = example['name']
463+
if name in exp_filter:
456464
os.chdir(name)
457465
logging.info("In folder '%s'" % name)
458466
cmd = "git checkout -B %s origin/%s" %(tag, tag)
@@ -484,17 +492,27 @@ def symlink_mbedos(config, path, exp_filter):
484492
else:
485493
logging.info("Creating Symbolic link '%s'->'mbed-os'" % path)
486494
os.symlink(path, "mbed-os")
495+
#Cmake tool currently require 'mbed-os.lib' to be present to perform build.
496+
#Add a empty 'mbed-os.lib' as a workaround
497+
open('mbed-os.lib', 'a').close()
487498
os.chdir(CWD)
488499
return 0
489500

490-
def fetch_output_image(output):
501+
def fetch_output_image(output,cmake):
491502
"""Find the build image from the last 30 lines of a given log"""
492503
lines = output.splitlines()
493504
last_index = -31 if len(lines)>29 else (-1 - len(lines))
494505
for index in range(-1,last_index,-1):
495-
if lines[index].startswith("Image:"):
496-
image = lines[index][7:]
497-
if os.path.isfile(image):
498-
return image
506+
if cmake:
507+
if lines[index].startswith("-- built:") and lines[index].endswith(".bin"):
508+
image = lines[index][10:]
509+
print("IMAGE is " + image)
510+
if os.path.isfile(image):
511+
return os.path.relpath(image)
512+
else:
513+
if lines[index].startswith("Image:"):
514+
image = lines[index][7:]
515+
if os.path.isfile(image):
516+
return image
499517
return False
500518

0 commit comments

Comments
 (0)