Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Added ability for html5 target to handle #LIBS #71

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion src/transcc/builders/html5.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,60 @@ Class Html5Builder Extends Builder
End

Method MakeTarget:Void()

CreateDataDir "data"

Local meta:="var META_DATA=~q"+MetaData()+"~q;~n"

'modify the container
Local containerDoc:= LoadString("MonkeyGame.html")

'build header
Local scriptTags:= ""

'add lib imports
Local libs:= GetConfigVar("LIBS")
If libs
scriptTags = ""
'iterate over each lib
For Local lib:=Eachin libs.Split( ";" )
If Not lib Continue

'check to see if thi
Local scriptPath:= lib.ToLower()
If scriptPath.StartsWith("http://") or scriptPath.StartsWith("https://")
'remote lib
'do nothing here yet but keep for later
scriptPath = lib
Else
'local lib, check that it exists!!!
Local pathOld:= lib
If FileType(pathOld) <> FILETYPE_FILE
'nope, so just assume the lib will be copied manually...
scriptPath = pathOld
Else
'yes, so copy it into build folder
Local pathNew:= StripDir(lib)
CCopyFile(pathOld, pathNew)

scriptPath = pathNew
EndIf
EndIf

'add lib to html output
scriptTags += "<script language=~qjavascript~q src=~q" + scriptPath + "~q>Javascript lib not supported!</script>~n"
Next
EndIf

'build header
Local header:= "<!-- lib imports start -->~n"
header += scriptTags + "~n"
header += "<!-- lib imports end -->~n"

'process header in container doc
containerDoc = ReplaceBlock(containerDoc, "HEAD", header, "~n<!--")
SaveString(containerDoc, "MonkeyGame.html")

'modify the main script src
Local main:=LoadString( "main.js" )

main=ReplaceBlock( main,"TRANSCODE",transCode )
Expand Down
2 changes: 2 additions & 0 deletions targets/html5/template/MonkeyGame.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
height: 8px;
}
</style>
<!--${HEAD_BEGIN}-->
<!--${HEAD_END}-->
<script>

var CANVAS_RESIZE_MODE=1; //0=locked, 1=stretch, 2=resize
Expand Down