annotate johndyer-mediaelement-13fa20a/src/Builder.py @ 25:4a4bd554b4c1 tip

Closing this sub branch.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Mon, 25 Mar 2013 14:02:54 +0000
parents 032bc65ebafc
children
rev   line source
gyorgy@0 1 import sys
gyorgy@0 2 import os
gyorgy@0 3 import shutil
gyorgy@0 4
gyorgy@0 5 me_filename = 'mediaelement'
gyorgy@0 6 mep_filename = 'mediaelementplayer'
gyorgy@0 7 combined_filename = 'mediaelement-and-player'
gyorgy@0 8
gyorgy@0 9 # BUILD MediaElement (single file)
gyorgy@0 10
gyorgy@0 11 me_files = []
gyorgy@0 12 me_files.append('me-header.js')
gyorgy@0 13 me_files.append('me-namespace.js')
gyorgy@0 14 me_files.append('me-utility.js')
gyorgy@0 15 me_files.append('me-plugindetector.js')
gyorgy@0 16 me_files.append('me-featuredetection.js')
gyorgy@0 17 me_files.append('me-mediaelements.js')
gyorgy@0 18 me_files.append('me-shim.js')
gyorgy@0 19
gyorgy@0 20 code = ''
gyorgy@0 21
gyorgy@0 22 for item in me_files:
gyorgy@0 23 src_file = open('js/' + item,'r')
gyorgy@0 24 code += src_file.read() + "\n"
gyorgy@0 25
gyorgy@0 26 tmp_file = open('../build/' + me_filename + '.js','w')
gyorgy@0 27 tmp_file.write(code)
gyorgy@0 28 tmp_file.close()
gyorgy@0 29
gyorgy@0 30 # BUILD MediaElementPlayer (single file)
gyorgy@0 31
gyorgy@0 32 mep_files = []
gyorgy@0 33 mep_files.append('mep-header.js')
gyorgy@0 34 mep_files.append('mep-library.js')
gyorgy@0 35 mep_files.append('mep-player.js')
gyorgy@0 36 mep_files.append('mep-feature-playpause.js')
gyorgy@0 37 mep_files.append('mep-feature-stop.js')
gyorgy@0 38 mep_files.append('mep-feature-progress.js')
gyorgy@0 39 mep_files.append('mep-feature-time.js')
gyorgy@0 40 mep_files.append('mep-feature-volume.js')
gyorgy@0 41 mep_files.append('mep-feature-fullscreen.js')
gyorgy@0 42 mep_files.append('mep-feature-tracks.js')
gyorgy@0 43 mep_files.append('mep-feature-contextmenu.js')
gyorgy@0 44
gyorgy@0 45 code = ''
gyorgy@0 46
gyorgy@0 47 for item in mep_files:
gyorgy@0 48 src_file = open('js/' + item,'r')
gyorgy@0 49 code += src_file.read() + "\n"
gyorgy@0 50
gyorgy@0 51 tmp_file = open('../build/' + mep_filename + '.js','w')
gyorgy@0 52 tmp_file.write(code)
gyorgy@0 53 tmp_file.close()
gyorgy@0 54
gyorgy@0 55 # MINIFY both scripts
gyorgy@0 56
gyorgy@0 57 # os.system("java -jar yuicompressor-2.4.2.jar ../build/" + me_filename + ".js -o ../build/" + me_filename + ".min.js --charset utf-8 -v")
gyorgy@0 58 # os.system("java -jar yuicompressor-2.4.2.jar ../build/" + mep_filename + ".js -o ../build/" + mep_filename + ".min.js --charset utf-8 -v")
gyorgy@0 59 os.system("java -jar compiler.jar --js ../build/" + me_filename + ".js --js_output_file ../build/" + me_filename + ".min.js")
gyorgy@0 60 os.system("java -jar compiler.jar --js ../build/" + mep_filename + ".js --js_output_file ../build/" + mep_filename + ".min.js")
gyorgy@0 61
gyorgy@0 62 # PREPEND intros
gyorgy@0 63 def addHeader(headerFilename, filename):
gyorgy@0 64
gyorgy@0 65 # get the header text
gyorgy@0 66 tmp_file = open(headerFilename)
gyorgy@0 67 header_txt = tmp_file.read();
gyorgy@0 68 tmp_file.close()
gyorgy@0 69
gyorgy@0 70 # read the current contents of the file
gyorgy@0 71 tmp_file = open(filename)
gyorgy@0 72 file_txt = tmp_file.read()
gyorgy@0 73 tmp_file.close()
gyorgy@0 74
gyorgy@0 75 # open the file again for writing
gyorgy@0 76 tmp_file = open(filename, 'w')
gyorgy@0 77 tmp_file.write(header_txt)
gyorgy@0 78 # write the original contents
gyorgy@0 79 tmp_file.write(file_txt)
gyorgy@0 80 tmp_file.close()
gyorgy@0 81
gyorgy@0 82 addHeader('js/me-header.js', '../build/' + me_filename + '.min.js')
gyorgy@0 83 addHeader('js/mep-header.js', '../build/' + mep_filename + '.min.js')
gyorgy@0 84
gyorgy@0 85
gyorgy@0 86 # COMBINE into single script
gyorgy@0 87
gyorgy@0 88 code = ''
gyorgy@0 89 src_file = open('../build/' + me_filename + '.js','r')
gyorgy@0 90 code += src_file.read() + "\n"
gyorgy@0 91 src_file = open('../build/' + mep_filename + '.js','r')
gyorgy@0 92 code += src_file.read() + "\n"
gyorgy@0 93
gyorgy@0 94 tmp_file = open('../build/' + combined_filename + '.js','w')
gyorgy@0 95 tmp_file.write(code)
gyorgy@0 96 tmp_file.close()
gyorgy@0 97
gyorgy@0 98 code = ''
gyorgy@0 99 src_file = open('../build/' + me_filename + '.min.js','r')
gyorgy@0 100 code += src_file.read() + "\n"
gyorgy@0 101 src_file = open('../build/' + mep_filename + '.min.js','r')
gyorgy@0 102 code += src_file.read() + "\n"
gyorgy@0 103
gyorgy@0 104 tmp_file = open('../build/' + combined_filename + '.min.js','w')
gyorgy@0 105 tmp_file.write(code)
gyorgy@0 106 tmp_file.close()
gyorgy@0 107
gyorgy@0 108
gyorgy@0 109 # MINIFY CSS
gyorgy@0 110 src_file = open('css/mediaelementplayer.css','r')
gyorgy@0 111 tmp_file = open('../build/mediaelementplayer.css','w')
gyorgy@0 112 tmp_file.write(src_file.read())
gyorgy@0 113 tmp_file.close()
gyorgy@0 114 os.system("java -jar yuicompressor-2.4.2.jar ../build/mediaelementplayer.css -o ../build/mediaelementplayer.min.css --charset utf-8 -v")
gyorgy@0 115
gyorgy@0 116 #COPY skin files
gyorgy@0 117 shutil.copy2('css/controls.png','../build/controls.png')
gyorgy@0 118 shutil.copy2('css/bigplay.png','../build/bigplay.png')
gyorgy@0 119 shutil.copy2('css/loading.gif','../build/loading.gif')
gyorgy@0 120
gyorgy@0 121 shutil.copy2('css/mejs-skins.css','../build/mejs-skins.css')
gyorgy@0 122 shutil.copy2('css/controls-ted.png','../build/controls-ted.png')
gyorgy@0 123 shutil.copy2('css/controls-wmp.png','../build/controls-wmp.png')
gyorgy@0 124 shutil.copy2('css/controls-wmp-bg.png','../build/controls-wmp-bg.png')