bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #21142] #192720 still not fixed in the current tree


From: Friedrich
Subject: [bug #21142] #192720 still not fixed in the current tree
Date: Mon, 24 Sep 2007 09:54:31 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1+lenny1)

Follow-up Comment #2, bug #21142 (project gnustep):

I'm a bit too short on time. Here's a suggested patch. It seems to make the
right thing but ProjectCenter crashes later (for unkown reasons) 

Problem it seems that the pathes where the generated files and are moving
constantly. So one has to patch run and debug also. I'm sorry but I can not
finish that currently. 

/* is this a good idea? 2007-09-24 11:03:12 frido */
- (NSString*)findExecutable
{
  NSFileManager *fm = [NSFileManager defaultManager];
  NSString *savedSubDir;
  NSString *tPath;
  NSString *execFileName;
  NSString *projectName = [project projectName];
  
  execFileName = [project projectName];
  if ( ! [fm isExecutableFileAtPath: execFileName])
    /* not in the current directory */
    {
      /* check the projectName.debug subdirectory */
      /* this is the path in debug builds has to be changed for release
builds .... */
      /* so in the end we have to check what kind of build we're running */
      execFileName = nil;
      execFileName = [projectName stringByAppendingPathExtension: @"debug"];
      savedSubDir = [NSString stringWithString: execFileName];
      execFileName = [execFileName stringByAppendingPathComponent:
projectName];
      
      if (! [fm isExecutableFileAtPath: execFileName])
        {
          /* no it's not there so go down another level */
          execFileName = savedSubDir;
          AUTORELEASE(savedSubDir);
          tPath = [projectName stringByAppendingPathExtension: @"build"];
          execFileName = [execFileName stringByAppendingPathComponent:
tPath];
          savedSubDir = [NSString stringWithString: execFileName];
          execFileName = [execFileName stringByAppendingPathComponent:
projectName];
          /* test again */
          if (! [fm isExecutableFileAtPath: execFileName]) 
            {
              /* well then try another subdirectory which currently seems to
be named obj,
                 I do not feel running behind this is a good idea. IMHO one
should save away the 
                 location of the executable to not need this kind of hack */
              execFileName = [savedSubDir
stringByAppendingPathComponent:@"obj"];
              execFileName = [execFileName
stringByAppendingPathComponent:projectName];
              /* now test again */
              if (! [fm isExecutableFileAtPath: execFileName])
                {
                  /* now we're giving up */
                  [NSException raise:@"No executable found" format:@""];
                } 

            } 
          
        }
    }
  if (NULL != savedSubDir) AUTORELEASE(savedSubDir);
  assert(NULL != execFileName);
  NSLog(execFileName);
  return [NSString stringWithString: execFileName];
}

I patched run: like this:
- (void)run:(id)sender
{
  NSMutableArray *args = [[NSMutableArray alloc] init];
  NSPipe         *logPipe;
  NSPipe         *errorPipe;
  NSString       *openPath;
  NSString       *exeFileName;

  // Check if project type is executable
  if ([project isExecutable])
    {
      openPath = [project execToolName];
      if ([openPath isEqualToString: @"openapp"])
        {
      exeFileName = [self findExecutable];
          /* openapp ./MyApplication.app */
          [args addObject: [NSString stringWithFormat: @"./%@", exeFileName]];
      AUTORELEASE(exeFileName);
        }
      else
        {
          /* opentool MyTool */
      exeFileName = [self findExecutable];
          [args addObject: exeFileName];
      AUTORELEASE(exeFileName);
            
        }
    }
  else 
    {
      NSRunAlertPanel(@"Run",
                      @"The project is not executable",
                      @"Close", nil, nil, nil);
      [runButton setState:NSOffState];
      return;
    }

  // [makeTask isRunning] doesn't work here.
  // "waitpid 7045, result -1, error No child processes" is printed.
  if (launchTask)
    {
      PCLogStatus(self, @"task will terminate");
      [launchTask terminate];
      return;
    }

  // Setting I/O
  logPipe = [NSPipe pipe];
  RELEASE(readHandle);
  readHandle = [[logPipe fileHandleForReading] retain];
  [stdOut setString:@""];
  [readHandle waitForDataInBackgroundAndNotify];

  [NOTIFICATION_CENTER addObserver:self 
                          selector:@selector(logStdOut:) 
                              name:NSFileHandleDataAvailableNotification
                            object:readHandle];

  errorPipe = [NSPipe pipe];
  RELEASE(errorReadHandle);
  errorReadHandle = [[errorPipe fileHandleForReading] retain];
  [stdOut setString:@""];
  [errorReadHandle waitForDataInBackgroundAndNotify];

  [NOTIFICATION_CENTER addObserver:self 
                          selector:@selector(logErrOut:) 
                              name:NSFileHandleDataAvailableNotification
                            object:errorReadHandle];

  // Launch task
  RELEASE(launchTask);
  launchTask = [[NSTask alloc] init];

  [NOTIFICATION_CENTER addObserver:self
                          selector:@selector(runDidTerminate:)
                              name:NSTaskDidTerminateNotification
                            object:launchTask];  
  [launchTask setArguments:args];  
  [launchTask setCurrentDirectoryPath:[project projectPath]];
  [launchTask setLaunchPath:openPath];
  [launchTask setStandardOutput:logPipe];
  [launchTask setStandardError:errorPipe];
  [launchTask launch];

  [debugButton setEnabled:NO];

  _isRunning = YES;
  RELEASE(args);
}


But left out the stuff in debug (around line 266)
  /* We try in the order:
   *  xxx.debug/xxx (gnustep-make v1, application),
   *  xxx.app/xxx (gnustep-make v1 and v2, application),
   *  obj/xxx (gnustep-make v1 and v2, tool).
   */
  fp = [project projectPath];
  fp = [fp stringByAppendingPathComponent: [projectName
stringByAppendingPathExtension: @"debug"]];
  fp = [fp stringByAppendingPathComponent: projectName];

  if (! [fm isExecutableFileAtPath: fp])
    {
      fp = [project projectPath];
      fp = [fp stringByAppendingPathComponent: [projectName
stringByAppendingPathExtension: @"app"]];
      fp = [fp stringByAppendingPathComponent: projectName];

      if (! [fm isExecutableFileAtPath: fp])
        {
          fp = [project projectPath];
          fp = [fp stringByAppendingPathComponent: @"obj"];
          fp = [fp stringByAppendingPathComponent: projectName];
        }
    }

This has to be changed also. My suggestion would be either using an own
function for that search or better IMHO. Storing the path to the outputted
files somewhere.

As said I'M short on time therefor this is just a hackerish try.

Regards
Friedrich


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?21142>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]