Make build parameter from extension list.
This commit is contained in:
parent
49d7df32cb
commit
3308ce695b
@ -16,17 +16,26 @@ def ReplaceInFile (filePath, source, dest):
|
||||
file = open (filePath, 'rb')
|
||||
content = file.read ();
|
||||
file.close ()
|
||||
content = content.replace (source, dest)
|
||||
content = re.sub (source, dest, content, flags = re.MULTILINE | re.DOTALL)
|
||||
file = open (filePath, 'wb')
|
||||
file.write (content);
|
||||
file.close ()
|
||||
|
||||
def BuildWebSite (rootFolder, resultFolder):
|
||||
def BuildWebSite (rootFolder, resultFolder, extensions):
|
||||
targetFolder = os.path.join (resultFolder, 'website')
|
||||
shutil.copytree (os.path.join (rootFolder, 'website'), targetFolder)
|
||||
shutil.copytree (os.path.join (rootFolder, 'jsmodeler'), os.path.join (targetFolder, 'jsmodeler'))
|
||||
indexFilePath = os.path.join (targetFolder, 'index.html')
|
||||
importerAppFilePath = os.path.join (targetFolder, 'include', 'importerapp.js')
|
||||
ReplaceInFile (indexFilePath, '../jsmodeler/', 'jsmodeler/')
|
||||
extensionIncludes = ''
|
||||
for extension in extensions:
|
||||
extensionIncludes += '<script type="text/javascript" src="' + extension['path'] + '"></script>\r\n\t'
|
||||
ReplaceInFile (indexFilePath, '\<\!\-\- ExtensionIncludes \-\-\>.*\<\!\-\- ExtensionIncludesEnd \-\-\>', extensionIncludes)
|
||||
extensionIncludes = ''
|
||||
for extension in extensions:
|
||||
extensionIncludes += 'importerApp.AddExtension (new ' + extension['name'] + ' ());\r\n\t'
|
||||
ReplaceInFile (importerAppFilePath, '\/\/ ExtensionIncludes.*\/\/ ExtensionIncludesEnd', extensionIncludes)
|
||||
|
||||
def BuildEmbeddable (rootFolder, resultFolder):
|
||||
targetFolder = os.path.join (resultFolder, 'embeddable')
|
||||
@ -38,6 +47,15 @@ def BuildEmbeddable (rootFolder, resultFolder):
|
||||
ReplaceInFile (indexFilePath, '../jsmodeler/', 'jsmodeler/')
|
||||
|
||||
def Main ():
|
||||
extensions = []
|
||||
i = 1
|
||||
while i < len (sys.argv):
|
||||
extensions.append ({
|
||||
'name' : sys.argv[i],
|
||||
'path' : sys.argv[i + 1]
|
||||
});
|
||||
i += 2
|
||||
|
||||
rootFolder = os.path.abspath ('..')
|
||||
resultFolder = os.path.join (rootFolder, 'build')
|
||||
if os.path.exists (resultFolder):
|
||||
@ -45,7 +63,7 @@ def Main ():
|
||||
os.mkdir (resultFolder)
|
||||
|
||||
PrintInfo ('Building website to folder <' + resultFolder + '>.')
|
||||
BuildWebSite (rootFolder, resultFolder)
|
||||
BuildWebSite (rootFolder, resultFolder, extensions)
|
||||
|
||||
PrintInfo ('Building embeddable example to folder <' + resultFolder + '>.')
|
||||
BuildEmbeddable (rootFolder, resultFolder)
|
||||
|
||||
@ -5,7 +5,7 @@ ExampleExtension = function ()
|
||||
|
||||
ExampleExtension.prototype.IsEnabled = function ()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
ExampleExtension.prototype.Init = function (extensionInterface)
|
||||
|
||||
@ -550,5 +550,7 @@ window.onload = function ()
|
||||
{
|
||||
var importerApp = new ImporterApp ();
|
||||
importerApp.Init ();
|
||||
// ExtensionIncludes
|
||||
importerApp.AddExtension (new ExampleExtension ());
|
||||
// ExtensionIncludesEnd
|
||||
};
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
<script type="text/javascript" src="include/importermenu.js"></script>
|
||||
<script type="text/javascript" src="include/importerapp.js"></script>
|
||||
|
||||
<!-- ExtensionIncludes -->
|
||||
<script type="text/javascript" src="extensions/example/example.js"></script>
|
||||
<!-- ExtensionIncludesEnd -->
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user