Code: Select all
#ProgramVersion$ = "0." + #PB_Editor_BuildCount + "." + #PB_Editor_CompileCount
Code: Select all
EnableExplicit
; Error with external compiler use.....
;#ProgramVersion$ = "0." + #PB_Editor_BuildCount + "." + #PB_Editor_CompileCount
;
#ProgramVersion$ = "0.0" ;+ #PB_Editor_BuildCount + "." + #PB_Editor_CompileCount
#ProgramCaption$ = "Compiler Test "
; Debug #PB_Editor_CreateExecutable ; <= not working with Debugger On
; ---
Global PureBasicHome$, WorkDir$, InputFile$, OutputFile$
CompilerIf #PB_Compiler_Debugger
PureBasicHome$ = #PB_Compiler_Home
InputFile$ = #PB_Compiler_File
CompilerElse
PureBasicHome$ = GetEnvironmentVariable("PUREBASIC_HOME")
InputFile$ = ProgramParameter()
CompilerEndIf
; ---
Procedure Add(Message$)
AddGadgetItem (0, -1, Message$)
; SetGadgetState(0, CountGadgetItems(0)-1)
EndProcedure
; ---
Procedure RunCompiler(Command$)
Protected ec, Compiler
If Not Asc(Command$) : Command$ = "-h" : EndIf
Compiler = RunProgram(#PB_Compiler_Home+"compilers/pbcompiler", Command$, WorkDir$, #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
Add("Run with Command: " + Command$ + "")
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
Add(ReadProgramString(Compiler))
EndIf
Wend
ec = ProgramExitCode(Compiler)
Add("")
Add("Exitcode: " + Str(ec))
CloseProgram(Compiler)
EndIf
EndProcedure
; ---
Procedure Main()
Protected res$, opt$
If OpenWindow(0, 0, 0, 808, 248, #ProgramCaption$, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 4, 4, 800, 240)
; init .....
;
WorkDir$ = GetPathPart(InputFile$)
OutputFile$ = WorkDir$ + "PureBasic_MyApp.exe" ; this is waht I want
If FileSize(InputFile$) < 0 : res$ = "not " : EndIf
Add("InputFile " + #DQUOTE$ + InputFile$ + #DQUOTE$ + " is " + res$ + "existing.")
If FileSize(OutputFile$) < 0 : res$ = "not " : EndIf
Add("OutputFile " + #DQUOTE$ + OutputFile$ + #DQUOTE$ + " is " + res$ + "existing.")
If FileSize(OutputFile$) > -1 And Not DeleteFile(OutputFile$, #PB_FileSystem_Force)
Add(" Cannot delete OutputFile " + #DQUOTE$ + OutputFile$ + #DQUOTE$)
EndIf
Add("Run Compiler .....")
opt$ = "-d " ; debugger on
RunCompiler(opt$ + #DQUOTE$ + InputFile$ + #DQUOTE$ + " -o " + #DQUOTE$ + OutputFile$ + #DQUOTE$)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CloseWindow(0) ; we are done...
EndIf
; Clean up, because this is only a compile test. Don't leave any trash behind.
;
If FileSize(OutputFile$) > 0
If MessageRequester(#ProgramCaption$ + "Info", "OutputFile found:" + #LF$ + OutputFile$ + #LF$ + "Delete it now?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
DeleteFile(OutputFile$, #PB_FileSystem_Force)
EndIf
Else
MessageRequester(#ProgramCaption$ + "Error", "OutputFile not found:" + #LF$ + OutputFile$ + #LF$ + "Probably the source contains errors.")
EndIf
ProcedureReturn 0
EndProcedure
End Main()