@@ -0,0 +1,124 @@
Rem
Love Builder
global declarations
(c) Jeroen P. Broks, 2016, All rights reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Exceptions to the standard GNU license are available with Jeroen's written permission given prior
to the project the exceptions are needed for.
Version: 16.03.26
End Rem
MKL_Version "Love Builder - globals.bmx","16.03.26"
MKL_Lic "Love Builder - globals.bmx","GNU General Public License 3"

?Win32
Const platform$ = "windows"
?MacOS
Const platform$ = "mac"
?linux
Const platform$ = "linux"
?
Const ginifile$ = "BuildLove."+platform+".ini"
Global pinifile$

Global file$
Global gini:TIni = New TIni ' Global ini
Global pini:TIni = New TIni ' Project ini

Global Project:TJCRDir = New TJCRDir

Global JWIN32:TJCRDir = JCR_Dir("incbin::Win32.jcr")
Global JWIN64:TJCRDir = JCR_Dir("incbin::Win32.jcr")
Global JMac64:TJCRDir = JCR_Dir("incbin::Win32.jcr")

Global WorkDir$ = Dirry("$AppSupport$/$LinuxDot$BuildLove/")
Global TempDir$ = Workdir + "TempProject"

Global BT:TStream

Global MacDefs:TList = New TList; ListAddLast MacDefs,"$MAC" ListAddLast MacDefs,"$OSX"
Global WinDefs:TList = New TList; ListAddLast WinDefs,"$WINDOWS" ListAddLast winDefs,"$WIN"
Global LinDefs:TList = New TList; ListAddLast LinDefs,"$LINUX" ListAddLast LinDefs,"$LIN"
Global AndDefs:TList = New TList; ListAddLast LinDefs,"$ANDROID"
Global iOSDefs:TList = New TList; ListAddLast iOSDefs,"$IOS"


Global DefsMap:TMap = New TMap

'- "OS X", "Windows", "Linux", "Android" Or "iOS".
Type toutos
Field BT:TStream
Field defs:TList = New TList
Field LOSN$
Field allow:Byte = True
Field process:Byte
Field dir$,file$
Field ReleaseGame(os$)
EndType


Global MacOut:toutos = New toutos
Global WinOut:Toutos = New toutos
Global LinOut:Toutos = New toutos
Global AndOut:Toutos = New toutos
Global IOSOut:Toutos = New toutos

macout.defs = macdefs
macout.losn = "OS X"
winout.defs = windefs
winout.losn = "Windows"
linout.defs = lindefs
linout.losn = "Linux"
andout.defs = anddefs
andout.losn = "Android"
iosout.defs = iosdefs
iosout.losn = "iOS"

Global wplatforms$[] = ["OSX","WIN","LIN","AND","IOS"]

MapInsert DefsMap,"MAC",Macout
MapInsert DefsMap,"WIN",Winout
MapInsert DefsMap,"LIN",Linout
MapInsert DefsMap,"AND",Andout
MapInsert DefsMap,"MACOS",Macout
MapInsert DefsMap,"WINOWS",Winout
MapInsert DefsMap,"LINUX",Linout
MapInsert DefsMap,"ANDROID",Andout
MapInsert DefsMap,"MACOSX",Macout
MapInsert DefsMap,"OSX",Macout
MapInsert DefsMap,"IOS",iosout
Function DefsList:TList(Tag$)
Local e:Object = MapValueForKey(defsmap,Upper(tag))
If TList(e) Return TList(e)
check toutos(e)<>Null,"I don't have a deflist called: "+tag
Return Toutos(e).defs
End Function
Function out:toutos(tag$)
Return Toutos(MapValueForKey(defsmap,Upper(tag)))
End Function

Type TImport
Field file$
Field variable$
End Type


Global imports:TList = New TList
'Global impdetect:TList[] = [New TList,New TList]
Global importjcr:TJCRDir

