diff --git a/console/README.md b/console/README.md index 1fda3583bf..129c784c74 100644 --- a/console/README.md +++ b/console/README.md @@ -13,9 +13,9 @@ npm start To run, the console needs to find a build of Interface, domain-server, and assignment-client. -The command `npm start` tells the console to look for debug builds of those binaries in a build folder beside this console folder. +The command `npm start` tells the console to look for builds of those binaries in a build folder beside this console folder. -To look for release builds in the build folder, you'll want `npm run local-release`. +On platforms with separate build folders for release and debug libraries `npm start` will choose the debug binaries. On those platforms if you prefer to use local release builds you'll want `npm run local-release`. ### Packaging diff --git a/console/main.js b/console/main.js index 0188bb11ab..deedc4af4f 100644 --- a/console/main.js +++ b/console/main.js @@ -24,25 +24,79 @@ var APP_ICON = 'resources/tray-icon.png'; // Quit when all windows are closed. app.on('window-all-closed', function() { +<<<<<<< HEAD // On OS X it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform != 'darwin') { app.quit(); } +======= + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform != 'darwin') { + app.quit(); + } +>>>>>>> add initial local process search }); // Check command line arguments to see how to find binaries -var argv = require('yargs'); +var argv = require('yargs').argv; +var fs = require('fs'); -if (argv.localDebugBuilds) { - // check in a dev folder structure for debug binaries -} else if (argv.localReleaseBuilds) { - // check in a dev folder structure for release binaries -} else { - // check beside the console application for the binaries +function localProcessForBinary(name, preferRelease) { + var path = "../build/" + name + "/"; + + function processFromPath(name, path) { + function platformExtension() { + return process.platform == 'win32' ? ".exe" : "" + } + + try { + var fullPath = path + name + platformExtension(); + + var stats = fs.lstatSync(path + name + platformExtension()) + + if (stats.isFile()) { + console.log("Found " + name + " at " + fullPath); + return fullPath; + } + } catch (e) { + console.log("Executable with name " + name + " not found at path " + path); + } + + return null; + } + + // does the executable exist at this path already? + // if so assume we're on a platform that doesn't have Debug/Release + // folders and just use the discovered executable + var matchingProcess = processFromPath(name, path); + + if (matchingProcess == null) { + if (preferRelease) { + // check if we can find the executable in a Release folder below this path + matchingProcess = processFromPath(name, path + "Release/"); + } else { + // check if we can find the executable in a Debug folder below this path + matchingProcess = processFromPath(name, path + "Debug/"); + } + } + + return matchingProcess; } +if (argv.localDebugBuilds) { + // check in a dev folder structure for debug binaries + var interfaceProcess = localProcessForBinary("Interface"); + var dsProcess = localProcessForBinary("domain-server"); + var acProcess = localProcessForBinary("assignment-client"); +} else if (argv.localReleaseBuilds) { + // check in a dev folder structure for release binaries +} else { + // check beside the console application for the binaries +} + // This method will be called when Electron has finished // initialization and is ready to create browser windows. app.on('ready', function() {