Exemple #1
0
    def test_gcc_minimal_printf(self):
        """Test that linker flags are correctly added to an instance of GCC_ARM."""
        mock_target = mock.MagicMock()
        mock_target.core = "Cortex-M4"
        mock_target.printf_lib = "minimal-printf"
        mock_target.supported_toolchains = ["GCC_ARM"]
        mock_target.c_lib = "std"
        del mock_target.default_lib
        mock_target.supported_c_libs = {"gcc_arm": ["std"]}
        mock_target.is_TrustZone_secure_target = False

        gcc_obj = GCC_ARM(mock_target)

        self.assertIn("-DMBED_MINIMAL_PRINTF", gcc_obj.flags["common"])

        minimal_printf_wraps = [
            "-Wl,--wrap,printf",
            "-Wl,--wrap,sprintf",
            "-Wl,--wrap,snprintf",
            "-Wl,--wrap,vprintf",
            "-Wl,--wrap,vsprintf",
            "-Wl,--wrap,vsnprintf",
            "-Wl,--wrap,fprintf",
            "-Wl,--wrap,vfprintf",
        ]

        for i in minimal_printf_wraps:
            self.assertIn(i, gcc_obj.flags["ld"])
Exemple #2
0
 def test_gcc_arm_c_lib_std_exception(self):
     """Test that an exception is raised if the std C library is not supported for a target on the GCC_ARM toolchain."""
     mock_target = mock.MagicMock()
     mock_target.core = "Cortex-M4"
     mock_target.default_toolchain = "ARM"
     mock_target.c_lib = "std"
     del mock_target.default_lib
     mock_target.supported_c_libs = {"arm": ["small"]}
     with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib)):
         GCC_ARM(mock_target)
 def test_gcc_arm_default_lib(self):
     """Test that linker flags are correctly added to an instance of GCC_ARM."""
     mock_target = mock.MagicMock()
     mock_target.core = "Cortex-M4"
     mock_target.supported_c_libs = {"gcc_arm": ["small"]}
     mock_target.default_lib = "sMALL"
     mock_target.supported_toolchains = ["GCC_ARM"]
     mock_target.is_TrustZone_secure_target = False
     gcc_arm_obj = GCC_ARM(mock_target)
     self.assertIn("-DMBED_RTOS_SINGLE_THREAD", gcc_arm_obj.flags["common"])
     self.assertIn("-D__NEWLIB_NANO", gcc_arm_obj.flags["common"])
     self.assertIn("--specs=nano.specs", gcc_arm_obj.flags["ld"])
Exemple #4
0
 def test_gcc_arm_small_c_lib_swap_std_lib(self):
     """Test that no exception is raised when small c lib is not supported but std lib is supported."""
     mock_target = mock.MagicMock()
     mock_target.core = "Cortex-M4"
     mock_target.supported_c_libs = {"gcc_arm": ["std"]}
     mock_target.c_lib = "small"
     del mock_target.default_lib
     mock_target.supported_toolchains = ["GCC_ARM"]
     mock_target.is_TrustZone_secure_target = False
     mock_target.default_toolchain = "GCC_ARM"
     try:
         GCC_ARM(mock_target)
     except NotSupportedException:
         self.fail(
             UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib))
Exemple #5
0
from os import walk
from os.path import join, abspath, dirname, basename, splitext
import sys

ROOT = abspath(join(dirname(__file__), "..", ".."))
sys.path.insert(0, ROOT)

from tools.toolchains.gcc import GCC_ARM
from tools.targets import TARGET_MAP
from argparse import ArgumentParser

if __name__ == "__main__":
    parser = ArgumentParser(
        "Find duplicate file names within a directory structure")
    parser.add_argument("dirs",
                        help="Directories to search for duplicate file names",
                        nargs="*")
    parser.add_argument(
        "--silent",
        help="Supress printing of filenames, just return number of duplicates",
        action="store_true")
    args = parser.parse_args()

    toolchain = GCC_ARM(TARGET_MAP["K64F"])

    resources = sum([toolchain.scan_resources(d) for d in args.dirs], None)

    scanned_files = {}

    exit(resources.detect_duplicates(toolchain))
Exemple #6
0
        proc.wait()


EXCLUDES = [
    "targets", "features/FEATURE", "features/mbedtls", "features/nanostack",
    "features/storage"
]


def is_not_excluded(src):
    return all(exclude not in src for exclude in EXCLUDES)


if __name__ == "__main__":
    import sys
    from os.path import abspath, dirname, join
    # Be sure that the tools directory is in the search path
    ROOT = abspath(join(dirname(__file__), "..", ".."))
    sys.path.insert(0, ROOT)

    from tools.toolchains.gcc import GCC_ARM
    from tools.targets import TARGET_MAP
    toolchain = GCC_ARM(TARGET_MAP["Super_Target"])
    resources = toolchain.scan_resources(".")
    generate_documentation(
        filter(
            is_not_excluded,
            sum(map(lambda x: x.headers, resources.features.values()),
                resources.headers)),
        join(dirname(dirname(__file__)), "mbed-docs"))