
Mais si tu préfères, on peut finaliser la première version pour moebius pour windows et on verra aprés celle pour linux

Code : Tout sélectionner
svn checkout http://moebius-pb.googlecode.com/svn/trunk/ moebius-pb-read-only
Code : Tout sélectionner
Global gConf_PureBasic_Path.s = #PB_Compiler_Home
Global gConf_Path_PBCOMPILER.s = #PB_Compiler_Home + "compilers\pbcompiler.exe"
Global gConf_Path_FASM.s = #PB_Compiler_Home + "compilers\fasm.exe"
Global gConf_Path_OBJ2LIB.s = #PB_Compiler_Home + "compilers\polib.exe"
Global gConf_Path_PBLIBMAKER.s = #PB_Compiler_Home + "Library SDK\LibraryMaker.exe"
Code : Tout sélectionner
;{ Create ASM Files
Protected lFile.l
ForEach LL_DLLFunctions()
lFile = CreateFile(#PB_Any, gConf_ProjectDir + "ASM" + #System_Separator + LL_DLLFunctions()\FuncName + ".asm")
Code : Tout sélectionner
Procedure.l CreateAsmFile(FichierPureBasic$)
; Retourne #true si le fichier asm a correctement été créé sinon retourne une valeur négative
; qui dépend du lieu de l'erreur, permet de trouver rapidement ou se situe l'erreur
Protected extension$ = LCase(GetExtensionPart(FichierPureBasic$))
; mémorise le nom du fichier asm avec le chemein complet
Protected FichierAsm$ = ""
; mémorise le nom du fichier exe, mais en fait la variable est vide
Protected FichierExe$ = ""
; mémorise le chemin et le nom du fichier asm initial créé par PB
Protected FichierInitialAsm$ = ""
; mémorise la chaine retournée par le compilateur lors de la création du fichier asm
Protected Sortie$ = ""
; mémorise le résultat de la fonction Runprogram
Protected Compilateur
; on teste si le fichier se fini par "pb ou pbi"
; si oui on continue sinon on retourrne #False
Select extension$
Case "pb"
FichierAsm$ + Mid(GetFilePart(FichierPureBasic$), 1, Len(GetFilePart(FichierPureBasic$))-2) + "asm"
; on fixe le nom du fiche executable
FichierExe$ + Mid(GetFilePart(FichierPureBasic$), 1, Len(GetFilePart(FichierPureBasic$))-2) + "exe"
Case "pbi"
FichierAsm$ + Mid(GetFilePart(FichierPureBasic$), 1, Len(GetFilePart(FichierPureBasic$))-3) + "asm"
; on fixe le nom du fiche executable
FichierExe$ + Mid(GetFilePart(FichierPureBasic$), 1, Len(GetFilePart(FichierPureBasic$))-3) + "exe"
Default
; ce n'est pas un fichier PB, on quitte
ProcedureReturn -1
EndSelect
; le fichier asm Prebasic.asm est créé dans le dossier de l'éxécutable qui le crée
FichierInitialAsm$ = GetCurrentDirectory() + "PureBasic.asm"
; on efface le fichier asm qui existerait éventuellement sous le même nom et sous le nom PureBasic.asm
; on efface éventuellement le fichier asm plus ancien
SetFileAttributes(FichierAsm$, #PB_FileSystem_Normal)
DeleteFile(FichierAsm$)
; on efface éventuellement le fichier Pb asm
SetFileAttributes(FichierAsm$, #PB_FileSystem_Normal)
DeleteFile(FichierInitialAsm$)
Compilateur = RunProgram(#PB_Compiler_Home + "\Compilers\pbcompiler", Chr(34) + FichierPureBasic$ + Chr(34) + " /INLINEASM /COMMENTED /EXE " + Chr(34) + FichierExe$ + Chr(34) , "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
If Compilateur
While ProgramRunning(Compilateur)
Sortie$ + ReadProgramString(Compilateur) + Chr(13)
Wend
EndIf
If ProgramExitCode(Compilateur) = 0
MessageRequester("", Sortie$, 16)
; on teste si le résultat est Ok
; la dernière ligne retournée vaut
; "- Feel the ..PuRe.. Power -"
; If FindString(Sortie$, "- Feel the ..PuRe.. Power -", Len(Sortie$)-28)
If FindString(Sortie$, "- Feel the ..PuRe.. Power -", 0)
; on efface le fichier executable créé
DeleteFile(FichierExe$)
; on renomme le fichier asm PureBasic.asm avec le nouveau nom
If RenameFile(FichierInitialAsm$, FichierAsm$)
ProcedureReturn #True
Else
ProcedureReturn -1
EndIf
Else
; on efface le fichier executable créé
DeleteFile(FichierExe$)
ProcedureReturn -2
EndIf
Else
; on efface le fichier executable créé
DeleteFile(FichierExe$)
ProcedureReturn -3
EndIf
EndProcedure
Code : Tout sélectionner
; donne le bon chemin au fichier asm
FichierAsm$ = GetPathPart(FichierPureBasic$) + FichierAsm$
Code : Tout sélectionner
*MemLib_Header = AllocateMemory(LibSize)
Code : Tout sélectionner
Procedure PB_GetInfoLib(FileName.s)
Protected LibName.s = GetFilePart(FileName)
Protected hFile = ReadFile(#PB_Any, FileName)
Protected Ndx.l
Protected Filesize.q = FileSize(FileName)
Debug FileName
If hFile
If Filesize>0
Ndx = 2
While ((Ndx>0) And ((Loc(hFile) + 1)<Lof(hFile)))
If ReadByte(hFile) = 0
Ndx-1
EndIf
Wend
If (Loc(hFile)<(Lof(hFile)-2))
FileSeek(hFile, Loc(hFile) + 2)
EndIf
While Eof(hFile) = 0
If AddElement(LL_PBFunctions())
LL_PBFunctions()\FuncName = ReadString(hFile)
; Debug LL_PBFunctions()\FuncName
LL_PBFunctions()\LibContaining = LibName
If (Loc(hFile)<(Lof(hFile)-2))
FileSeek(hFile, Loc(hFile) + 2)
Else
; erreur
CloseFile(hFile)
ProcedureReturn -1 ; erreur sur le déplacement dans le fichier
EndIf
Else
; erreur
CloseFile(hFile)
ProcedureReturn -1 ; erreur sur Addelement
EndIf
Wend
CloseFile(hFile)
Else
CloseFile(hFile)
ProcedureReturn -1 ; erreur sur le fichier (taille ou inexsistant)
EndIf
Else
ProcedureReturn -1 ; erreur sur l'ouverture du fichier
EndIf
EndProcedure
Code : Tout sélectionner
CompilerIf #PB_Compiler_Version<430
; Type of the Return Value
If Mid(LL_DLLFunctions()\FuncName, Len(LL_DLLFunctions()\FuncName)-1, 1) = "."
Select Mid(LL_DLLFunctions()\FuncName, Len(LL_DLLFunctions()\FuncName), 1)
Case "b" : LL_DLLFunctions()\FuncRetType = "Byte"
Case "c" : LL_DLLFunctions()\FuncRetType = "Character"
Case "d" : LL_DLLFunctions()\FuncRetType = "Double"
Case "f" : LL_DLLFunctions()\FuncRetType = "Float"
Case "q" : LL_DLLFunctions()\FuncRetType = "Quad"
Case "s" : LL_DLLFunctions()\FuncRetType = "String"
Case "w" : LL_DLLFunctions()\FuncRetType = "Word"
Default : LL_DLLFunctions()\FuncRetType = "Long"
EndSelect
Else
LL_DLLFunctions()\FuncRetType = "Long"
EndIf
; Type of Parameters
For IncA = 1 To CountString(LL_DLLFunctions()\Params, ",") + 1
Select Right(Trim(StringField(LL_DLLFunctions()\Params, IncA, ",")), 1)
Case "b" : LL_DLLFunctions()\ParamsRetType + ", Byte"
Case "c" : LL_DLLFunctions()\ParamsRetType + ", Character"
Case "d" : LL_DLLFunctions()\ParamsRetType + ", Double"
Case "f" : LL_DLLFunctions()\ParamsRetType + ", Float"
Case "q" : LL_DLLFunctions()\ParamsRetType + ", Quad"
Case "s" : LL_DLLFunctions()\ParamsRetType + ", String"
Case "w" : LL_DLLFunctions()\ParamsRetType + ", Word"
Default : LL_DLLFunctions()\ParamsRetType + ", Long"
EndSelect
Next
CompilerElse
; Type of the Return Value
If Mid(LL_DLLFunctions()\FuncName, Len(LL_DLLFunctions()\FuncName)-1, 1) = "."
Select Mid(LL_DLLFunctions()\FuncName, Len(LL_DLLFunctions()\FuncName), 1)
Case "b" : LL_DLLFunctions()\FuncRetType = "Byte"
Case "c" : LL_DLLFunctions()\FuncRetType = "Character"
Case "d" : LL_DLLFunctions()\FuncRetType = "Double"
Case "f" : LL_DLLFunctions()\FuncRetType = "Float"
Case "l" : LL_DLLFunctions()\FuncRetType = "Long"
Case "q" : LL_DLLFunctions()\FuncRetType = "Quad"
Case "s" : LL_DLLFunctions()\FuncRetType = "String"
Case "w" : LL_DLLFunctions()\FuncRetType = "Word"
Default : LL_DLLFunctions()\FuncRetType = "Integer"
EndSelect
Else
LL_DLLFunctions()\FuncRetType = "Integer"
EndIf
; Type of Parameters
For IncA = 1 To CountString(LL_DLLFunctions()\Params, ",") + 1
Select Right(Trim(StringField(LL_DLLFunctions()\Params, IncA, ",")), 1)
Case "b" : LL_DLLFunctions()\ParamsRetType + ", Byte"
Case "c" : LL_DLLFunctions()\ParamsRetType + ", Character"
Case "d" : LL_DLLFunctions()\ParamsRetType + ", Double"
Case "f" : LL_DLLFunctions()\ParamsRetType + ", Float"
Case "l" : LL_DLLFunctions()\ParamsRetType + ", Long"
Case "q" : LL_DLLFunctions()\ParamsRetType + ", Quad"
Case "s" : LL_DLLFunctions()\ParamsRetType + ", String"
Case "w" : LL_DLLFunctions()\ParamsRetType + ", Word"
Default : LL_DLLFunctions()\ParamsRetType + ", Integer"
EndSelect
Next
CompilerEndIf
Code : Tout sélectionner
LL_DLLFunctions()\FuncName = StringField(TrCodeField, 1, " ")
Code : Tout sélectionner
LL_DLLFunctions()\FuncName = StringField(TrCodeField, 2, " ")