Global WarningList:TList = New TList
@@ -0,0 +1,76 @@
Rem
Love Builder
dir scanner
(c) Jeroen P. Broks, 2016, All rights reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Exceptions to the standard GNU license are available with Jeroen's written permission given prior
to the project the exceptions are needed for.
Version: 16.03.26
End Rem
Function LookDirs()
Local jd:TJCRDir
Local d$
If pini.c("MULTIDIR").toUpper()<>"Y"
project = JCR_Dir(pini.c("Projectdir."+platform))
Return
EndIf
Print "Looking for dirs: "
pini.clist "I_WANT_YOU",True
pini.clist "I_DONT_WANT_YOU",True
pini.clist "LICS"
Local ly:TList = pini.list("I_WANT_YOU")
Local ln:TList = pini.list("I_DONT_WANT_YOU")
Local lic:TList = pini.list("LICS")
For d$=EachIn ListDir(pini.c("Projectdir."+platform))
If JCR_Type((pini.c("Projectdir."+platform))+"/"+d)
If Not ( ListContains(ly,d) Or ListContains(ln,d) )
If yes("Allow dir ~q"+d+"~q")
ListAddLast ly,d
SortList ly
Else
ListAddLast ln,d
SortList ln
EndIf
SaveIni pinifile,pini
EndIf
If ListContains(ly,d)
Print "Will add: "+D
Need pini,"Dir.Author."+d,"Author",d
If Not pini.c("Dir.Lic."+d)
Print "We got the next license codes: "
For Local lc$=EachIn lic Print "* "+lc Next
EndIf
need pini,"Dir.Lic."+d,"License Tag: ","UNKNOWN"
If Not ListContains(lic,pini.c("Dir.Lic."+d))
ListAddLast lic, pini.c("Dir.Lic."+d);
SaveIni pinifile,pini
EndIf
need pini,"Lic."+pini.c("Dir.Lic."+d),"License Text: ","License text not properly set up. Sorry!"
EndIf
EndIf
Next
Print "Adding directories to project"
For d$=EachIn ly
Print "Adding: "+d
jd = JCR_Dir(pini.c("Projectdir."+platform)+"/"+d)
For Local f$=EachIn MapKeys(jd.entries)
If Prefixed(f,"JBL/") Or Prefixed(f,"JCR/") Print "WARNING! "+f+" makes use of a reserved directory. This may lead to undesirable behavior!"
Next
JCR_AddPatch(project,jd)
Next
End Function
@@ -0,0 +1,73 @@
MKL_Version "",""
MKL_Lic "",""


Function MacRelease(o$)
Local mac:TJCRDir = JCR_Dir("incbin::Mac64.jcr")
Local e:TJCREntry
Local target$
AddRaw mac,tempdir+"/zips/project.OSX.love","love.app/Contents/Resources/"+pini.c("Executable")+".love"
For e=EachIn MapValues(mac.entries)
target = pini.c("Release."+platform)+"/"+o+"/"+Replace(e.filename,"love.app/",pini.c("Executable")+".app/")
Print "= Writing: "+target
check CreateDir(ExtractDir(target),2),"Could not create: "+ExtractDir(target)
If ExtractExt(target).tolower()="icns"
If Not CopyFile(pini.c("MacIcon."+platform),target) warn "Could not copy "+pini.c("MacIcon."+platform)+" to "+target
Else
JCR_Extract mac,e.filename,target,True
EndIf
Next
End Function; out("OSX").releasegame = MacRelease


Function WinRelease(o$)
Local win32:TJCRDir = JCR_Dir("incbin::Win32.jcr")
Local win64:TJCRDir = JCR_Dir("incbin::Win64.jcr")
Local exej:TJCRDir[] = [win32,win64]
Local dir$ = pini.c("Release."+platform)+"/"+o+"/"
Local exeb[] = [32,64]
Local exed$[] = [dir+"/32bit",dir+"/64bit"]
Local love:TJCRDir = Raw2JCR(tempdir+"/zips/project.WIN.love","Win.love")
Local lovebank:TBank = JCR_B(love,"Win.Love")
Local exebank:TBank
Local i
Local bo:TStream
Local e:TJCREntry
Local lic$ = LoadString(JCR_B(win32,"license.txt"))
For i=0 Until Len exeb
check CreateDir(exed[i],1),"Cannot create: "+Exed[i]
exebank = JCR_B(exej[i],"love.exe")
WriteStdout "= Compiling: "+exed[i]+"/"+pini.c("Executable")+".exe ... step 1 "
bo = WriteStream(exed[i]+"/"+pini.c("Executable")+".exe")
check bo<>Null,"Cannot write file!"
WriteBank exebank,bo,0,BankSize(exebank)
WriteStdout Chr(8)+Chr(8)+"2 "
WriteBank lovebank,bo,0,BankSize(lovebank)
For Local j=1 To 7 WriteStdout Chr(8) Next
Print "done "
CloseStream bo
For e=EachIn MapValues(exej[i].entries)
If ExtractExt(e.filename).tolower()="dll" JCR_Extract exej[i],e.filename,exed[i] Print "= Written: "+exed[i]+"/"+e.filename
Next
bo = WriteStream(exed[i]+"/love.license.txt")
WriteLine bo,"This file only explains the license about the underlying LOVE2D engine. It says nothing about the game itself!~n~n"
WriteString bo,lic
CloseStream bo
Next
End Function; out("WIN").releasegame = winrelease

Function ReleaseGames()
Local r(os$)
For Local p$=EachIn(wplatforms)
If out(p).process
Print "Releasing for "+out(p).losn
r = out(p).releasegame
If Not r
warn "Code not found to release for: "+p
Else
check CreateDir(pini.c("Release."+platform)+"/"+p,2),"Could not create: "+pini.c("Release."+platform)+"/"+p,2
r(p)
EndIf
EndIf
Next
End Function
@@ -0,0 +1,31 @@
Rem
YES!
(c) Jeroen P. Broks, 2016, All rights reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Exceptions to the standard GNU license are available with Jeroen's written permission given prior
to the project the exceptions are needed for.
Version: 16.03.25
End Rem
Function yes(q$)
Local T$ = Upper(Left(Trim(Input(q+" ? (Y/N) ")),1))
Return T="Y" Or T="T" Or T="J"
End Function

MKL_Lic "Love Builder - yes.bmx","GNU General Public License 3"
MKL_Version "Love Builder - yes.bmx","16.03.25"
@@ -0,0 +1,43 @@
Rem
LoveBuilder
zip
(c) Jeroen P. Broks, 2016, All rights reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Exceptions to the standard GNU license are available with Jeroen's written permission given prior
to the project the exceptions are needed for.
Version: 16.03.26
End Rem
Function zip()
Local pwd$ = CurrentDir()
ChangeDir Tempdir
CreateDir "Zips"
ChangeDir "Assets"
Print "Zipping assets"
system_ "zip ../Zips/Assets -9 -r *"
ChangeDir "../Script"
For Local p$=EachIn wplatforms
If out(p).process
Print "Creating love file for "+out(p).losn
check CopyFile("../zips/assets.zip","../zips/project."+p+".love"),"Could not copy assets into full project file"
ChangeDir p
system_ "zip ../../zips/project."+p+".love -9 -r *"
ChangeDir ".."
EndIf
Next
ChangeDir pwd
End Function
@@ -77,9 +77,9 @@ Just ends the -- *if statement set up before.
Then the pre-processor will replace the next tags with the applicable data. This works as well INSIDE as OUTSIDE strings, however in most cases I do recommend to use them INSIDE a string, unless you know what you are doing.
(The tags below are all CASE SENSITIVE).

Tag | Data
====|=====
$$mydir$$ | will turn into the directory in which the lua file itself lives. This is most of all done to make your life easier when creating libraries.
| Tag | Data |
|====|=====|
| $$mydir$$ | will turn into the directory in which the lua file itself lives. This is most of all done to make your life easier when creating libraries. |


And that should be it. Enjoy!