Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,110 +110,6 @@ matrix:
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*' \
':!*events/tests/*' ':!*drivers/tests/*'

- &cmake-build-test
stage: "CMake"
name: "CMake blinky example - develop (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=develop
language: python
python: 3.8
install:
# Install gcc
- source_pkg gcc
- arm-none-eabi-gcc --version
- pip install --upgrade cmake
- pip install --upgrade mbed-tools
# We use manual clone, with depth and single branch = the fastest
# Because of this, we need to create .mbed file as the current tools require it
- git clone --depth=1 --single-branch --branch feature-cmake https://github.com/ARMmbed/${EXAMPLE_NAME}.git;
- >-
if [ -z ${SUBEXAMPLE_NAME} ]; then
cd ${EXAMPLE_NAME};
else
cd ${EXAMPLE_NAME}/${SUBEXAMPLE_NAME};
fi
- >-
git clone --depth=1 --single-branch https://github.com/ARMmbed/mbed-os.git;
cd mbed-os;
- to_fetch=("${TRAVIS_COMMIT}")
- if [ false != "${TRAVIS_PULL_REQUEST-}" ]; then to_fetch+=("+refs/pull/${TRAVIS_PULL_REQUEST}/merge:"); fi
- git fetch -q -- origin "${to_fetch[@]}"
- git checkout -qf "${TRAVIS_COMMIT}" --
- >-
cd -;
# Replace the content of mbed-os.lib to stay on ${TRAVIS_PULL_REQUEST}
- echo “” > mbed-os.lib
- mbedtools checkout;
- mbedtools configure -t GCC_ARM -m ${TARGET_NAME};
- mkdir -p build
script:
- cd build && cmake .. -GNinja -DCMAKE_BUILD_TYPE=${PROFILE} && cmake --build .

- <<: *cmake-build-test
name: "CMake blinky example - release (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=release

- <<: *cmake-build-test
name: "CMake blinky example - debug (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=K64F PROFILE=debug

- <<: *cmake-build-test
name: "CMake blinky example - develop (DISCO_L475VG_IOT01A)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=develop

- <<: *cmake-build-test
name: "CMake blinky example - release (DISCO_L475VG_IOT01A)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=release

- <<: *cmake-build-test
name: "CMake blinky example - debug (DISCO_L475VG_IOT01A)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=debug

- <<: *cmake-build-test
name: "CMake blinky example - develop (NRF52840_DK)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=develop

- <<: *cmake-build-test
name: "CMake blinky example - release (NRF52840_DK)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=release

- <<: *cmake-build-test
name: "CMake blinky example - debug (NRF52840_DK)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-blinky TARGET_NAME=NRF52840_DK PROFILE=debug

- <<: *cmake-build-test
name: "CMake kvstore example (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-kvstore TARGET_NAME=K64F

- <<: *cmake-build-test
name: "CMake ble example (NRF52840_DK)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-ble TARGET_NAME=NRF52840_DK SUBEXAMPLE_NAME=BLE_LED

- <<: *cmake-build-test
name: "CMake cellular example (WIO_3G)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-cellular TARGET_NAME=WIO_3G

- <<: *cmake-build-test
name: "CMake devicekey example (K66F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-devicekey TARGET_NAME=K66F

- <<: *cmake-build-test
name: "CMake lorawan example (K66F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-lorawan TARGET_NAME=K66F

- <<: *cmake-build-test
name: "CMake crypto example (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-mbed-crypto TARGET_NAME=K64F SUBEXAMPLE_NAME=getting-started

- <<: *cmake-build-test
name: "CMake nfc example (DISCO_L475VG_IOT01A)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-nfc TARGET_NAME=DISCO_L475VG_IOT01A SUBEXAMPLE_NAME=NFC_EEPROM

- <<: *cmake-build-test
name: "CMake sockets example (K64F)"
env: NAME=cmake_test EXAMPLE_NAME=mbed-os-example-sockets TARGET_NAME=K64F



### Docs Tests ###
- &docs-vm
stage: "Docs"
Expand Down
11 changes: 5 additions & 6 deletions tools/test/examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ def parse_args():
official_target_names, "MCU")),
default=official_target_names)

compile_cmd.add_argument(
"--profiles",
nargs='+',
metavar="profile",
help="build profile(s)")
compile_cmd.add_argument("--profiles",
nargs='+',
metavar="profile",
help="build profile(s)")

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

def do_compile(args, config, examples):
"""Do the compile step"""
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.jobs)
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.cmake, args.jobs)
failures = lib.get_build_summary(results)
return failures

Expand Down
150 changes: 150 additions & 0 deletions tools/test/examples/examples_cmake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"examples": [
{
"name": "mbed-os-example-blinky",
"github": "https://github.com/ARMmbed/mbed-os-example-blinky",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : [],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : false,
"baud_rate": 9600,
"auto-update" : true
},
{
"name": "mbed-os-example-sockets",
"github":"https://github.com/ARMmbed/mbed-os-example-sockets",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : ["K64F", "K66F"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : true,
"baud_rate": 9600,
"compare_log": ["mbed-os-example-sockets/tests/sockets.log"],
"auto-update" : true
},
{
"name": "mbed-os-example-cellular",
"github":"https://github.com/ARMmbed/mbed-os-example-cellular",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : ["WIO_3G"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : false,
"auto-update" : true
},
{
"name": "mbed-os-example-lorawan",
"github":"https://github.com/ARMmbed/mbed-os-example-lorawan",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : ["K64F"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": false,
"test" : false,
"auto-update" : true
},
{
"name": "mbed-os-example-devicekey",
"github":"https://github.com/ARMmbed/mbed-os-example-devicekey",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : ["K66F"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : true,
"baud_rate": 9600,
"compare_log": ["mbed-os-example-devicekey/tests/devicekey.log"],
"auto-update" : true
},
{
"name": "mbed-os-example-mbed-crypto",
"github":"https://github.com/ARMmbed/mbed-os-example-mbed-crypto",
"sub-repo-example": true,
"subs": ["getting-started"],
"features" : [],
"targets" : ["K64F"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : true,
"baud_rate": 9600,
"compare_log": ["mbed-os-example-mbed-crypto/tests/getting-started.log"],
"auto-update" : true
},
{
"name": "mbed-os-example-nfc",
"github": "https://github.com/ARMmbed/mbed-os-example-nfc",
"sub-repo-example": true,
"subs": [
"NFC_EEPROM",
"NFC_SmartPoster"
],
"features" : [],
"targets" : ["NUCLEO_F401RE"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : true,
"baud_rate": 9600,
"compare_log": [
"mbed-os-example-nfc/tests/EEPROM.log",
"mbed-os-example-nfc/tests/SmartPoster_noShield.log"
],
"auto-update" : true
},
{
"name": "mbed-os-example-ble",
"github":"https://github.com/ARMmbed/mbed-os-example-ble",
"sub-repo-example": true,
"subs": [
"BLE_LED"

],
"features" : [],
"targets" : ["NRF52840_DK", "DISCO_L475VG_IOT01A"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : false,
"auto-update" : true
},
{
"name": "mbed-os-example-kvstore",
"github":"https://github.com/ARMmbed/mbed-os-example-kvstore",
"sub-repo-example": false,
"subs": [],
"features" : [],
"targets" : ["K64F", "DISCO_L475VG_IOT01A"],
"toolchains" : [],
"exporters": [],
"compile" : true,
"export": true,
"test" : true,
"baud_rate": 9600,
"compare_log": ["mbed-os-example-kvstore/tests/kvstore.log"],
"auto-update" : true
}
]
}
68 changes: 43 additions & 25 deletions tools/test/examples/examples_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def export_repos(config, ides, targets, exp_filter):
return results


def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jobs=0):
def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, cmake=False ,jobs=0):
"""Compiles combinations of example programs, targets and compile chains.

The results are returned in a [key: value] dictionary format:
Expand Down Expand Up @@ -382,27 +382,36 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo
summary_string = "%s %s %s" % (name, target, toolchain)
logging.info("Compiling %s" % summary_string)

build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target, "-j", str(jobs)] + (['-vv'] if verbose else [])
if profiles:
for profile in profiles:
build_command.extend(["--profile", profile])

logging.info("Executing command '%s'..." % " ".join(build_command))
proc = subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

std_out, std_err = proc.communicate()
std_out = std_out.decode()
std_err = std_err.decode()
print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err))

if proc.returncode:
failures.append(example_summary)
if cmake:
build_command_seq = ["mbed-tools build -t {} -m {} -c".format(toolchain, target)]
else:
build_command_seq = ["mbed-cli compile -t {} -m {} -j {} {}".format(toolchain, target, str(jobs), '-vv' if verbose else '') ]
if profiles:
for profile in profiles:
build_command_seq[0] += " --profile {}".format(profile)
Comment on lines +389 to +391
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also test all build profiles with mbed-tools.
You can use the --build-type optional argument of the build sub-command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers, good to know that.
But I as mentioned in Jaeden's comment, we are not going to introduce build multiple profile at this PR, as this will evolve more CI side code changes. We'll do that as an improvement in near future. In this PR we are only build the default profile which is development for now


failed_flag = False
for build_command in build_command_seq:
logging.info("Executing command '%s'..." % build_command)
proc = subprocess.Popen(build_command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)

std_out, std_err = proc.communicate()
std_out = std_out.decode()
std_err = std_err.decode()
print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err))

if proc.returncode:
failures.append(example_summary)
failed_flag = True
break


if not failed_flag:
if example['test']:
log = example['compare_log'].pop(0)
# example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
# pop the log file out of list regardless the compilation for each example pass of fail
image = fetch_output_image(std_out)
image = fetch_output_image(std_out,cmake)
if image:
image_info = [{"binary_type": "bootable","path": normpath(join(name,image)),"compare_log":log}]
test_group = "{}-{}-{}".format(target, toolchain, example['baud_rate'])
Expand Down Expand Up @@ -450,9 +459,8 @@ def update_example_version(config, tag, exp_filter):
"""
print("\nUpdating example to version(branch) '%s'\n" % tag)
for example in config['examples']:
if example['name'] not in exp_filter:
continue
for name in get_sub_examples_list(example):
name = example['name']
if name in exp_filter:
os.chdir(name)
logging.info("In folder '%s'" % name)
cmd = "git checkout -B %s origin/%s" %(tag, tag)
Expand Down Expand Up @@ -484,17 +492,27 @@ def symlink_mbedos(config, path, exp_filter):
else:
logging.info("Creating Symbolic link '%s'->'mbed-os'" % path)
os.symlink(path, "mbed-os")
#Cmake tool currently require 'mbed-os.lib' to be present to perform build.
#Add a empty 'mbed-os.lib' as a workaround
open('mbed-os.lib', 'a').close()
os.chdir(CWD)
return 0

def fetch_output_image(output):
def fetch_output_image(output,cmake):
"""Find the build image from the last 30 lines of a given log"""
lines = output.splitlines()
last_index = -31 if len(lines)>29 else (-1 - len(lines))
for index in range(-1,last_index,-1):
if lines[index].startswith("Image:"):
image = lines[index][7:]
if os.path.isfile(image):
return image
if cmake:
if lines[index].startswith("-- built:") and lines[index].endswith(".bin"):
image = lines[index][10:]
print("IMAGE is " + image)
if os.path.isfile(image):
return os.path.relpath(image)
else:
if lines[index].startswith("Image:"):
image = lines[index][7:]
if os.path.isfile(image):
return image
return False