Remember when I've said that I use a customized version of lexvictory IDE Tool to compile 32bit code from 64bit IDE Toolbar and vice versa. Source code be at the bottom.
Edit PBx64_LOCATION and PBx86_LOCATION variables with your information.
PBx64_LOCATION = \64\
PBx86_LOCATION = \86\
... based on your PB paths being C:\pb\542lts\32\ and C:\pb\542lts\64\
Create just the x86 executable, name it whatever you want. However I'll refer to it as CompilerCounterPart.exe.
Create new x86 IDE Tool.
- - commandline: field;
- "[Where_Ever_You_CreatedOrMovied_It_To]\CompilerCounterPart.exe" "/x64"
- Arguments: field;
- "/FILE:%FILE" "/TEMPFILE:%TEMPFILE"
- Name: field;
- Event to trigger the tool: drop-list;
.. save
In PB x86 Preferences, under General \ Toolbar \, and add the above tool.
Create new x64 IDE Tool.
- - commandline: field;
- "[Where_Ever_You_CreatedOrMovied_It_To]\CompilerCounterPart.exe" "/x86"
- Arguments: field;
- "/FILE:%FILE" "/TEMPFILE:%TEMPFILE"
- Name: field;
- Event to trigger the tool: drop-list;
.. save
In PB x64 Preferences, under General \ Toolbar \, and add the above tool.
Code: Select all
;Create an IDE tool with the arguments set to the following:
; "/FILE:%FILE" "/TEMPFILE:%TEMPFILE"
;You can also create another tool and add /EXE to the command arguments to create an exe/dll (you have to add .dll to the SaveFileRequester file field manually)
Global.s Purebasic_Path, PBx64_LOCATION, PBx86_LOCATION
PBx64_LOCATION = "\Program Files\"
PBx86_LOCATION = "\Program Files (x86)\"
#PROCESS_NAME_NATIVE = 1
Prototype.i QueryFullProcessImageName(hProcess, dwFlags, lpExeName, lpdwSize)
;Returns non-zero if success.
Procedure.i GetParentProcess(hwnd.l)
Protected result, hwndp.l, pid.l, snap.i, pinfo.PROCESSENTRY32
Protected buffer$, bufferSize, hProcess, libID, QueryFullProcessImageName.QueryFullProcessImageName
GetWindowThreadProcessId_(hwnd, @pid)
snap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS,0)
If snap
pinfo\dwSize=SizeOf(PROCESSENTRY32);
result = Process32First_(snap, @pinfo)
While result
If pid = pinfo\th32ProcessID
hProcess = OpenProcess_(#PROCESS_QUERY_INFORMATION, 0, pinfo\th32ParentProcessID)
If hProcess
libID = OpenLibrary(#PB_Any, "kernel32.dll")
If libID
bufferSize = 1024
buffer$ = Space(bufferSize)
QueryFullProcessImageName = GetFunction(libID, "QueryFullProcessImageNameA")
If QueryFullProcessImageName
result = QueryFullProcessImageName(hProcess, 0, @buffer$, @bufferSize)
Purebasic_Path = GetPathPart(buffer$)
EndIf
CloseLibrary(libID)
EndIf
CloseHandle_(hProcess)
EndIf
Break
EndIf
result = Process32Next_(snap, @pinfo)
Wend
CloseHandle_(snap)
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,0,0,"proc",#PB_Window_Invisible)
GetParentProcess(WindowID(0))
#windowwidth = 550
#windowheight = 250
#dontcloseonOKcompile = 1
#droopyslibisinstalled = 0
Procedure Error(error.s)
MessageRequester("Error", error, #MB_ICONERROR)
EndProcedure
CompilerIf #droopyslibisinstalled = 0
Procedure WaitUntilWindowIsClosed()
Repeat
Until WaitWindowEvent()= #PB_Event_CloseWindow
ProcedureReturn 1
EndProcedure
Procedure.s GetTempDirectory() ; Return the temp directory
Protected WinTemp.s
WinTemp = Space(255)
GetTempPath_(255, WinTemp)
If Right(WinTemp, 1) <> "\" : WinTemp = WinTemp + "\" : EndIf
ProcedureReturn WinTemp
EndProcedure
CompilerEndIf
Debugger = Val(GetEnvironmentVariable("PB_TOOL_Debugger"))
inlineasm = Val(GetEnvironmentVariable("PB_TOOL_InlineASM"))
unicode = Val(GetEnvironmentVariable("PB_TOOL_Unicode"))
threadsafe = Val(GetEnvironmentVariable("PB_TOOL_Thread"))
xpskin = Val(GetEnvironmentVariable("PB_TOOL_XPSkin"))
onerror = Val(GetEnvironmentVariable("PB_TOOL_OnError"))
subsys.s = Trim(GetEnvironmentVariable("PB_TOOL_SubSystem"))
theexe.s = GetEnvironmentVariable("PB_TOOL_Executable")
;EnableExplicit
Define compileroptions.s = "",x.i, progparam.s,properfile.s,tempfile.s
If debugger : compileroptions+"/DEBUGGER " : EndIf
If inlineasm : compileroptions+"/INLINEASM " : EndIf
If unicode : compileroptions+"/UNICODE " : EndIf
If threadsafe : compileroptions+"/THREAD " : EndIf
If xpskin : compileroptions+"/XP " : EndIf
If onerror : compileroptions+"/LINENUMBERING " : EndIf
If subsys <> "" : compileroptions+"/SUBSYSTEM "+Chr(34)+subsys+Chr(34)+" " : EndIf
For x = 0 To CountProgramParameters()-1
progparam = ProgramParameter(x)
If FindString(UCase(progparam), "/FILE:", 0)
properfile = RemoveString(progparam,"/FILE:",#PB_String_NoCase)
ElseIf FindString(progparam, "/x64", 0)
Purebasic_Path = ReplaceString(Purebasic_Path, PBx86_LOCATION, PBx64_LOCATION)
ElseIf FindString(progparam, "/x86", 0)
Purebasic_Path = ReplaceString(Purebasic_Path, PBx64_LOCATION, PBx86_LOCATION)
ElseIf FindString(UCase(progparam), "/TEMPFILE:", 0)
tempfile = RemoveString(progparam,"/TEMPFILE:",#PB_String_NoCase)
ElseIf FindString(UCase(progparam), "/EXE", 0)
makeexe.s = SaveFileRequester("Create cross compiled exe", theexe, "*.exe,*.dll|*.exe;*.dll", 0)
If makeexe
If (LCase(Right(makeexe, 4)) <> ".exe") And (LCase(Right(makeexe, 4)) <> ".dll")
makeexe+".exe"
EndIf
compileroptions+"/EXE "+Chr(34)+makeexe+Chr(34)+" "
If LCase(Right(makeexe, 4)) = ".dll"
compileroptions+"/DLL "
EndIf
disablethedebugger = 1
Else
End
EndIf
Else
compileroptions+progparam+" "
EndIf
Next x
OpenWindow(0,0,0,#windowwidth,#windowheight,"PB compiler output", #PB_Window_SystemMenu)
ListViewGadget(0,0,0,#windowwidth,#windowheight)
AddGadgetItem(0,-1, "Compiler Options:")
AddGadgetItem(0,-1, compileroptions)
If properfile <> ""
compileroptions+Chr(34)+properfile+Chr(34)
ElseIf tempfile <> ""
compileroptions+Chr(34)+tempfile+Chr(34)
SetCurrentDirectory(GetTempDirectory())
Else
Error("You need to specify a file (with /FILE:) or a temp file (with /TEMPFILE:)")
End
EndIf
If disablethedebugger : compileroptions=RemoveString(compileroptions, "/DEBUGGER ") : EndIf ;for compiling as exe
wasanerror = 0
prog = RunProgram(Purebasic_Path+"\compilers\PBCompiler.exe", compileroptions, GetCurrentDirectory(), #PB_Program_Open|#PB_Program_Read|#PB_Program_Error|#PB_Program_Hide)
If prog
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
progoutput.s = ReadProgramString(prog)
If FindString(LCase(progoutput), "error",0)
wasanerror = 1
Error(progoutput)
SetForegroundWindow_(WindowID(0))
EndIf
AddGadgetItem(0,-1, progoutput)
Else
WaitWindowEvent(0)
EndIf
Wend
CloseProgram(prog)
AddGadgetItem(0,-1, "Compiler Closed")
Else
Error("Could Not execute PB compiler")
EndIf
CompilerIf #dontcloseonOKcompile = 1
WaitUntilWindowIsClosed()
CompilerElse
If wasanerror
WaitUntilWindowIsClosed()
EndIf
CompilerEndIf