forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -7,6 +7,13 @@ const path = require("path");
|
||||
const log = require("./log");
|
||||
const ProjectFile_1 = require("./ProjectFile");
|
||||
class Library {
|
||||
constructor() {
|
||||
/**
|
||||
* If haxelib `classPath` is specified,
|
||||
* we don't add `libpath` as `-cp` to `hxml`.
|
||||
*/
|
||||
this.classPathIsAdded = false;
|
||||
}
|
||||
}
|
||||
exports.Library = Library;
|
||||
class Target {
|
||||
@ -66,7 +73,7 @@ class Project {
|
||||
if (!path.isAbsolute(projectDir)) {
|
||||
projectDir = path.join(this.scriptdir, projectDir);
|
||||
}
|
||||
if (!fs.existsSync(path.join(projectDir, 'khafile.js')) && (fs.existsSync(path.join(projectDir, 'kincfile.js')) || fs.existsSync(path.join(projectDir, 'korefile.js')) || fs.existsSync(path.join(projectDir, 'kfile.js')))) {
|
||||
if (!fs.existsSync(path.join(projectDir, 'khafile.js')) && (fs.existsSync(path.join(projectDir, 'kfile.js')) || fs.existsSync(path.join(projectDir, 'korefile.js')) || fs.existsSync(path.join(projectDir, 'kincfile.js')))) {
|
||||
this.libraries.push({
|
||||
libpath: projectDir,
|
||||
libroot: projectDir
|
||||
@ -176,14 +183,13 @@ class Project {
|
||||
}
|
||||
addLibrary(library) {
|
||||
this.addDefine(library);
|
||||
let self = this;
|
||||
function findLibraryDirectory(name) {
|
||||
const findLibraryDirectory = (name) => {
|
||||
if (path.isAbsolute(name)) {
|
||||
return { libpath: name, libroot: name };
|
||||
}
|
||||
// Tries to load the default library from inside the kha project.
|
||||
// e.g. 'Libraries/wyngine'
|
||||
let libpath = path.join(self.scriptdir, self.localLibraryPath, name);
|
||||
let libpath = path.join(this.scriptdir, this.localLibraryPath, name);
|
||||
if (fs.existsSync(libpath) && fs.statSync(libpath).isDirectory()) {
|
||||
let dir = path.resolve(libpath);
|
||||
return { libpath: dir, libroot: dir };
|
||||
@ -223,7 +229,7 @@ class Project {
|
||||
log.error('Error: Library ' + name + ' not found.');
|
||||
log.error('Add it to the \'Libraries\' subdirectory of your project. You may also install it via haxelib but that\'s less cool.');
|
||||
throw 'Library ' + name + ' not found.';
|
||||
}
|
||||
};
|
||||
let libInfo = findLibraryDirectory(library);
|
||||
let dir = libInfo.libpath;
|
||||
if (dir !== '') {
|
||||
@ -231,17 +237,18 @@ class Project {
|
||||
if (elem.libroot === libInfo.libroot)
|
||||
return '';
|
||||
}
|
||||
this.libraries.push({
|
||||
const lib = {
|
||||
libpath: dir,
|
||||
libroot: libInfo.libroot
|
||||
});
|
||||
};
|
||||
this.libraries.push(lib);
|
||||
// If this is a haxelib library, there must be a haxelib.json
|
||||
if (fs.existsSync(path.join(dir, 'haxelib.json'))) {
|
||||
let options = JSON.parse(fs.readFileSync(path.join(dir, 'haxelib.json'), 'utf8'));
|
||||
// If there is a classPath value, add that directory to be loaded.
|
||||
// Otherwise, just load the current path.
|
||||
if (options.classPath) {
|
||||
// TODO find an example haxelib that has a classPath value
|
||||
lib.classPathIsAdded = true;
|
||||
this.sources.push(path.join(dir, options.classPath));
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user