1/**************************************************************************** 2** 3** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> 4** Contact: http://www.qt.io/licensing 5** 6** This file is part of Qbs. 7** 8** Commercial License Usage 9** Licensees holding valid commercial Qt licenses may use this file in 10** accordance with the commercial license agreement provided with the 11** Software or, alternatively, in accordance with the terms contained in 12** a written agreement between you and The Qt Company. For licensing terms and 13** conditions see http://www.qt.io/terms-conditions. For further information 14** use the contact form at http://www.qt.io/contact-us. 15** 16** GNU Lesser General Public License Usage 17** Alternatively, this file may be used under the terms of the GNU Lesser 18** General Public License version 2.1 or version 3 as published by the Free 19** Software Foundation and appearing in the file LICENSE.LGPLv21 and 20** LICENSE.LGPLv3 included in the packaging of this file. Please review the 21** following information to ensure the GNU Lesser General Public License 22** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 23** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24** 25** In addition, as a special exception, The Qt Company gives you certain additional 26** rights. These rights are described in The Qt Company LGPL Exception 27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28** 29****************************************************************************/ 30 31import qbs.File 32import qbs.FileInfo 33import qbs.Probes 34import "cpp.js" as Cpp 35import "keil.js" as KEIL 36 37CppModule { 38 condition: qbs.hostOS.contains("windows") && qbs.toolchain && qbs.toolchain.contains("keil") 39 40 Probes.BinaryProbe { 41 id: compilerPathProbe 42 condition: !toolchainInstallPath && !_skipAllChecks 43 names: ["c51"] 44 } 45 46 Probes.KeilProbe { 47 id: keilProbe 48 condition: !_skipAllChecks 49 compilerFilePath: compilerPath 50 enableDefinesByLanguage: enableCompilerDefinesByLanguage 51 } 52 53 qbs.architecture: keilProbe.found ? keilProbe.architecture : original 54 qbs.targetPlatform: "none" 55 56 compilerVersionMajor: keilProbe.versionMajor 57 compilerVersionMinor: keilProbe.versionMinor 58 compilerVersionPatch: keilProbe.versionPatch 59 endianness: keilProbe.endianness 60 61 compilerDefinesByLanguage: keilProbe.compilerDefinesByLanguage 62 compilerIncludePaths: keilProbe.includePaths 63 64 toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined 65 66 /* Work-around for QtCreator which expects these properties to exist. */ 67 property string cCompilerName: compilerName 68 property string cxxCompilerName: compilerName 69 70 compilerName: toolchainDetails.compilerName + compilerExtension 71 compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) 72 73 assemblerName: toolchainDetails.assemblerName + compilerExtension 74 assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) 75 76 linkerName: toolchainDetails.linkerName + compilerExtension 77 linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) 78 79 property string archiverName: toolchainDetails.archiverName + compilerExtension 80 property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) 81 82 property string disassemblerName: toolchainDetails.disassemblerName + compilerExtension 83 property string disassemblerPath: FileInfo.joinPaths(toolchainInstallPath, disassemblerName) 84 85 runtimeLibrary: "static" 86 87 staticLibrarySuffix: ".lib" 88 executableSuffix: toolchainDetails.executableSuffix 89 objectSuffix: toolchainDetails.objectSuffix 90 linkerMapSuffix: toolchainDetails.linkerMapSuffix 91 92 imageFormat: toolchainDetails.imageFormat 93 94 enableExceptions: false 95 enableRtti: false 96 97 defineFlag: "-D" 98 includeFlag: "-I" 99 systemIncludeFlag: "-I" 100 preincludeFlag: KEIL.preincludeFlag(compilerPath) 101 libraryDependencyFlag: "" 102 libraryPathFlag: "--userlibpath=" 103 linkerScriptFlag: "--scatter" 104 105 toolchainDetails: KEIL.toolchainDetails(qbs) 106 107 knownArchitectures: ["arm", "c166", "mcs251", "mcs51"] 108 109 Rule { 110 id: assembler 111 inputs: ["asm"] 112 outputFileTags: Cpp.assemblerOutputTags(generateAssemblerListingFiles) 113 outputArtifacts: Cpp.assemblerOutputArtifacts(input) 114 prepare: KEIL.prepareAssembler.apply(KEIL, arguments) 115 } 116 117 FileTagger { 118 patterns: ["*.s", "*.a51", ".asm"] 119 fileTags: ["asm"] 120 } 121 122 Rule { 123 id: compiler 124 inputs: ["cpp", "c"] 125 auxiliaryInputs: ["hpp"] 126 outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) 127 outputArtifacts: Cpp.compilerOutputArtifacts(input) 128 prepare: KEIL.prepareCompiler.apply(KEIL, arguments) 129 } 130 131 Rule { 132 id: applicationLinker 133 multiplex: true 134 inputs: ["obj", "linkerscript"] 135 inputsFromDependencies: ["staticlibrary"] 136 outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) 137 outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) 138 prepare: KEIL.prepareLinker.apply(KEIL, arguments) 139 } 140 141 Rule { 142 id: staticLibraryLinker 143 multiplex: true 144 inputs: ["obj"] 145 inputsFromDependencies: ["staticlibrary"] 146 outputFileTags: Cpp.staticLibraryLinkerOutputTags() 147 outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) 148 prepare: KEIL.prepareArchiver.apply(KEIL, arguments) 149 } 150} 151