forked from Onek8/LNXSDK
Update
This commit is contained in:
@ -7,6 +7,11 @@ import {loadProject} from './ProjectFile';
|
||||
export class Library {
|
||||
libpath: string;
|
||||
libroot: string;
|
||||
/**
|
||||
* If haxelib `classPath` is specified,
|
||||
* we don't add `libpath` as `-cp` to `hxml`.
|
||||
*/
|
||||
classPathIsAdded? = false;
|
||||
}
|
||||
|
||||
export class Target {
|
||||
@ -29,6 +34,26 @@ function contains(main: string, sub: string) {
|
||||
return sub.indexOf(main) === 0 && sub.slice(main.length)[0] === path.sep;
|
||||
}
|
||||
|
||||
export type AssetMatcherOptions = {
|
||||
name?: string;
|
||||
nameBaseDir?: string;
|
||||
baseDir?: string;
|
||||
namePathSeparator?: string;
|
||||
destination?: string;
|
||||
destinationCallback?: (destination: string) => string;
|
||||
|
||||
quality?: number;
|
||||
noprocessing?: boolean;
|
||||
notinlist?: boolean;
|
||||
md5sum?: string;
|
||||
|
||||
original_height?: number;
|
||||
original_width?: number;
|
||||
readable?: boolean;
|
||||
}
|
||||
|
||||
export type AssetMatcher = { match: string, options: AssetMatcherOptions }
|
||||
|
||||
export class Project {
|
||||
static platform: string;
|
||||
static scriptdir: string;
|
||||
@ -46,7 +71,7 @@ export class Project {
|
||||
localLibraryPath: string;
|
||||
windowOptions: any;
|
||||
targetOptions: any;
|
||||
assetMatchers: { match: string, options: any }[];
|
||||
assetMatchers: AssetMatcher[];
|
||||
shaderMatchers: { match: string, options: any }[];
|
||||
customTargets: Map<string, Target>;
|
||||
stackSize: number;
|
||||
@ -95,7 +120,7 @@ export 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
|
||||
@ -151,7 +176,7 @@ export class Project {
|
||||
* Asset types are infered from the file suffix.
|
||||
* Glob syntax is very simple, the most important patterns are * for anything and ** for anything across directories.
|
||||
*/
|
||||
addAssets(match: string, options: any) {
|
||||
addAssets(match: string, options: AssetMatcherOptions) {
|
||||
if (!options) options = {};
|
||||
|
||||
if (!path.isAbsolute(match)) {
|
||||
@ -217,15 +242,15 @@ export class Project {
|
||||
|
||||
addLibrary(library: string): string {
|
||||
this.addDefine(library);
|
||||
let self = this;
|
||||
function findLibraryDirectory(name: string) {
|
||||
|
||||
const findLibraryDirectory = (name: string) => {
|
||||
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 };
|
||||
@ -275,17 +300,18 @@ export class Project {
|
||||
if (elem.libroot === libInfo.libroot)
|
||||
return '';
|
||||
}
|
||||
this.libraries.push({
|
||||
const lib:Library = {
|
||||
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