Skip to content

Commit

Permalink
Add an open option to open things
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Apr 14, 2024
1 parent f7d6ef5 commit 63cc807
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 11 deletions.
2 changes: 2 additions & 0 deletions kmake/src/Exporters/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ export abstract class Exporter {
reject('Called an abstract function');
});
}

open(project: Project, to: string) {}
}
5 changes: 5 additions & 0 deletions kmake/src/Exporters/VisualStudioExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { VrApi } from 'kmake/VrApi';
import * as log from 'kmake/log';
import * as fs from 'kmake/fsextra';
import * as path from 'path';
import * as child_process from 'child_process';
import * as crypto from 'crypto';
import { CLionExporter } from 'kmake/Exporters/CLionExporter';

Expand Down Expand Up @@ -184,6 +185,10 @@ export class VisualStudioExporter extends Exporter {
}
}

open(project: Project, to: string) {
child_process.spawn('start', [path.resolve(to, project.getSafeName() + '.sln')]);
}

async exportSolution(project: Project, from: string, to: string, platform: string, vrApi: any, options: any) {
this.clion.exportSolution(project, from, to, platform, vrApi, options);

Expand Down
18 changes: 13 additions & 5 deletions kmake/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ function compileKong(project: Project, from: string, to: string, platform: strin

let consoleCompilePlatform: string = null;

async function exportKoremakeProject(from: string, to: string, platform: string, korefile: string, retro: boolean, veryretro: boolean, options: any) {
async function exportKoremakeProject(from: string, to: string, platform: string, korefile: string, retro: boolean, veryretro: boolean, options: any): Promise<[Project, Exporter]> {
log.info('kfile found.');
if (options.onlyshaders) {
log.info('Only compiling shaders.');
Expand Down Expand Up @@ -605,7 +605,7 @@ async function exportKoremakeProject(from: string, to: string, platform: string,
}

if (options.onlyshaders) {
return project;
return [project, null];
}

// Run again to find new shader files for Metal
Expand Down Expand Up @@ -679,14 +679,14 @@ async function exportKoremakeProject(from: string, to: string, platform: string,
});
}*/

return project;
return [project, exporter]
}

function isKoremakeProject(directory: string, korefile: string): boolean {
return fs.existsSync(path.resolve(directory, korefile));
}

async function exportProject(from: string, to: string, platform: string, korefile: string, options: any): Promise<Project> {
async function exportProject(from: string, to: string, platform: string, korefile: string, options: any): Promise<[Project, Exporter]> {
if (isKoremakeProject(from, korefile)) {
return exportKoremakeProject(from, to, platform, korefile, false, false, options);
}
Expand Down Expand Up @@ -950,8 +950,11 @@ export async function run(options: any, loglog: any): Promise<string> {
options.buildPath = options.debug ? 'Debug' : 'Release';

let project: Project = null;
let exporter: Exporter = null;
try {
project = await exportProject(options.from, options.to, options.target, options.kfile, options);
const value = await exportProject(options.from, options.to, options.target, options.kfile, options);
project = value[0];
exporter = value[1];
}
catch (error) {
throw error;
Expand Down Expand Up @@ -1081,5 +1084,10 @@ export async function run(options: any, loglog: any): Promise<string> {
process.exit(1);
}
}

if (options.open) {
exporter.open(project, options.to);
}

return solutionName;
}
5 changes: 5 additions & 0 deletions lib/internal/main/run_main_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ let options = [
description: 'Use the JavaScript from the kmake repo that path points to',
metavar: 'path',
default: ''
},
{
full: 'open',
value: false,
description: 'Open the created project in its default application (usually your IDE)'
}
];

Expand Down
1 change: 1 addition & 0 deletions lib/kmake/Exporters/Exporter.js

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

2 changes: 1 addition & 1 deletion lib/kmake/Exporters/Exporter.js.map

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

4 changes: 4 additions & 0 deletions lib/kmake/Exporters/VisualStudioExporter.js

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

2 changes: 1 addition & 1 deletion lib/kmake/Exporters/VisualStudioExporter.js.map

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions lib/kmake/main.js

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

2 changes: 1 addition & 1 deletion lib/kmake/main.js.map

Large diffs are not rendered by default.

0 comments on commit 63cc807

Please sign in to comment.