Skip to content

Commit

Permalink
Use the proper executable name when copying the executable
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 4, 2023
1 parent ffad252 commit 6ae4bd4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
19 changes: 12 additions & 7 deletions kmake/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,35 +733,40 @@ function compileProject(make: child_process.ChildProcess, project: Project, solu
const sec = Math.floor(time - min * 60);
log.info(`Build time: ${min}m ${sec}s`);
if (code === 0) {
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}

if ((options.customTarget && options.customTarget.baseTarget === Platform.Linux) || options.target === Platform.Linux) {
if (options.lib) {
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), solutionName + '.a'), path.resolve(options.from.toString(), project.getDebugDir(), solutionName + '.a'));
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), executableName + '.a'), path.resolve(options.from.toString(), project.getDebugDir(), executableName + '.a'));
}
else if (options.dynlib) {
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), solutionName + '.so'), path.resolve(options.from.toString(), project.getDebugDir(), solutionName + '.so'));
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), executableName + '.so'), path.resolve(options.from.toString(), project.getDebugDir(), executableName + '.so'));
}
else {
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), solutionName), path.resolve(options.from.toString(), project.getDebugDir(), solutionName));
fs.copyFileSync(path.resolve(path.join(options.to.toString(), options.buildPath), executableName), path.resolve(options.from.toString(), project.getDebugDir(), executableName));
}
}
else if ((options.customTarget && options.customTarget.baseTarget === Platform.Windows) || options.target === Platform.Windows) {
const extension = (options.lib || options.dynlib) ? (options.lib ? '.lib' : '.dll') : '.exe';
const from =
dothemath
? path.join(options.to.toString(), 'x64', options.debug ? 'Debug' : 'Release', solutionName + extension)
: path.join(options.to.toString(), options.debug ? 'Debug' : 'Release', solutionName + extension);
? path.join(options.to.toString(), 'x64', options.debug ? 'Debug' : 'Release', executableName + extension)
: path.join(options.to.toString(), options.debug ? 'Debug' : 'Release', executableName + extension);
const dir = path.isAbsolute(project.getDebugDir())
? project.getDebugDir()
: path.join(options.from.toString(), project.getDebugDir());
fs.copyFileSync(from, path.join(dir, solutionName + extension));
fs.copyFileSync(from, path.join(dir, executableName + extension));
}
if (options.run) {
if ((options.customTarget && options.customTarget.baseTarget === Platform.OSX) || options.target === Platform.OSX) {
const spawned = child_process.spawn('build/' + (options.debug ? 'Debug' : 'Release') + '/' + project.name + '.app/Contents/MacOS/' + project.name, {stdio: 'inherit', cwd: options.to});
spawned.on('close', () => { resolve(); });
}
else if ((options.customTarget && (options.customTarget.baseTarget === Platform.Linux || options.customTarget.baseTarget === Platform.Windows)) || options.target === Platform.Linux || options.target === Platform.Windows) {
const spawned = child_process.spawn(path.resolve(options.from.toString(), project.getDebugDir(), solutionName), [], {stdio: 'inherit', cwd: path.resolve(options.from.toString(), project.getDebugDir())});
const spawned = child_process.spawn(path.resolve(options.from.toString(), project.getDebugDir(), executableName), [], {stdio: 'inherit', cwd: path.resolve(options.from.toString(), project.getDebugDir())});
spawned.on('close', () => { resolve(); });
}
else {
Expand Down
18 changes: 11 additions & 7 deletions lib/kmake/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6ae4bd4

Please sign in to comment.