Browse Source

CLion: Launch the .app bundle from the Projucer on OSX to pass environment variables

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
5c49152d9d
2 changed files with 20 additions and 18 deletions
  1. +12
    -10
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CLion.h
  2. +8
    -8
      modules/juce_core/native/juce_mac_Files.mm

+ 12
- 10
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_CLion.h View File

@@ -117,14 +117,14 @@ public:
#endif
if (getProject().getExporters().getChildWithName (exporterName).isValid())
return getCLionExecutable().existsAsFile();
return getCLionExecutableOrApp().exists();
return false;
}
bool launchProject() override
{
return getCLionExecutable().startAsProcess (getTargetFolder().getFullPathName().quoted());
return getCLionExecutableOrApp().startAsProcess (getTargetFolder().getFullPathName().quoted());
}
String getDescription() override
@@ -224,19 +224,21 @@ public:
private:
//==============================================================================
static File getCLionExecutable()
static File getCLionExecutableOrApp()
{
File clionExe (getAppSettings()
.getStoredPath (Ids::clionExePath)
.toString()
.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()));
File clionExeOrApp (getAppSettings()
.getStoredPath (Ids::clionExePath)
.toString()
.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()));
#if JUCE_MAC
if (clionExe.getFileName().endsWith (".app"))
clionExe = clionExe.getChildFile ("Contents/MacOS/clion");
if (clionExeOrApp.getFullPathName().endsWith ("/Contents/MacOS/clion"))
clionExeOrApp = clionExeOrApp.getParentDirectory()
.getParentDirectory()
.getParentDirectory();
#endif
return clionExe;
return clionExeOrApp;
}
//==============================================================================


+ 8
- 8
modules/juce_core/native/juce_mac_Files.mm View File

@@ -105,12 +105,12 @@ namespace MacFileHelpers
#else
static bool launchExecutable (const String& pathAndArguments)
{
const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), 0 };
const int cpid = fork();
if (cpid == 0)
{
const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), 0 };
// Child process
if (execve (argv[0], (char**) argv, 0) < 0)
exit (0);
@@ -412,10 +412,8 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String&
JUCE_AUTORELEASEPOOL
{
NSString* fileNameAsNS (juceStringToNS (fileName));
NSURL* filenameAsURL ([NSURL URLWithString: fileNameAsNS]);
if (filenameAsURL == nil)
filenameAsURL = [NSURL fileURLWithPath: fileNameAsNS];
NSURL* filenameAsURL = File (fileName).exists() ? [NSURL fileURLWithPath: fileNameAsNS]
: [NSURL URLWithString: fileNameAsNS];
#if JUCE_IOS
ignoreUnused (parameters);
@@ -442,11 +440,13 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String&
StringArray params;
params.addTokens (parameters, true);
NSMutableArray* paramArray = [[[NSMutableArray alloc] init] autorelease];
NSMutableDictionary* dict = [[NSMutableDictionary new] autorelease];
NSMutableArray* paramArray = [[NSMutableArray new] autorelease];
for (int i = 0; i < params.size(); ++i)
[paramArray addObject: juceStringToNS (params[i])];
NSMutableDictionary* dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setObject: paramArray
forKey: nsStringLiteral ("NSWorkspaceLaunchConfigurationArguments")];


Loading…
Cancel
Save