Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
#define OFPROJECTGENERATOR_MINOR_VERSION "105"
#define OFPROJECTGENERATOR_MINOR_VERSION "106"
#define OFPROJECTGENERATOR_PATCH_VERSION "0"

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
3 changes: 2 additions & 1 deletion frontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ function setup() {

if(isSierra) {
try {
const runningOnVar = (ofpath.length >= 8 && ofpath.substring(0,8) === '/private');
// matches Gatekeeper's real AppTranslocation path, not just any /private path
const runningOnVar = /^\/private\/var\/folders\/.*\/AppTranslocation\//.test(ofpath);
isFirstTimeSierra = runningOnVar;
} catch(e) {
isFirstTimeSierra = false;
Expand Down
8 changes: 5 additions & 3 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,14 @@



<div class="ui negative message" id="ofPathSierraMessage" style="position: absolute; top:-10px; left:0px; width:100%; height:400px; display:none;">
<div class="ui negative message" id="ofPathSierraMessage" style="position: absolute; top:-10px; left:0px; width:100%; display:none;">
<div class="header">
ACTION NEEDED: Running on macOS for the first time?
ACTION NEEDED: macOS quarantine warning
</div>

<p><br/>Please close the ProjectGenerator.app, move it up a level (or anywhere on HD) and then back into the projectGenerator/ folder. <br/> <br/> If the OF path is not the root of the unzipped OF folder please set the OF path to this folder (ie, the folder which has "addons", "libs", in it)</p>
<p>macOS is running this app from a temporary, randomized location because it still has a "downloaded from the internet" flag. This can confuse auto-detection of your openFrameworks path.</p>
<p><strong>Easiest fix:</strong> just set the OF path below to the folder containing "addons" and "libs".</p>
<p><strong>Permanent fix:</strong> close this app, move ProjectGenerator.app anywhere via Finder (e.g. to your Desktop) and back, then relaunch.</p>
</div>

</div>
Expand Down
84 changes: 73 additions & 11 deletions frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ const templateSettings = {



// mirrors isGoodOFPath() in commandLine/src/main.cpp
function isGoodOFPath(p) {
try {
return ['addons', 'libs', 'scripts'].every((folder) => {
const full = path.join(p, folder);
return fs.existsSync(full) && fs.statSync(full).isDirectory();
});
} catch (e) {
return false;
}
}

// mirrors findOFPathUpwards() in commandLine/src/main.cpp
function findOFPathUpwards(startPath) {
let current = path.resolve(startPath);
let previous = null;
while (current !== previous) {
if (isGoodOFPath(current)) return current;
previous = current;
current = path.dirname(current);
}
return null;
}

/**
* Determines the current platform based on process information.
* @returns {string} The platform identifier.
Expand Down Expand Up @@ -256,10 +280,18 @@ if (!path.isAbsolute(defaultOfPath)) {
// arturo, this may differ on linux, if putting ../ in settings doesn't work for the default path
// take a look at this...

let fixedDepthGuess;
if (hostplatform == "windows" || hostplatform == "linux" || hostplatform == "linux64" ){
defaultOfPath = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath));
fixedDepthGuess = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath));
} else if(hostplatform == "osx"){
defaultOfPath = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath));
fixedDepthGuess = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath));
}

// validate the fixed-depth guess, else search upward from this app's own location
if (isGoodOFPath(fixedDepthGuess)) {
defaultOfPath = fixedDepthGuess;
} else {
defaultOfPath = findOFPathUpwards(__dirname) || fixedDepthGuess;
}

settings["defaultOfPath"] = defaultOfPath || "";
Expand Down Expand Up @@ -977,11 +1009,35 @@ function getPgPath() {
return pgApp;
}

// clear error when the cmdLine binary hasn't been built/copied into frontend/app/ yet
function pgMissingError(pgApp) {
return new Error(
`commandLine binary not found at "${pgApp}". Build it first (commandLine/, via make/xcodebuild/MSBuild) ` +
`then copy it into frontend/app/ - see scripts/<platform>/build_frontend.sh, which does both.`
);
}

// wraps execFile(getPgPath(), ...) with the same missing-binary check as runPG()
function execPG(args, callback) {
const pgApp = getPgPath();
if (!pgApp || !fs.existsSync(pgApp)) {
callback(pgMissingError(pgApp), '', '');
return;
}
execFile(pgApp, args, { maxBuffer: Infinity }, callback);
}

// runs PG via argv (no shell), streaming stdout/stderr to the console panel as it arrives
function runPG(args, event, callback) {
const pgApp = getPgPath();
const displayCommand = [pgApp, ...args].join(' ');

if (!pgApp || !fs.existsSync(pgApp)) {
const error = pgMissingError(pgApp);
callback(error, '', error.message);
return;
}

let child;
try {
child = spawn(pgApp, args, { windowsHide: true });
Expand Down Expand Up @@ -1637,7 +1693,7 @@ function resolveEmsdkEnv(emsdkPath, emccDir) {

// asks the PG binary to detect emcc via EMSDK / PATH / a Homebrew install (see resolveEmscriptenSDK in Utils.cpp)
function detectEmsdk(callback) {
execFile(getPgPath(), ['-e'], { maxBuffer: Infinity }, (error, stdout) => {
execPG(['-e'], (error, stdout) => {
if (error) return callback(null);
try {
const lastLine = stdout.trim().split('\n').pop();
Expand Down Expand Up @@ -1784,13 +1840,19 @@ ipcMain.on('openPath', (event, p) => {
});

ipcMain.on('getOFPath', (event) => {
execFile(getPgPath(), ['--getofpath'], { maxBuffer: Infinity }, (error, stdout, stderr) => {
execPG(['--getofpath'], (error, stdout, stderr) => {
if (error) {
console.log( 'getOFPath error' );
event.sender.send('ofPathResult', {
success: false,
message: error.message
});
console.log('getOFPath error:', error.message);
// cmdLine unavailable - fall back to the same search it would have done
const found = findOFPathUpwards(__dirname);
if (found) {
event.sender.send('ofPathResult', { success: true, message: found });
} else {
event.sender.send('ofPathResult', {
success: false,
message: error.message
});
}
} else {
try {
// Assuming the JSON object is on the last line
Expand Down Expand Up @@ -1818,7 +1880,7 @@ ipcMain.on('getOFPath', (event) => {
});

ipcMain.on('getHostType', (event) => {
execFile(getPgPath(), ['-i'], { maxBuffer: Infinity }, (error, stdout, stderr) => {
execPG(['-i'], (error, stdout, stderr) => {
if (error) {
console.log( 'getHostType error' );
event.sender.send('ofPlatformResult', {
Expand Down Expand Up @@ -1851,7 +1913,7 @@ ipcMain.on('getHostType', (event) => {
});

ipcMain.on('getVersion', (event) => {
execFile(getPgPath(), ['-w'], { maxBuffer: Infinity }, (error, stdout, stderr) => {
execPG(['-w'], (error, stdout, stderr) => {
if (error) {
console.log( 'getVersion error' );
event.sender.send('ofVersionResult', {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "projectGenerator",
"productName": "projectGenerator",
"version": "0.96.0",
"version": "0.97.0",
"description": "Build electron GUI openFrameworks projectGenerator",
"license": "MIT",
"main": "index.js",
Expand Down
Loading