summaryrefslogtreecommitdiff
path: root/share/qbs/modules
diff options
context:
space:
mode:
Diffstat (limited to 'share/qbs/modules')
-rw-r--r--share/qbs/modules/cpp/dmc.js71
-rw-r--r--share/qbs/modules/cpp/dmc.qbs28
2 files changed, 84 insertions, 15 deletions
diff --git a/share/qbs/modules/cpp/dmc.js b/share/qbs/modules/cpp/dmc.js
index 23d03ba09..1137a0c0a 100644
--- a/share/qbs/modules/cpp/dmc.js
+++ b/share/qbs/modules/cpp/dmc.js
@@ -38,7 +38,47 @@ var TemporaryDir = require("qbs.TemporaryDir");
var TextFile = require("qbs.TextFile");
var Utilities = require("qbs.Utilities");
-function dumpMacros(compilerFilePath, tag) {
+function targetFlags(platform, architecture, extender, consoleApp, type) {
+ if (platform === "dos") {
+ if (architecture === "x86_16") {
+ if (extender === "dosz")
+ return ["-mz"];
+ else if (extender === "dosr")
+ return ["-mr"];
+ return ["-mc"];
+ } else if (architecture === "x86") {
+ if (extender === "dosx")
+ return ["-mx"];
+ else if (extender === "dosp")
+ return ["-mp"];
+ }
+ } else if (platform === "windows") {
+ var flags = [];
+ if (architecture === "x86_16") {
+ flags.push("-ml");
+ if (type.contains("application") && !consoleApp)
+ flags.push("-WA");
+ else if (type.contains("dynamiclibrary"))
+ flags.push("-WD");
+ } else if (architecture === "x86") {
+ flags.push("-mn");
+ if (type.contains("application"))
+ flags.push("-WA");
+ else if (type.contains("dynamiclibrary"))
+ flags.push("-WD");
+ }
+ return flags;
+ }
+ return [];
+}
+
+function languageFlags(tag) {
+ if (tag === "cpp")
+ return ["-cpp"];
+ return [];
+}
+
+function dumpMacros(compilerPath, platform, architecture, extender, tag) {
// Note: The DMC compiler does not support the predefined/ macros dumping. So, we do it
// with the following trick, where we try to create and compile a special temporary file
// and to parse the console output with the own magic pattern: #define <key> <value>.
@@ -55,7 +95,8 @@ function dumpMacros(compilerFilePath, tag) {
"_MSDOS", "MSDOS",
// Prepare the OS/2 target macros.
"__OS2__",
- "WIN32", "_WIN32",
+ // Prepare the Windows target macros.
+ "WIN32", "_WIN32", "__NT__",
// Prepare extended the 32 and 16 bit DOS target macros.
"DOS386", "DOS16RM",
// Prepare the memory model macros.
@@ -96,9 +137,10 @@ function dumpMacros(compilerFilePath, tag) {
var process = new Process();
process.setWorkingDirectory(outputDirectory.path());
- var args = ["-c"].concat((tag === "cpp") ? ["-cpp"] : [],
- FileInfo.toWindowsSeparators(outputFilePath));
- process.exec(compilerFilePath, args, false);
+ var lang = languageFlags(tag);
+ var target = targetFlags(platform, architecture, extender, false, ["application"]);
+ var args = ["-c"].concat(lang, target, FileInfo.toWindowsSeparators(outputFilePath));
+ process.exec(compilerPath, args, false);
File.remove(outputFilePath);
var out = process.readStdOut();
return Cpp.extractMacros(out);
@@ -166,6 +208,12 @@ function depsOutputArtifacts(input, product) {
function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
var args = ["-c"];
+ var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags));
+ args = args.concat(languageFlags(tag));
+ args = args.concat(targetFlags(product.qbs.targetPlatform, product.qbs.architecture,
+ product.cpp.extenderName, product.consoleApplication,
+ product.type));
+
// Input.
args.push(FileInfo.toWindowsSeparators(input.filePath));
// Output.
@@ -178,7 +226,6 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
// Defines.
args = args.concat(Cpp.collectDefinesArguments(input));
- var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags));
if (tag === "cpp") {
// We need to add the paths to the STL includes, because the DMC compiler does
// not handle it by default (because the STL libraries is a separate port).
@@ -226,8 +273,6 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
args.push("-wx");
if (tag === "cpp") {
- args.push("-cpp");
-
// Exceptions flag.
if (input.cpp.enableExceptions)
args.push("-Ae");
@@ -285,6 +330,10 @@ function linkerFlags(project, product, inputs, outputs) {
var useCompilerDriver = useCompilerDriverLinker(product);
if (useCompilerDriver) {
+ args = args.concat(targetFlags(product.qbs.targetPlatform, product.qbs.architecture,
+ product.cpp.extenderName, product.consoleApplication,
+ product.type));
+
// Input objects.
args = args.concat(Cpp.collectLinkerObjectPaths(inputs).map(function(path) {
return FileInfo.toWindowsSeparators(path);
@@ -303,11 +352,11 @@ function linkerFlags(project, product, inputs, outputs) {
// Output.
if (product.type.contains("application")) {
args.push("-o" + FileInfo.toWindowsSeparators(outputs.application[0].filePath));
- args.push("-WA");
- args.push("/SUBSYSTEM:" + (product.consoleApplication ? "CONSOLE" : "WINDOWS"));
+ args.push("-L/" + (product.cpp.generateLinkerMapFile ? "MAP" : "NOMAP"));
+ if (product.qbs.targetPlatform === "windows" && product.qbs.architecture === "x86")
+ args.push("-L/SUBSYSTEM:" + (product.consoleApplication ? "CONSOLE" : "WINDOWS"));
} else if (product.type.contains("dynamiclibrary")) {
args.push("-o" + FileInfo.toWindowsSeparators(outputs.dynamiclibrary[0].filePath));
- args.push("-WD");
}
if (product.cpp.debugInformation)
diff --git a/share/qbs/modules/cpp/dmc.qbs b/share/qbs/modules/cpp/dmc.qbs
index fe8ba25f1..f7f75169b 100644
--- a/share/qbs/modules/cpp/dmc.qbs
+++ b/share/qbs/modules/cpp/dmc.qbs
@@ -43,7 +43,7 @@ CppModule {
Probes.BinaryProbe {
id: compilerPathProbe
condition: !toolchainInstallPath && !_skipAllChecks
- names: ["cxcorm"]
+ names: ["dmc"]
}
Probes.DmcProbe {
@@ -51,10 +51,13 @@ CppModule {
condition: !_skipAllChecks
compilerFilePath: compilerPath
enableDefinesByLanguage: enableCompilerDefinesByLanguage
+ _targetPlatform: qbs.targetPlatform
+ _targetArchitecture: qbs.architecture
+ _targetExtender: extenderName
}
qbs.architecture: dmcProbe.found ? dmcProbe.architecture : original
- qbs.targetPlatform: dmcProbe.targetPlatform
+ qbs.targetPlatform: dmcProbe.found ? dmcProbe.targetPlatform : original
compilerVersionMajor: dmcProbe.versionMajor
compilerVersionMinor: dmcProbe.versionMinor
@@ -86,6 +89,18 @@ CppModule {
property string rccCompilerName: "rcc.exe"
property string rccCompilerPath: FileInfo.joinPaths(toolchainInstallPath, rccCompilerName)
+ property string extenderName
+ PropertyOptions {
+ name: "extenderName"
+ allowedValues: [undefined, "dosz", "dosr", "dosx", "dosp"]
+ description: "Specifies the DOS memory extender to compile with:\n"
+ + " - \"dosz\" is the ZPM 16 bit DOS Extender\n"
+ + " - \"dosr\" is the Rational 16 bit DOS Extender\n"
+ + " - \"dosx\" is the DOSX 32 bit DOS Extender\n"
+ + " - \"dosp\" is the Pharlap 32 bit DOS Extender\n"
+ ;
+ }
+
runtimeLibrary: "dynamic"
staticLibrarySuffix: ".lib"
@@ -93,7 +108,12 @@ CppModule {
executableSuffix: ".exe"
objectSuffix: ".obj"
- imageFormat: "pe"
+ imageFormat: {
+ if (qbs.targetPlatform === "dos")
+ return "mz";
+ else if (qbs.targetPlatform === "windows")
+ return "pe";
+ }
defineFlag: "-D"
includeFlag: "-I"
@@ -101,7 +121,7 @@ CppModule {
preincludeFlag: "-HI"
libraryPathFlag: "-L/packcode"
- knownArchitectures: ["x86"]
+ knownArchitectures: ["x86", "x86_16"]
Rule {
id: assembler