summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2022-02-05 22:06:27 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2022-02-09 12:23:03 +0000
commitc2f6f404ad3f12d38ba8ac799c5eb5b8fb146a02 (patch)
tree92b3e72058c8ca32f6f9071af27d4533de07e582 /share
parenta4046a72a29e70abe482e8d35276721ace375997 (diff)
downloadqbs-c2f6f404ad3f12d38ba8ac799c5eb5b8fb146a02.tar.gz
Add support for other platforms supported by Open Watcom
This patch adds support for the following target platforms: * DOS - both 32/16 bit. * OS/2 - both 32/16 bit. * Windows - 16 bit. Also all these platforms covered in CI tests. Change-Id: Ie75d9203c50f4d61546b19328992ff0e107d9942 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/imports/qbs/Probes/WatcomProbe.qbs10
-rw-r--r--share/qbs/modules/cpp/watcom.js104
-rw-r--r--share/qbs/modules/cpp/watcom.qbs3
3 files changed, 90 insertions, 27 deletions
diff --git a/share/qbs/imports/qbs/Probes/WatcomProbe.qbs b/share/qbs/imports/qbs/Probes/WatcomProbe.qbs
index 34be235b1..09511458f 100644
--- a/share/qbs/imports/qbs/Probes/WatcomProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/WatcomProbe.qbs
@@ -29,6 +29,7 @@
****************************************************************************/
import qbs.File
+import qbs.Host
import qbs.ModUtils
import "../../../modules/cpp/watcom.js" as WATCOM
@@ -40,6 +41,7 @@ PathProbe {
property string _pathListSeparator
property string _toolchainInstallPath
property string _targetPlatform
+ property string _targetArchitecture
// Outputs
property string architecture
@@ -64,8 +66,8 @@ PathProbe {
if (!languages || languages.length === 0)
languages = ["c"];
- environment = WATCOM.guessEnvironment(_targetPlatform, _toolchainInstallPath,
- _pathListSeparator);
+ environment = WATCOM.guessEnvironment(Host.os(), _targetPlatform, _targetArchitecture,
+ _toolchainInstallPath, _pathListSeparator);
includePaths = environment["INCLUDE"].split(_pathListSeparator).filter(function(path) {
return File.exists(path);
@@ -73,7 +75,9 @@ PathProbe {
for (var i = 0; i < languages.length; ++i) {
var tag = languages[i];
- compilerDefinesByLanguage[tag] = WATCOM.dumpMacros(environment, compilerFilePath, tag);
+ compilerDefinesByLanguage[tag] = WATCOM.dumpMacros(
+ environment, compilerFilePath,
+ _targetPlatform, _targetArchitecture, tag);
}
var macros = compilerDefinesByLanguage["c"]
diff --git a/share/qbs/modules/cpp/watcom.js b/share/qbs/modules/cpp/watcom.js
index c186fe814..20ba2dbe3 100644
--- a/share/qbs/modules/cpp/watcom.js
+++ b/share/qbs/modules/cpp/watcom.js
@@ -40,13 +40,20 @@ var TextFile = require("qbs.TextFile");
var Utilities = require("qbs.Utilities");
function toolchainDetails(qbs) {
- var targetPlatform = qbs.targetPlatform;
+ var platform = qbs.targetPlatform;
var details = {};
- if (targetPlatform.contains("windows")) {
+ if (platform === "dos") {
+ details.imageFormat = "mz";
+ details.executableSuffix = ".exe";
+ } else if (platform === "os2") {
+ details.imageFormat = "pe";
+ details.executableSuffix = ".exe";
+ details.dynamicLibrarySuffix = ".dll";
+ } else if (platform === "windows") {
details.imageFormat = "pe";
details.executableSuffix = ".exe";
details.dynamicLibrarySuffix = ".dll";
- } else if (targetPlatform.contains("linux")) {
+ } else if (platform === "linux") {
details.imageFormat = "elf";
details.executableSuffix = "";
details.dynamicLibrarySuffix = ".so";
@@ -61,6 +68,31 @@ function languageFlag(tag) {
return "-xc++";
}
+function targetFlag(platform, architecture, type) {
+ if (platform === "dos") {
+ if (architecture === "x86_16")
+ return "-bdos";
+ else if (architecture === "x86")
+ return "-bdos4g";
+ } else if (platform === "os2") {
+ if (architecture === "x86_16")
+ return "-bos2";
+ else if (architecture === "x86")
+ return "-bos2v2";
+ } else if (platform === "windows") {
+ if (architecture === "x86_16")
+ return "-bwindows";
+ else if (architecture === "x86") {
+ if (type.contains("application"))
+ return "-bnt";
+ else if (type.contains("dynamiclibrary"))
+ return "-bnt_dll";
+ }
+ } else if (platform === "linux") {
+ return "-blinux";
+ }
+}
+
function guessVersion(macros) {
var version = parseInt(macros["__WATCOMC__"], 10)
|| parseInt(macros["__WATCOM_CPLUSPLUS__"], 10);
@@ -71,7 +103,8 @@ function guessVersion(macros) {
}
}
-function guessEnvironment(targetPlatform, toolchainInstallPath, pathListSeparator) {
+function guessEnvironment(hostOs, platform, architecture,
+ toolchainInstallPath, pathListSeparator) {
var toolchainRootPath = FileInfo.path(toolchainInstallPath);
if (!File.exists(toolchainRootPath)) {
throw "Unable to deduce environment due to compiler root directory: '"
@@ -95,23 +128,44 @@ function guessEnvironment(targetPlatform, toolchainInstallPath, pathListSeparato
setVariable("WATCOM", [toolchainRootPath], undefined, pathListSeparator);
setVariable("EDPATH", ["eddat"], toolchainRootPath, pathListSeparator);
- if (targetPlatform === "windows") {
- setVariable("WIPFC", ["wipfc"], toolchainRootPath, pathListSeparator);
- setVariable("PATH", ["binw", "binnt", "binnt64"], toolchainRootPath, pathListSeparator);
- setVariable("INCLUDE", ["h", "h/nt", "h/nt/directx", "h/nt/ddk"],
- toolchainRootPath, pathListSeparator);
- setVariable("WHTMLHELP", ["binnt/help"], toolchainRootPath, pathListSeparator);
- } else if (targetPlatform === "linux") {
+
+ if (hostOs.contains("linux"))
setVariable("PATH", ["binl64", "binl"], toolchainRootPath, pathListSeparator);
+ else if (hostOs.contains("windows"))
+ setVariable("PATH", ["binnt64", "binnt"], toolchainRootPath, pathListSeparator);
+
+ if (platform === "linux") {
setVariable("INCLUDE", ["lh"], toolchainRootPath, pathListSeparator);
} else {
- throw "Unable to deduce environment for unsupported target platform: '"
- + targetPlatform + "'";
+ // Common for DOS, Windows, OS/2.
+ setVariable("WIPFC", ["wipfc"], toolchainRootPath, pathListSeparator);
+ setVariable("WHTMLHELP", ["binnt/help"], toolchainRootPath, pathListSeparator);
+
+ var includes = ["h"];
+ if (platform === "dos") {
+ // Same includes as before.
+ } else if (platform === "os2") {
+ if (architecture === "x86")
+ includes = includes.concat(["h/os2"]);
+ else if (architecture === "x86_16")
+ includes = includes.concat(["h/os21x"]);
+ } else if (platform === "windows") {
+ if (architecture === "x86")
+ includes = includes.concat(["h/nt", "h/nt/directx", "h/nt/ddk"]);
+ else if (architecture === "x86_16")
+ includes = includes.concat(["h/win"]);
+ } else {
+ throw "Unable to deduce environment for unsupported target platform: '"
+ + platform + "'";
+ }
+
+ setVariable("INCLUDE", includes, toolchainRootPath, pathListSeparator);
}
+
return env;
}
-function dumpMacros(environment, compilerPath, tag) {
+function dumpMacros(environment, compilerPath, platform, architecture, tag) {
// Note: The Open Watcom 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
@@ -178,7 +232,10 @@ function dumpMacros(environment, compilerPath, tag) {
for (var envkey in environment)
process.setEnv(envkey, environment[envkey]);
- var args = [ outputFilePath ].concat(languageFlag(tag));
+ var target = targetFlag(platform, architecture, ["application"]);
+ var lang = languageFlag(tag);
+ var args = [ target, lang, outputFilePath ];
+
process.exec(compilerPath, args, false);
var m = Cpp.extractMacros(process.readStdOut(), /"?(#define(\s\w+){1,2})"?$/);
if (tag === "cpp" && m["__cplusplus"] === "1")
@@ -249,9 +306,12 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) {
function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
var args = ["-g" + (input.cpp.debugInformation ? "3" : "0")];
- var targetPlatform = product.qbs.targetPlatform;
+ var target = targetFlag(product.qbs.targetPlatform, product.qbs.architecture,
+ product.type);
+ args.push(target);
+
if (product.type.contains("application")) {
- if (targetPlatform === "windows") {
+ if (product.qbs.targetPlatform === "windows") {
var consoleApplication = product.consoleApplication;
args.push(consoleApplication ? "-mconsole" : "-mwindows");
}
@@ -358,18 +418,16 @@ function linkerFlags(project, product, inputs, outputs) {
var args = [];
var useCompilerDriver = useCompilerDriverLinker(product);
if (useCompilerDriver) {
- var targetPlatform = product.qbs.targetPlatform;
+ var target = targetFlag(product.qbs.targetPlatform, product.qbs.architecture,
+ product.type);
+ args.push(target);
+
if (product.type.contains("application")) {
- if (targetPlatform === "windows")
- args.push("-bnt")
- else if (targetPlatform === "linux")
- args.push("-blinux")
args.push("-o", FileInfo.toNativeSeparators(outputs.application[0].filePath));
if (product.cpp.generateLinkerMapFile)
args.push("-fm=" + FileInfo.toNativeSeparators(outputs.mem_map[0].filePath));
} else if (product.type.contains("dynamiclibrary")) {
if (targetPlatform === "windows") {
- args.push("-bnt_dll")
args.push("-Wl, option implib=" + FileInfo.toNativeSeparators(
outputs.dynamiclibrary_import[0].filePath));
}
diff --git a/share/qbs/modules/cpp/watcom.qbs b/share/qbs/modules/cpp/watcom.qbs
index d180b1455..eed63692c 100644
--- a/share/qbs/modules/cpp/watcom.qbs
+++ b/share/qbs/modules/cpp/watcom.qbs
@@ -53,6 +53,7 @@ CppModule {
_pathListSeparator: qbs.pathListSeparator
_toolchainInstallPath: toolchainInstallPath
_targetPlatform: qbs.targetPlatform
+ _targetArchitecture: qbs.architecture
}
qbs.architecture: watcomProbe.found ? watcomProbe.architecture : original
@@ -110,7 +111,7 @@ CppModule {
toolchainDetails: WATCOM.toolchainDetails(qbs)
- knownArchitectures: ["x86"]
+ knownArchitectures: ["x86", "x86_16"]
property var buildEnv: watcomProbe.environment
setupBuildEnvironment: {