Fix building LOOT as a native Linux application.

Not all Windows-specific code has equivalent Linux code, file path to
URL conversion is hacky, and only that LOOT launches correctly with no
game detected has been tested.
This commit is contained in:
Oliver Hamlet
2015-10-29 18:20:14 +00:00
parent f837e3a235
commit d874fbb52c
14 changed files with 377 additions and 148 deletions
+94 -3
View File
@@ -1,6 +1,7 @@
// Helper functions shared across scripts.
var path = require('path');
var fs = require('fs');
var os = require('os');
function fileExists(file_path) {
try {
@@ -16,9 +17,99 @@ function fileExists(file_path) {
return false;
}
function isMultiArch(root_path) {
return fileExists(path.join(root_path, 'build', '64', 'Release', 'loot64.dll'));
function getAppReleasePaths(root_path) {
var paths = [];
var file = 'LOOT';
var paths_to_try = [
{
path: path.join(root_path, 'build'),
label: null
},
{
path: path.join(root_path, 'build', '32'),
label: '32 bit'
},
{
path: path.join(root_path, 'build', '64'),
label: '64 bit'
}
];
if (os.platform() == 'win32') {
file += '.exe';
}
for (var i = 0; i < paths_to_try.length; ++i) {
if (os.platform() == 'win32') {
paths_to_try[i].path = path.join(paths_to_try[i].path, 'Release');
}
if (fileExists(path.join(paths_to_try[i].path, file))) {
paths.push(paths_to_try[i]);
}
}
return paths;
}
function getApiBinaryPaths(root_path) {
var paths = [];
var files = [];
var paths_to_try = [
{
path: path.join(root_path, 'build'),
label: null
},
{
path: path.join(root_path, 'build', '32'),
label: '32 bit'
},
{
path: path.join(root_path, 'build', '64'),
label: '64 bit'
}
];
for (var i = 0; i < paths_to_try.length; ++i) {
if (os.platform() == 'win32') {
paths_to_try[i].path = path.join(paths_to_try[i].path, 'Release');
files = [
{
name: 'loot32.dll',
label: '32 bit'
},
{
name: 'loot64.dll',
label: '64 bit'
}
];
} else {
files = [
{
name: 'libloot32.so',
label: '32 bit'
},
{
name: 'libloot64.so',
label: '64 bit'
}
];
}
for (var j = 0; j < files.length; ++j) {
if (fileExists(path.join(paths_to_try[i].path, files[j].name))) {
paths_to_try[i].path = path.join(paths_to_try[i].path, files[j].name);
paths_to_try[i].label = files[j].label;
paths.push(paths_to_try[i]);
break;
}
}
}
return paths;
}
module.exports.fileExists = fileExists;
module.exports.isMultiArch = isMultiArch;
module.exports.getAppReleasePaths = getAppReleasePaths;
module.exports.getApiBinaryPaths = getApiBinaryPaths;