2013-08-06 13:38:00 +00:00
|
|
|
"""
|
|
|
|
mbed SDK
|
|
|
|
Copyright (c) 2011-2013 ARM Limited
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
"""
|
2013-02-18 15:32:11 +00:00
|
|
|
import sys
|
|
|
|
from os.path import join, abspath, dirname, exists
|
|
|
|
ROOT = abspath(join(dirname(__file__), ".."))
|
2013-12-19 13:02:57 +00:00
|
|
|
sys.path.insert(0, ROOT)
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2013-08-16 15:39:30 +00:00
|
|
|
from shutil import move
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2013-08-16 15:39:30 +00:00
|
|
|
from workspace_tools.paths import *
|
|
|
|
from workspace_tools.utils import mkdir, cmd
|
|
|
|
from workspace_tools.export import export, setup_user_prj
|
2013-05-13 15:13:25 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2013-07-23 16:22:57 +00:00
|
|
|
USR_PRJ_NAME = "usr_prj"
|
2013-08-16 15:39:30 +00:00
|
|
|
USER_PRJ = join(EXPORT_WORKSPACE, USR_PRJ_NAME)
|
2013-02-18 15:32:11 +00:00
|
|
|
USER_SRC = join(USER_PRJ, "src")
|
2013-07-23 16:22:57 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
def setup_test_user_prj():
|
|
|
|
if exists(USER_PRJ):
|
|
|
|
print 'Test user project already generated...'
|
|
|
|
return
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-08-16 15:39:30 +00:00
|
|
|
setup_user_prj(USER_PRJ, join(TEST_DIR, "rtos", "mbed", "basic"), [join(LIB_DIR, "rtos")])
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
# FAKE BUILD URL
|
|
|
|
open(join(USER_SRC, "mbed.bld"), 'w').write("http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5\n")
|
|
|
|
|
|
|
|
|
|
|
|
def fake_build_url_resolver(url):
|
|
|
|
# FAKE BUILD URL: Ignore the URL, always return the path to the mbed library
|
|
|
|
return {'path':MBED_LIBRARIES, 'name':'mbed'}
|
|
|
|
|
|
|
|
|
|
|
|
def test_export(toolchain, target, expected_error=None):
|
|
|
|
if toolchain is None and target is None:
|
2013-08-16 15:39:30 +00:00
|
|
|
base_dir = join(EXPORT_TMP, "zip")
|
2013-02-18 15:32:11 +00:00
|
|
|
else:
|
2013-08-16 15:39:30 +00:00
|
|
|
base_dir = join(EXPORT_TMP, toolchain, target)
|
2013-02-18 15:32:11 +00:00
|
|
|
temp_dir = join(base_dir, "temp")
|
|
|
|
mkdir(temp_dir)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, fake_build_url_resolver)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
if report['success']:
|
2013-08-16 15:39:30 +00:00
|
|
|
move(zip_path, join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target)))
|
2013-02-18 15:32:11 +00:00
|
|
|
print "[OK]"
|
|
|
|
else:
|
|
|
|
if expected_error is None:
|
|
|
|
print '[ERRROR] %s' % report['errormsg']
|
|
|
|
else:
|
|
|
|
if (zip_path is None) and (expected_error in report['errormsg']):
|
|
|
|
print '[OK]'
|
|
|
|
else:
|
|
|
|
print '[ERROR]'
|
|
|
|
print ' zip:', zip_path
|
|
|
|
print ' msg:', report['errormsg']
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
setup_test_user_prj()
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
for toolchain, target in [
|
2013-09-09 12:10:11 +00:00
|
|
|
('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'), ('uvision', 'LPC1114'), ('uvision', 'LPC4088'),
|
2014-05-05 09:22:02 +00:00
|
|
|
|
2014-05-21 13:00:59 +00:00
|
|
|
('uvision', 'NUCLEO_F030R8'),
|
|
|
|
('uvision', 'NUCLEO_F072RB'),
|
2014-05-05 09:22:02 +00:00
|
|
|
('uvision', 'NUCLEO_F103RB'),
|
|
|
|
('uvision', 'NUCLEO_F302R8'),
|
|
|
|
('uvision', 'NUCLEO_F401RE'),
|
|
|
|
('uvision', 'NUCLEO_L053R8'),
|
|
|
|
('uvision', 'NUCLEO_L152RE'),
|
2014-05-21 13:00:59 +00:00
|
|
|
|
2014-04-01 15:23:19 +00:00
|
|
|
('lpcxpresso', 'LPC1768'), ('lpcxpresso', 'LPC4088'),('lpcxpresso', 'LPC1114'),
|
|
|
|
('lpcxpresso', 'LPC11U35_401'),
|
|
|
|
('lpcxpresso', 'LPC11U35_501'),
|
2014-06-15 00:12:42 +00:00
|
|
|
('lpcxpresso', 'LPC1549'),
|
|
|
|
('lpcxpresso', 'LPC11U68'),
|
2013-02-18 15:32:11 +00:00
|
|
|
# Linux path: /home/emimon01/bin/gcc-cs/bin/
|
|
|
|
# Windows path: "C:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/"
|
|
|
|
('codesourcery', 'LPC1768'),
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
# Linux path: /home/emimon01/bin/gcc-arm/bin/
|
|
|
|
# Windows path: C:/arm-none-eabi-gcc-4_7/bin/
|
|
|
|
('gcc_arm', 'LPC1768'),
|
2014-03-08 08:15:42 +00:00
|
|
|
('gcc_arm', 'LPC1114'),
|
2014-03-17 14:45:39 +00:00
|
|
|
('gcc_arm', 'LPC11U35_401'),
|
|
|
|
('gcc_arm', 'LPC11U35_501'),
|
2014-06-13 11:09:48 +00:00
|
|
|
('gcc_arm', 'LPC2368'),
|
2014-03-17 14:45:39 +00:00
|
|
|
|
2014-03-18 11:32:53 +00:00
|
|
|
('gcc_arm', 'STM32F407'),
|
2014-03-19 12:15:59 +00:00
|
|
|
('gcc_arm', 'DISCO_F100RB'),
|
2014-03-21 11:23:13 +00:00
|
|
|
('gcc_arm', 'DISCO_F051R8'),
|
2014-03-24 14:56:58 +00:00
|
|
|
('gcc_arm', 'DISCO_F407VG'),
|
2014-04-08 13:30:24 +00:00
|
|
|
('gcc_arm', 'DISCO_F303VC'),
|
2014-05-31 22:01:40 +00:00
|
|
|
('gcc_arm', 'NRF51822'),
|
2014-03-18 11:32:53 +00:00
|
|
|
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
('ds5_5', 'LPC1768'), ('ds5_5', 'LPC11U24'),
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
('iar', 'LPC1768'),
|
2014-03-18 11:32:53 +00:00
|
|
|
|
2014-05-31 20:29:50 +00:00
|
|
|
(None, None),
|
2013-02-18 15:32:11 +00:00
|
|
|
]:
|
|
|
|
print '\n=== Exporting to "%s::%s" ===' % (toolchain, target)
|
|
|
|
test_export(toolchain, target)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
print "\n=== Test error messages ==="
|
2014-04-01 15:23:19 +00:00
|
|
|
test_export('lpcxpresso', 'LPC11U24', expected_error='lpcxpresso')
|