This commit is contained in:
Nishi 2026-05-09 19:19:44 +09:00
commit 7ce5bd3cf3
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 36 additions and 6 deletions

View file

@ -20,6 +20,7 @@ function main() {
Duktape.output = "duktape";
Duktape.sources = fs.glob("external/duktape/*.c");
Duktape.includes = [ "external/duktape" ];
Duktape.libdirs = ["a"];
if(pmake.system.target == "Unix") {
Duktape.libraries = [ "m" ];

View file

@ -46,7 +46,11 @@ Watcom.link = function(target, files) {
return "library \"" + x + "\"";
}
return "wlink option quiet system nt name " + this.output(target) + " " + files.map(add_file).join(" ") + " " + pmake.libs(target, add_lib).map(add_library).join(" ");
function add_libpath(x) {
return "libpath \"" + x + "\"";
}
return "wlink option quiet system nt name " + this.output(target) + " " + files.map(add_file).join(" ") + " " + pmake.libdirs(target).map(add_libpath).join(" ") + " " + pmake.libs(target, add_lib).map(add_library).join(" ");
}
return "";

View file

@ -77,7 +77,7 @@ pmake.resolveProjects = function(arr, if_str) {
}
if(proj instanceof pmake.Project) {
r = r.concat(pmake.resolveProjects(proj.libraries));
r = r.concat(pmake.resolveProjects(proj.libraries, if_str));
r.push(proj);
} else if((typeof proj) == "string" && if_str) {
r.push(if_str(proj));
@ -105,12 +105,10 @@ pmake.includes = function(target) {
return targets.map(includes).flat();
};
pmake.libs = function(target, if_str) {
function libs(x) {
pmake.libdirs = function(target, if_str) {
function libdirs(x) {
if(x instanceof pmake.LibraryProject) {
return x.libraries.concat([ pmake.compiler.output(x) ]);
} else if((typeof x) == "string") {
return [ x ];
return x.libdirs;
}
return [];
@ -118,7 +116,29 @@ pmake.libs = function(target, if_str) {
const targets = pmake.resolveProjects(target.libraries, if_str);
return targets.map(libs).flat();
return target.libdirs.concat(targets.map(libdirs).flat());
};
pmake.libs = function(target, if_str) {
function libs(x) {
if(x instanceof pmake.LibraryProject) {
const r = pmake.resolveProjects(x.libraries, if_str).concat([ pmake.compiler.output(x) ]);
return r;
} else if((typeof x) == "string") {
return [ x ];
}
return [];
}
const targets = pmake.resolveProjects(target.libraries, if_str).map(libs).flat();
targets = targets.filter(function(item, pos) {
return targets.indexOf(item) == pos;
});
return targets;
};
pmake.setSystem = function(target) {
@ -192,7 +212,11 @@ POSIXCompiler.prototype.link = function(target, files) {
return "-l" + x;
}
return this.prefix + c + " -o " + this.output(target) + " " + files.join(" ") + " " + pmake.libs(target, add_l).join(" ");
function add_L(x) {
return "-L" + x;
}
return this.prefix + c + " " + pmake.libdirs(target).map(add_L).join(" ") + " -o " + this.output(target) + " " + files.join(" ") + " " + pmake.libs(target, add_l).join(" ");
}
return "";
@ -209,6 +233,7 @@ const Project = function(target) {
this.target = target;
this.sources = [];
this.includes = [];
this.libdirs = [];
this.libraries = [];
this.output = target;
};