Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Strict
- Local bmaxpath:String = BlitzMaxPath()+"\"
- Local source:String
- If AppArgs.length > 1
- source = AppArgs[1]
- Else
- End
- End If
- If FileType(bmaxpath+"bin\bmk.exe") <> 1
- Print "Invalid bmax root path"
- End
- EndIf
- source = RealPath(source)
- If FileType(source) <> 1
- Print "Can't find bmax source file"
- End
- EndIf
- Local sourcepath:String = ExtractDir(source)
- If Not(Right(sourcepath,1)="/") Then sourcepath :+ "\"
- Local sourcename:String = StripExt(StripDir(source))
- If FileType(sourcepath+sourcename+".exe") = 1
- DeleteFile(sourcepath+sourcename+".exe")
- End If
- If FileType(sourcepath+sourcename+".dll") = 1
- DeleteFile(sourcepath+sourcename+".dll")
- End If
- system_(bmaxpath+"bin\bmk.exe makeapp -r -d -t console ~q"+source+"~q")
- Print "Parsing sourcefile..."
- Local sfile:TStream = ReadFile(source)
- Local dfile:TStream = WriteFile(sourcepath+"makedll.def")
- WriteLine dfile,"EXPORTS"
- Local tmpline:String = sfile.ReadLine()
- Local indx:Int
- Print "Exported functions:"
- While Not sfile.Eof()
- If tmpline.Find("Function") > -1 And tmpline.Find("'EXPORT") > -1 Then
- Local expfunc$
- indx = tmpline.Find("Function")+10
- While Mid(tmpline,indx,1)<>"(" And Mid(tmpline,indx,1)<>":"
- expfunc :+ Mid(tmpline,indx,1)
- indx :+ 1
- Wend
- Print " "+expfunc
- WriteLine dfile, Chr(9)+expfunc + " = bb_" + expfunc
- ElseIf tmpline.Find("'FUNC") > -1 Then
- Local expfunc$
- indx = tmpline.Find("'FUNC")+7
- expfunc = Mid(tmpline, indx)
- Print " "+expfunc
- WriteLine dfile, Chr(9)+expfunc + " = bb_" + expfunc
- EndIf
- tmpline = sfile.ReadLine()
- Wend
- CloseStream(dfile)
- CloseStream(sfile)
- system_(bmaxpath+"bin\ld.exe --dll -o ~q"+sourcepath+sourcename+".dll~q -L ~q"+bmaxpath+"lib~q -e _bb_DllMain ~q"+sourcepath+"makedll.def~q ~q"+bmaxpath+"tmp\ld.tmp~q")
- If FileType(sourcepath+sourcename+".dll") <> 1
- Print "Creation of "+sourcename+".dll failed"
- Else
- Print "Creation of "+sourcename+".dll successful"
- End If
- If FileType(sourcepath+sourcename+".exe") = 1
- DeleteFile(sourcepath+sourcename+".exe")
- End If
- If FileType(sourcepath+"makedll.def") = 1
- DeleteFile(sourcepath+"makedll.def")
- EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement