function tc = armcc_tc % Creates MinGW ToolchainInfo object. % Copyright 2003-2019 (C) National Instruments Corp. tc = coder.make.ToolchainInfo('BuildArtifact', 'gmake makefile'); tc.Name = 'armcc | gmake makefile (64-bit Windows)'; tc.Platform = 'win64'; tc.SupportedVersion = '7.3'; tool_path = [getenv('ARM_GCC_PATH') '\bin']; tc.addAttribute('TransformPathsWithSpaces'); tc.addAttribute('RequiresCommandFile'); tc.addAttribute('RequiresBatchFile'); % ------------------------------ % Macros % ------------------------------ tc.addMacro('MW_EXTERNLIB_DIR', ['$(MATLAB_ROOT)\extern\lib\' tc.Platform '\microsoft']); tc.addMacro('MW_LIB_DIR', ['$(MATLAB_ROOT)\lib\' tc.Platform]); tc.addMacro('CFLAGS_ADDITIONAL', '-c -m32'); tc.addMacro('CPPFLAGS_ADDITIONAL', '-c -m32'); tc.addMacro('LIBS_TOOLCHAIN', '$(conlibs)'); tc.addMacro('LINKFLAGS_ADDITIONAL', '-m32 -shared'); tc.addMacro('CVARSFLAG', ''); tc.addMacro('CFLAG', '-std=c90 -pedantic -fwrapv -m32'); tc.addIntrinsicMacros({'ldebug', 'conflags', 'cflags'}); % ------------------------------ % C Compiler % ------------------------------ tool = tc.getBuildTool('C Compiler'); tool.setName( 'arm-none-eabi-gcc'); tool.setCommand( 'arm-none-eabi-gcc'); tool.setPath( tool_path); tool.setDirective( 'IncludeSearchPath', '-I'); tool.setDirective( 'PreprocessorDefine', '-D'); tool.setDirective( 'OutputFlag', '-o'); tool.setDirective( 'Debug', '-g'); tool.setFileExtension( 'Source', '.c'); tool.setFileExtension( 'Header', '.h'); tool.setFileExtension( 'Object', '.obj'); tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|'); % ------------------------------ % C++ Compiler % ------------------------------ tool = tc.getBuildTool('C++ Compiler'); tool.setName( 'arm-none-eabi-g++'); tool.setCommand( 'arm-none-eabi-g++'); tool.setPath( tool_path); tool.setDirective( 'IncludeSearchPath', '-I'); tool.setDirective( 'PreprocessorDefine', '-D'); tool.setDirective( 'OutputFlag', '-o'); tool.setDirective( 'Debug', '-g'); tool.setFileExtension( 'Source', '.cpp'); tool.setFileExtension( 'Header', '.hpp'); tool.setFileExtension( 'Object', '.obj'); tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|'); % ------------------------------ % Linker % ------------------------------ tool = tc.getBuildTool('Linker'); tool.setName( 'GCC Linker'); tool.setCommand( 'arm-none-eabi-g++'); tool.setPath( tool_path); tool.setDirective( 'Library', '-L'); tool.setDirective( 'LibrarySearchPath', '-I'); tool.setDirective( 'OutputFlag', '-o'); tool.setDirective( 'Debug', ''); tool.setFileExtension( 'Executable', '.dll'); tool.setFileExtension( 'Shared Library', '.dll'); tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|'); % ------------------------------ % C++ Linker % ------------------------------ tool = tc.getBuildTool('C++ Linker'); tool.setName( 'GCC Linker'); tool.setCommand( 'arm-none-eabi-g++'); tool.setPath( tool_path); tool.setDirective( 'Library', '-L'); tool.setDirective( 'LibrarySearchPath', '-I'); tool.setDirective( 'OutputFlag', '-o'); tool.setDirective( 'Debug', ''); tool.setFileExtension( 'Executable', '.dll'); tool.setFileExtension( 'Shared Library', '.dll'); tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|'); % ------------------------------ % Archiver % ------------------------------ tool = tc.getBuildTool('Archiver'); tool.setName( 'GNU Archiver'); tool.setCommand( 'arm-none-eabi-ar'); tool.setPath( tool_path); tool.setDirective( 'OutputFlag', ''); tool.setFileExtension( 'Static Library', '.a'); tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|'); % ------------------------------ % Builder % ------------------------------ tc.setBuilderApplication(tc.Platform); % -------------------------------------------- % BUILD CONFIGURATIONS % -------------------------------------------- optimsOffOpts = {'-O0'}; optimsOnOpts = {'-O2'}; cCompilerOpts = '$(cflags) $(CVARSFLAG) $(CFLAGS_ADDITIONAL)'; cppCompilerOpts = '$(cflags) $(CVARSFLAG) $(CPPFLAGS_ADDITIONAL)'; linkerOpts = {'$(ldebug) $(conflags) $(LINKFLAGS_ADDITIONAL) $(LIBS_TOOLCHAIN)'}; sharedLinkerOpts = horzcat(linkerOpts, '-shared -def:$(DEF_FILE)'); archiverOpts = {'rcs'}; % Get the debug flag per build tool debugFlag.CCompiler = '$(CDEBUG)'; debugFlag.CppCompiler = '$(CPPDEBUG)'; debugFlag.Linker = '$(LDDEBUG)'; debugFlag.CppLinker = '$(CPPLDDEBUG)'; debugFlag.Archiver = '$(ARDEBUG)'; % Set the toolchain flags for 'Faster Builds' build configuration cfg = tc.getBuildConfiguration('Faster Builds'); cfg.setOption( 'C Compiler', horzcat(cCompilerOpts, optimsOffOpts)); cfg.setOption( 'C++ Compiler', horzcat(cppCompilerOpts, optimsOffOpts)); cfg.setOption( 'Linker', linkerOpts); cfg.setOption( 'C++ Linker', linkerOpts); cfg.setOption( 'Shared Library Linker', sharedLinkerOpts); cfg.setOption( 'Archiver', archiverOpts); % Set the toolchain flags for 'Faster Runs' build configuration cfg = tc.getBuildConfiguration('Faster Runs'); cfg.setOption( 'C Compiler', horzcat(cCompilerOpts, optimsOnOpts)); cfg.setOption( 'C++ Compiler', horzcat(cppCompilerOpts, optimsOnOpts)); cfg.setOption( 'Linker', linkerOpts); cfg.setOption( 'C++ Linker', linkerOpts); cfg.setOption( 'Shared Library Linker', sharedLinkerOpts); cfg.setOption( 'Archiver', archiverOpts); % Set the toolchain flags for 'Debug' build configuration cfg = tc.getBuildConfiguration('Debug'); cfg.setOption( 'C Compiler', horzcat(cCompilerOpts, optimsOffOpts, debugFlag.CCompiler)); cfg.setOption( 'C++ Compiler', horzcat(cppCompilerOpts, optimsOffOpts, debugFlag.CppCompiler)); cfg.setOption( 'Linker', horzcat(linkerOpts, debugFlag.Linker)); cfg.setOption( 'C++ Linker', horzcat(linkerOpts, debugFlag.CppLinker)); cfg.setOption( 'Shared Library Linker', horzcat(sharedLinkerOpts, debugFlag.Linker)); cfg.setOption( 'Archiver', horzcat(archiverOpts, debugFlag.Archiver)); tc.setBuildConfigurationOption('all', 'Download', ''); tc.setBuildConfigurationOption('all', 'Execute', ''); tc.setBuildConfigurationOption('all', 'Make Tool', '-f $(MAKEFILE)');