aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2022-02-10 18:32:34 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2022-02-17 12:34:25 +0000
commit2ddbafe29872d43245a7fba544dbdced21a09b7f (patch)
tree9fce25afa97ac4917e8ab1c37fc7c074c3fa7255 /share/qbs/modules/cpp
parent29b15e594f50314959ce9b63c4a39cc86e831475 (diff)
Add support for other platforms supported by Digital Mars
This patch adds support for the following target platforms: * DOS - both 32/16 bit. * Windows - 16 bit. Also, more specifically, the target is controlled by the `cpp.extenderName` property, which is the DOS extender to use. The Digital Mars support the following DOS extenders: * Rational 16 bit DOS Extender * ZPM 16 bit DOS Extender * DOSX 32 bit DOS Extender * Pharlap 32 bit DOS Extender which have the following names `dosr`, `dosz`, `dosx`, `dosp`. The user can set any of the desired values in the `cpp.extenderName` property (also this property can be empty that means no any extender is used). Right now the `qbs-setup-toolchain` utility creates all possible supported profiles with the required pre-configured properties: Profile 'dmc-8_57_0-windows-x86' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-windows-x86_16' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-dosx-x86' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-dosp-x86' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-dosr-x86_16' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-dosz-x86_16' created for 'C:/dm/bin/dmc.exe'. Profile 'dmc-8_57_0-dos-x86_16' created for 'C:/dm/bin/dmc.exe'. Compiling with DOS extenders requires additional external utilities and libraries (depending on the extender type). Some of them are no longer available at the moment, so the tests in CI are only done for the `dmc-windows-x86`, `dmc-windows-x86_16`, and `dmc-dos-x86_16` profiles. Change-Id: I221d2995900c63605c8552b825bf0c4d55171f5c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp')
-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