diff --git a/src/u_ceproject.pas b/src/u_ceproject.pas index 30fd9162..76b0a65c 100644 --- a/src/u_ceproject.pas +++ b/src/u_ceproject.pas @@ -33,7 +33,6 @@ type fModified: boolean; fRootFolder: string; fBasePath: string; - fRunnerOldCwd: string; fVersion: string; fLibAliases: TStringList; fAutoDeps: boolean; @@ -157,24 +156,20 @@ begin fAsProjectItf := self as ICommonProject; fSymStringExpander := getSymStringExpander; fMsgs:= getMessageDisplay; - // - fRunnerOldCwd := GetCurrentDirUTF8; fProjectSubject := TProjectSubject.create; - // fLibAliases := TStringList.Create; fSrcs := TStringList.Create; fSrcs.OnChange := @subMemberChanged; fConfigs := TCollection.create(TCompilerConfiguration); - // reset; addDefaults; subjProjNew(fProjectSubject, self); subjProjChanged(fProjectSubject, self); - // + {$IFNDEF WINDOWS} fBasePath := '/'; {$ENDIF} - // + fModified := false; end; @@ -873,14 +868,10 @@ end; procedure TNativeProject.run(const runArgs: string = ''); var - prm: string; - i: Integer; - cwd: string; + p: string; + i: integer; begin killProcess(fRunner); - if fRunnerOldCwd.dirExists then - ChDir(fRunnerOldCwd); - // fRunner := TDexedProcess.Create(nil); fRunner.XTermProgram:=consoleProgram; currentConfiguration.runOptions.setProcess(fRunner); @@ -888,29 +879,24 @@ begin begin i := 1; repeat - prm := ExtractDelimited(i, runArgs, [' ']); - prm := fSymStringExpander.expand(prm); - if prm.isNotEmpty then - fRunner.Parameters.AddText(prm); + p := ExtractDelimited(i, runArgs, [' ']); + p := fSymStringExpander.expand(p); + if p.isNotEmpty then + fRunner.Parameters.AddText(p); Inc(i); - until prm = ''; + until p = ''; end; - // + if not outputFilename.fileExists then begin fMsgs.message('output executable missing: ' + shortenPath(outputFilename, 25), fAsProjectItf, amcProj, amkErr); exit; end; - // + fRunner.Executable := outputFilename; - fRunnerOldCwd := GetCurrentDirUTF8; if fRunner.CurrentDirectory.isEmpty then - begin - cwd := fRunner.Executable.extractFilePath; - SetCurrentDirUTF8(cwd); - fRunner.CurrentDirectory := cwd; - end; + fRunner.CurrentDirectory := fRunner.Executable.extractFilePath; if poUsePipes in fRunner.Options then begin fRunner.OnReadData := @runProcOutput; @@ -938,16 +924,13 @@ begin finally lst.Free; end; - // + proc := TProcess(sender); if not proc.Running then begin getprocInputHandler.removeProcess(TProcess(sender)); - SetCurrentDirUTF8(fRunnerOldCwd); - if proc is TDexedProcess then dproc := TDexedProcess(proc); - if (proc.ExitStatus <> 0) then begin fMsgs.message(format('error: the process (%s) has returned the status %s', diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index 1faab037..1d969a22 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -114,7 +114,6 @@ type fInGroup: boolean; fHasLoaded: boolean; fDubProc: TDexedProcess; - fPreCompilePath: string; fPackageName: string; fFilename: string; fModified: boolean; @@ -1082,12 +1081,10 @@ begin [fDubProc.autoKillProcThreshold]), nil, amcProj, amkWarn); end; subjProjCompiled(fProjectSubject, fAsProjectItf, fCompiled); - SetCurrentDirUTF8(fPreCompilePath); end; procedure TDubProject.executeDub(command: TDubCommand; const runArgs: string = ''); var - olddir: string; prjname: string; rargs: TStringList; begin @@ -1108,56 +1105,49 @@ begin fMsgs.clearByData(fAsProjectItf); prjname := shortenPath(fFilename); fDubProc:= TDexedProcess.Create(nil); - olddir := GetCurrentDir; - try - subjProjCompiling(fProjectSubject, fAsProjectItf); - fMsgs.message(dubCmd2PreMsg[command] + prjname, fAsProjectItf, amcProj, amkInf); - if modified then - saveToFile(fFilename); - chDir(fFilename.extractFilePath); - fDubProc.Executable := 'dub' + exeExt; - if not dubBuildOptions.showConsole then - begin - fDubProc.Options := fDubProc.Options + [poStderrToOutPut, poUsePipes]; - fDubProc.OnReadData:= @dubProcOutput; - fDubProc.ShowWindow := swoHIDE; - end - else - begin - fDubProc.Options := fDubProc.Options + [poWaitOnExit, poNewConsole]; - end; - fDubProc.CurrentDirectory := fFilename.extractFilePath; - fDubProc.XTermProgram:=consoleProgram; - fDubProc.Parameters.Add(dubCmd2Arg[command]); - fDubProc.OnTerminate:= @dubProcTerminated; - if (command <> dcTest) or not dubBuildOptions.autoSelectTestConfig then - begin - fDubProc.Parameters.Add('--build=' + fBuildTypes[fBuiltTypeIx]); - if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then - fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]); - end; - fDubProc.Parameters.Add('--compiler=' + DubCompilerFilename); - dubBuildOptions.getOpts(fDubProc.Parameters); - if (command <> dcBuild) and runArgs.isNotEmpty then - begin - fDubProc.Parameters.Add('--'); - rargs := TStringList.Create; - try - CommandToList(runArgs, rargs); - fDubProc.Parameters.AddStrings(rargs); - finally - rargs.Free; - end; - end; - fDubProc.Execute; - finally - SetCurrentDirUTF8(olddir); + subjProjCompiling(fProjectSubject, fAsProjectItf); + fMsgs.message(dubCmd2PreMsg[command] + prjname, fAsProjectItf, amcProj, amkInf); + if modified then + saveToFile(fFilename); + fDubProc.Executable := 'dub' + exeExt; + if not dubBuildOptions.showConsole then + begin + fDubProc.Options := fDubProc.Options + [poStderrToOutPut, poUsePipes]; + fDubProc.OnReadData:= @dubProcOutput; + fDubProc.ShowWindow := swoHIDE; + end + else + begin + fDubProc.Options := fDubProc.Options + [poWaitOnExit, poNewConsole]; end; + fDubProc.CurrentDirectory := fFilename.extractFilePath; + fDubProc.XTermProgram:=consoleProgram; + fDubProc.Parameters.Add(dubCmd2Arg[command]); + fDubProc.OnTerminate:= @dubProcTerminated; + if (command <> dcTest) or not dubBuildOptions.autoSelectTestConfig then + begin + fDubProc.Parameters.Add('--build=' + fBuildTypes[fBuiltTypeIx]); + if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then + fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]); + end; + fDubProc.Parameters.Add('--compiler=' + DubCompilerFilename); + dubBuildOptions.getOpts(fDubProc.Parameters); + if (command <> dcBuild) and runArgs.isNotEmpty then + begin + fDubProc.Parameters.Add('--'); + rargs := TStringList.Create; + try + CommandToList(runArgs, rargs); + fDubProc.Parameters.AddStrings(rargs); + finally + rargs.Free; + end; + end; + fDubProc.Execute; end; procedure TDubProject.compile; begin - fPreCompilePath := GetCurrentDirUTF8; executeDub(dcBuild); end; @@ -1716,14 +1706,11 @@ var str: TStringList; jsn: TJSONData; prs: TJSONParser; - old: string; begin result := nil; dub := TProcess.Create(nil); str := TStringList.Create; - old := GetCurrentDirUTF8; try - SetCurrentDirUTF8(filename.extractFilePath); dub.Executable := 'dub' + exeExt; dub.Options := [poUsePipes{$IFDEF WINDOWS}, poNewConsole{$ENDIF}]; dub.ShowWindow := swoHIDE; @@ -1754,7 +1741,6 @@ begin result := nil; end; finally - SetCurrentDirUTF8(old); dub.free; str.Free; end; diff --git a/src/u_tools.pas b/src/u_tools.pas index 0c869c29..eed33bf0 100644 --- a/src/u_tools.pas +++ b/src/u_tools.pas @@ -186,7 +186,6 @@ var arg: string; prm: string; inp: string; - old: string; const confSpec = 'Are you sure you want to execute the "%s" tool ?'; begin @@ -203,7 +202,6 @@ begin if askConfirmation and (dlgOkCancel(format(confSpec, [toolAlias])) <> mrOk) then exit; - old := GetCurrentDirUTF8; fProcess := TDexedProcess.Create(nil); fProcess.OnReadData:= @processOutput; fProcess.OnTerminate:= @processOutput; @@ -228,7 +226,7 @@ begin end; end; ensureNoPipeIfWait(fProcess); - // + if fProcess.Executable.fileExists then begin fProcess.Execute; @@ -242,8 +240,6 @@ begin fProcess.CloseInput; end; end; - // - SetCurrentDirUTF8(old); end; procedure TToolItem.processOutput(sender: TObject);