def build_deploy_webpage(fips_dir, proj_dir): # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir) if os.path.isdir(webpage_dir): shutil.rmtree(webpage_dir) os.makedirs(webpage_dir) # compile emscripten, pnacl and android samples if BuildEmscripten and emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, 'emsc-ninja-release') project.build(fips_dir, proj_dir, 'emsc-ninja-release') if BuildWasm and emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, 'wasm-ninja-release') project.build(fips_dir, proj_dir, 'wasm-ninja-release') if BuildPNaCl and nacl.check_exists(fips_dir): project.gen(fips_dir, proj_dir, 'pnacl-ninja-release') project.build(fips_dir, proj_dir, 'pnacl-ninja-release') # export sample assets export_assets(fips_dir, proj_dir, webpage_dir) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
def build_deploy_webpage(fips_dir, proj_dir, rebuild): # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir) if rebuild: if os.path.isdir(webpage_dir): shutil.rmtree(webpage_dir) if not os.path.isdir(webpage_dir): os.makedirs(webpage_dir) # compile samples if BuildEmscripten and emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, EmscConfig) project.build(fips_dir, proj_dir, EmscConfig) if BuildWasm and emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, WasmConfig) project.build(fips_dir, proj_dir, WasmConfig) # export sample assets if ExportAssets: export_assets(fips_dir, proj_dir, webpage_dir) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
def build_deploy_webpage(fips_dir, proj_dir) : # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir) if os.path.isdir(webpage_dir) : shutil.rmtree(webpage_dir) os.makedirs(webpage_dir) # compile emscripten, pnacl and android samples if BuildEmscripten and emscripten.check_exists(fips_dir) : project.gen(fips_dir, proj_dir, 'emsc-ninja-release') project.build(fips_dir, proj_dir, 'emsc-ninja-release') if BuildWasm and emscripten.check_exists(fips_dir) : project.gen(fips_dir, proj_dir, 'wasm-ninja-release') project.build(fips_dir, proj_dir, 'wasm-ninja-release') if BuildPNaCl and nacl.check_exists(fips_dir) : project.gen(fips_dir, proj_dir, 'pnacl-ninja-release') project.build(fips_dir, proj_dir, 'pnacl-ninja-release') # export sample assets export_assets(fips_dir, proj_dir, webpage_dir) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
def check_sdk(fips_dir, platform_name) : """check whether an external crossplatform-SDK is installed""" if platform_name == 'emscripten' : return emscripten.check_exists(fips_dir) elif platform_name == 'android' : return android.check_exists(fips_dir) else : return True
def check_sdk(fips_dir, platform_name): """check whether an external crossplatform-SDK is installed""" if platform_name == 'emscripten': return emscripten.check_exists(fips_dir) elif platform_name == 'android': return android.check_exists(fips_dir) else: return True
def build_deploy_webpage(fips_dir, proj_dir, rebuild): # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/{}'.format(ws_dir, WebpageDeployDir) if rebuild: if os.path.isdir(webpage_dir): shutil.rmtree(webpage_dir) if not os.path.isdir(webpage_dir): os.makedirs(webpage_dir) # compile examples if emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, BuildConfig) project.build(fips_dir, proj_dir, BuildConfig) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated Examples web page under {}.'.format(webpage_dir))
def build_deploy_webpage(fips_dir, proj_dir) : # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/oryol-samples-webpage'.format(ws_dir) if os.path.isdir(webpage_dir) : shutil.rmtree(webpage_dir) os.makedirs(webpage_dir) if emscripten.check_exists(fips_dir) : project.gen(fips_dir, proj_dir, BuildConfig) project.build(fips_dir, proj_dir, BuildConfig) # export sample assets if ExportAssets : export_assets(fips_dir, proj_dir, webpage_dir) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
def build_deploy_webpage(fips_dir, proj_dir) : # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/yakc-webpage/virtualkc'.format(ws_dir) if os.path.isdir(webpage_dir) : shutil.rmtree(webpage_dir) os.makedirs(webpage_dir) # compile emscripten, pnacl and android samples if emscripten.check_exists(fips_dir) : project.gen(fips_dir, proj_dir, 'yakc-emsc-make-release') project.build(fips_dir, proj_dir, 'yakc-emsc-make-release') # build the webpage via jekyll subprocess.call('jekyll build', cwd=proj_dir+'/web', shell=True) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated web page under {}.'.format(webpage_dir))
def build_deploy_webpage(fips_dir, proj_dir): # if webpage dir exists, clear it first ws_dir = util.get_workspace_dir(fips_dir) webpage_dir = '{}/fips-deploy/yakc-webpage/virtualkc'.format(ws_dir) if os.path.isdir(webpage_dir): shutil.rmtree(webpage_dir) os.makedirs(webpage_dir) # compile if emscripten.check_exists(fips_dir): project.gen(fips_dir, proj_dir, 'yakc-emsc-make-release') project.build(fips_dir, proj_dir, 'yakc-emsc-make-release') project.gen(fips_dir, proj_dir, 'yakc-wasm-make-release') project.build(fips_dir, proj_dir, 'yakc-wasm-make-release') # build the webpage via jekyll subprocess.call('jekyll build', cwd=proj_dir + '/web', shell=True) # deploy the webpage deploy_webpage(fips_dir, proj_dir, webpage_dir) log.colored(log.GREEN, 'Generated web page under {}.'.format(webpage_dir))
def deploy_webpage(fips_dir, proj_dir, webpage_dir) : """builds the final webpage under under fips-deploy/voxel-test-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # copy other required files for name in ['style.css', 'emsc.js', 'favicon.png'] : log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate emscripten HTML page if emscripten.check_exists(fips_dir) : emsc_deploy_dir = '{}/fips-deploy/voxel-test/emsc-ninja-release'.format(ws_dir) name = 'VoxelTest' log.info('> generate emscripten HTML page: {}'.format(name)) for ext in ['js', 'html.mem'] : src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, webpage_dir) with open(proj_dir + '/web/emsc.html', 'r') as f : templ = Template(f.read()) html = templ.safe_substitute(name=name) with open('{}/index.html'.format(webpage_dir), 'w') as f : f.write(html)
def deploy_webpage(fips_dir, proj_dir, webpage_dir): """builds the final webpage under under fips-deploy/learnopengl-examples""" ws_dir = util.get_workspace_dir(fips_dir) wasm_deploy_dir = '{}/fips-deploy/learnopengl-examples/{}'.format( ws_dir, BuildConfig) # create directories if not os.path.exists(webpage_dir): os.makedirs(webpage_dir) # build the thumbnail gallery content = '' for chapter in items: chapter_title = chapter[0] lessons = chapter[1] content += '<h2>{}</i></h2>\n'.format(chapter_title) for lesson in lessons: lesson_title = lesson[0] lesson_link = lesson[1] examples = lesson[3] content += '<article>\n' content += '<section class="header"><h3><a href="{}">{} <i class="icon-link-ext"></i></a></h3></section>\n'.format( lesson_link, lesson_title) content += '<section class="group examples">\n' for example in examples: name = example[0] filename = example[1] log.info('> adding thumbnail for {}'.format(filename)) url = "{}.html".format(filename) img_name = filename + '.jpg' img_path = proj_dir + '/webpage/' + img_name if not os.path.exists(img_path): img_name = 'dummy.jpg' img_path = proj_dir + 'webpage/dummy.jpg' content += '<figure class="col-15">\n' content += '<figcaption><h4>{}</h4></figcaption>\n'.format( name) content += '<div><img class="responsive" src="{}" alt=""></div>\n'.format( img_name) content += '<a href="{}">Read More</a>\n'.format(url) content += '</figure>\n' content += '</section>\n' content += '</article>\n' content += '<hr>\n' # populate the html template, and write to the build directory with open(proj_dir + '/webpage/index.html', 'r') as f: templ = Template(f.read()) html = templ.safe_substitute( samples=content, date=datetime.date.today().strftime("%B %d %Y")) with open(webpage_dir + '/index.html', 'w') as f: f.write(html) # copy other required files for name in [ 'dummy.jpg', 'favicon.png', 'fontello.woff', 'fontello.woff2' ]: log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name) # generate WebAssembly HTML pages if emscripten.check_exists(fips_dir): for chapter in items: lessons = chapter[1] for lesson in lessons: dir = lesson[2] examples = lesson[3] for example in examples: filename = example[1] source = example[2] glsl = example[3] log.info('> generate wasm HTML page: {}'.format(filename)) for ext in ['wasm', 'js']: src_path = '{}/{}.{}'.format(wasm_deploy_dir, filename, ext) if os.path.isfile(src_path): shutil.copy(src_path, '{}/'.format(webpage_dir)) with open(proj_dir + '/webpage/wasm.html', 'r') as f: templ = Template(f.read()) src_url = '{}/{}/{}'.format(GitHubExamplesURL, dir, source) if glsl is None: glsl_url = "." glsl_hidden = "hidden" else: glsl_url = '{}/{}/{}'.format( GitHubExamplesURL, dir, glsl) glsl_hidden = "" html = templ.safe_substitute(name=filename, prog=filename, source=src_url, glsl=glsl_url, hidden=glsl_hidden) with open('{}/{}.html'.format(webpage_dir, filename), 'w') as f: f.write(html) # copy assets from deploy directory for asset in assets: log.info('> copy asset file: {}'.format(asset)) src_path = '{}/{}'.format(wasm_deploy_dir, asset) if os.path.isfile(src_path): shutil.copy(src_path, webpage_dir) # copy the screenshots for chapter in items: lessons = chapter[1] for lesson in lessons: examples = lesson[3] for example in examples: img_name = example[1] + '.jpg' img_path = proj_dir + '/webpage/' + img_name if os.path.exists(img_path): log.info('> copy screenshot: {}'.format(img_name)) shutil.copy(img_path, webpage_dir + '/' + img_name)
def deploy_webpage(fips_dir, proj_dir, webpage_dir): """builds the final webpage under under fips-deploy/oryol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + "/websamples.yml", "r") as f: samples = yaml.load(f.read()) # build the thumbnail gallery content = "" for sample in samples: if sample["name"] != "__end__": name = sample["name"] imgPath = sample["image"] types = sample["type"] desc = sample["desc"] head, tail = os.path.split(imgPath) if tail == "none": imgFileName = "dummy.jpg" else: imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format( name, imgFileName, desc ) content += ' <div class="thumb-bar">\n' content += ' <ul class="thumb-list">\n' if "emscripten" in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}.html">emsc</a></li>\n'.format( name ) if "pnacl" in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}_pnacl.html">pnacl</a></li>\n'.format( name ) if "android" in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}-debug.apk">apk</a></li>\n'.format( name ) content += " </ul>\n" content += " </div>\n" content += "</div>\n" # populate the html template, and write to the build directory with open(proj_dir + "/web/index.html", "r") as f: templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + "/index.html", "w") as f: f.write(html) # copy other required files for name in ["style.css", "dummy.jpg", "emsc.js", "pnacl.js", "about.html", "favicon.png"]: log.info("> copy file: {}".format(name)) shutil.copy(proj_dir + "/web/" + name, webpage_dir + "/" + name) # generate emscripten HTML pages if BuildEmscripten and emscripten.check_exists(fips_dir): emsc_deploy_dir = "{}/fips-deploy/oryol/emsc-ninja-release".format(ws_dir) for sample in samples: name = sample["name"] if name != "__end__" and "emscripten" in sample["type"]: log.info("> generate emscripten HTML page: {}".format(name)) for ext in ["js", "html.mem"]: src_path = "{}/{}.{}".format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy(src_path, webpage_dir) with open(proj_dir + "/web/emsc.html", "r") as f: templ = Template(f.read()) src_url = GitHubSamplesURL + sample["src"] html = templ.safe_substitute(name=name, source=src_url) with open("{}/{}.html".format(webpage_dir, name), "w") as f: f.write(html) # copy PNaCl HTML pages if BuildPNaCl and nacl.check_exists(fips_dir): pnacl_deploy_dir = "{}/fips-deploy/oryol/pnacl-ninja-release".format(ws_dir) for sample in samples: name = sample["name"] if name != "__end__" and "pnacl" in sample["type"]: log.info("> generate PNaCl HTML page: {}".format(name)) for ext in ["nmf", "pexe"]: shutil.copy("{}/{}.{}".format(pnacl_deploy_dir, name, ext), webpage_dir) with open(proj_dir + "/web/pnacl.html", "r") as f: templ = Template(f.read()) src_url = GitHubSamplesURL + sample["src"] html = templ.safe_substitute(name=name, source=src_url) with open("{}/{}_pnacl.html".format(webpage_dir, name), "w") as f: f.write(html) # copy the screenshots for sample in samples: if sample["name"] != "__end__": img_path = sample["image"] head, tail = os.path.split(img_path) if tail != "none": log.info("> copy screenshot: {}".format(tail)) shutil.copy(img_path, webpage_dir + "/" + tail) # copy the Android sample files over if BuildAndroid and android.check_exists(fips_dir): android_deploy_dir = "{}/fips-deploy/oryol/android-ninja-release".format(ws_dir) for sample in samples: if sample["name"] != "__end__" and "android" in sample["type"]: log.info("> copy android sample files: {}".format(sample["name"])) shutil.copy("{}/{}-debug.apk".format(android_deploy_dir, sample["name"]), webpage_dir)
def deploy_webpage(fips_dir, proj_dir, webpage_dir): """builds the final webpage under under fips-deploy/oryol-samples-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + '/websamples.yml', 'r') as f: samples = yaml.load(f.read()) # create directories for platform in ['wasm']: platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir): os.makedirs(platform_dir) # link to the Core Samples content = '<div class="thumb">\n' content += ' <div class="thumb-title">To Core Samples...</div>\n' content += ' <div class="img-frame"><a href="http://floooh.github.com/oryol/index.html"><img class="image" src="core_samples.jpg"></img></a></div>\n' content += '</div>\n' # build the thumbnail gallery for sample in samples: if sample['name'] != '__end__': name = sample['name'] imgPath = sample['image'] types = sample['type'] desc = sample['desc'] head, tail = os.path.split(imgPath) if tail == 'none': imgFileName = 'dummy.jpg' else: imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="wasm/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format( name, imgFileName, desc) content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/web/index.html', 'r') as f: templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f: f.write(html) # copy other required files for name in [ 'style.css', 'dummy.jpg', 'emsc.js', 'favicon.png', 'core_samples.jpg' ]: log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate WebAssembly HTML pages if emscripten.check_exists(fips_dir): wasm_deploy_dir = '{}/fips-deploy/oryol-samples/{}'.format( ws_dir, BuildConfig) for sample in samples: name = sample['name'] if name != '__end__' and 'emscripten' in sample['type']: log.info('> generate wasm HTML page: {}'.format(name)) for ext in ['js', 'wasm']: src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) with open(proj_dir + '/web/wasm.html', 'r') as f: templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src'] html = templ.safe_substitute(name=name, source=src_url) with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f: f.write(html) # copy the screenshots for sample in samples: if sample['name'] != '__end__': img_path = sample['image'] head, tail = os.path.split(img_path) if tail != 'none': log.info('> copy screenshot: {}'.format(tail)) shutil.copy(img_path, webpage_dir + '/' + tail)
def deploy_webpage(fips_dir, proj_dir, webpage_dir) : """builds the final webpage under under fips-deploy/oryol-samples-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + '/websamples.yml', 'r') as f : samples = yaml.load(f.read()) # create directories for platform in ['wasm'] : platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir) : os.makedirs(platform_dir) # link to the Core Samples content = '<div class="thumb">\n' content += ' <div class="thumb-title">To Core Samples...</div>\n' content += ' <div class="img-frame"><a href="http://floooh.github.com/oryol/index.html"><img class="image" src="core_samples.jpg"></img></a></div>\n' content += '</div>\n' # build the thumbnail gallery for sample in samples : if sample['name'] != '__end__' : name = sample['name'] imgPath = sample['image'] types = sample['type'] desc = sample['desc'] head, tail = os.path.split(imgPath) if tail == 'none' : imgFileName = 'dummy.jpg' else : imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="wasm/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(name,imgFileName,desc) content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/web/index.html', 'r') as f : templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f : f.write(html) # copy other required files for name in ['style.css', 'dummy.jpg', 'emsc.js', 'favicon.png', 'core_samples.jpg'] : log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate WebAssembly HTML pages if emscripten.check_exists(fips_dir) : wasm_deploy_dir = '{}/fips-deploy/oryol-samples/{}'.format(ws_dir, BuildConfig) for sample in samples : name = sample['name'] if name != '__end__' and 'emscripten' in sample['type'] : log.info('> generate wasm HTML page: {}'.format(name)) for ext in ['js', 'wasm'] : src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) with open(proj_dir + '/web/wasm.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f : f.write(html) # copy the screenshots for sample in samples : if sample['name'] != '__end__' : img_path = sample['image'] head, tail = os.path.split(img_path) if tail != 'none' : log.info('> copy screenshot: {}'.format(tail)) shutil.copy(img_path, webpage_dir + '/' + tail)
def deploy_webpage(fips_dir, proj_dir, webpage_dir): """builds the final webpage under under fips-deploy/oryol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + '/websamples.yml', 'r') as f: samples = yaml.load(f.read()) # build the thumbnail gallery content = '' for sample in samples: if sample['name'] != '__end__': name = sample['name'] imgPath = sample['image'] types = sample['type'] desc = sample['desc'] head, tail = os.path.split(imgPath) if tail == 'none': imgFileName = 'dummy.jpg' else: imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format( name, imgFileName, desc) content += ' <div class="thumb-bar">\n' content += ' <ul class="thumb-list">\n' if 'emscripten' in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}.html">emsc</a></li>\n'.format( name) if 'pnacl' in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}_pnacl.html">pnacl</a></li>\n'.format( name) if 'android' in types: content += ' <li class="thumb-item"><a class="thumb-link" href="{}-debug.apk">apk</a></li>\n'.format( name) content += ' </ul>\n' content += ' </div>\n' content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/web/index.html', 'r') as f: templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f: f.write(html) # copy other required files for name in [ 'style.css', 'dummy.jpg', 'emsc.js', 'pnacl.js', 'about.html', 'favicon.png' ]: log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate emscripten HTML pages if BuildEmscripten and emscripten.check_exists(fips_dir): emsc_deploy_dir = '{}/fips-deploy/oryol/emsc-make-release'.format( ws_dir) for sample in samples: name = sample['name'] if name != '__end__' and 'emscripten' in sample['type']: log.info('> generate emscripten HTML page: {}'.format(name)) for ext in ['js', 'html.mem']: src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy(src_path, webpage_dir) with open(proj_dir + '/web/emsc.html', 'r') as f: templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src'] html = templ.safe_substitute(name=name, source=src_url) with open('{}/{}.html'.format(webpage_dir, name), 'w') as f: f.write(html) # copy PNaCl HTML pages if BuildPNaCl and nacl.check_exists(fips_dir): pnacl_deploy_dir = '{}/fips-deploy/oryol/pnacl-make-release'.format( ws_dir) for sample in samples: name = sample['name'] if name != '__end__' and 'pnacl' in sample['type']: log.info('> generate PNaCl HTML page: {}'.format(name)) for ext in ['nmf', 'pexe']: shutil.copy('{}/{}.{}'.format(pnacl_deploy_dir, name, ext), webpage_dir) with open(proj_dir + '/web/pnacl.html', 'r') as f: templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src'] html = templ.safe_substitute(name=name, source=src_url) with open('{}/{}_pnacl.html'.format(webpage_dir, name), 'w') as f: f.write(html) # copy the screenshots for sample in samples: if sample['name'] != '__end__': img_path = sample['image'] head, tail = os.path.split(img_path) if tail != 'none': log.info('> copy screenshot: {}'.format(tail)) shutil.copy(img_path, webpage_dir + '/' + tail) # copy the Android sample files over if BuildAndroid and android.check_exists(fips_dir): android_deploy_dir = '{}/fips-deploy/oryol/android-make-release'.format( ws_dir) for sample in samples: if sample['name'] != '__end__' and 'android' in sample['type']: log.info('> copy android sample files: {}'.format( sample['name'])) shutil.copy( '{}/{}-debug.apk'.format(android_deploy_dir, sample['name']), webpage_dir)
def deploy_webpage(fips_dir, proj_dir, webpage_dir) : """builds the final webpage under under fips-deploy/sokol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) wasm_deploy_dir = '{}/fips-deploy/sokol-samples/{}'.format(ws_dir, BuildConfig) # create directories for platform in ['wasm'] : platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir) : os.makedirs(platform_dir) # build the thumbnail gallery content = '' for sample in samples : name = sample[0] log.info('> adding thumbnail for {}'.format(name)) url = "wasm/{}-sapp.html".format(name) ui_url = "wasm/{}-sapp-ui.html".format(name) img_name = name + '.jpg' img_path = proj_dir + '/webpage/' + img_name if not os.path.exists(img_path): img_name = 'dummy.jpg' img_path = proj_dir + 'webpage/dummy.jpg' content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) if os.path.exists(wasm_deploy_dir + '/' + name + '-sapp-ui.js'): content += '<a class="img-btn-link" href="{}"><div class="img-btn">UI</div></a>'.format(ui_url) content += ' <div class="img-frame"><a href="{}"><img class="image" src="{}"></img></a></div>\n'.format(url,img_name) content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/webpage/index.html', 'r') as f : templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f : f.write(html) # copy other required files for name in ['dummy.jpg', 'favicon.png'] : log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name) # generate WebAssembly HTML pages if emscripten.check_exists(fips_dir) : for sample in samples : name = sample[0] source = sample[1] log.info('> generate wasm HTML page: {}'.format(name)) for postfix in ['sapp', 'sapp-ui']: for ext in ['wasm', 'js'] : src_path = '{}/{}-{}.{}'.format(wasm_deploy_dir, name, postfix, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) with open(proj_dir + '/webpage/wasm.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + source html = templ.safe_substitute(name=name, prog=name+'-'+postfix, source=src_url) with open('{}/wasm/{}-{}.html'.format(webpage_dir, name, postfix), 'w') as f : f.write(html) # copy the screenshots for sample in samples : img_name = sample[0] + '.jpg' img_path = proj_dir + '/webpage/' + img_name if os.path.exists(img_path): log.info('> copy screenshot: {}'.format(img_name)) shutil.copy(img_path, webpage_dir + '/' + img_name)
def deploy_webpage(fips_dir, proj_dir, webpage_dir): """builds the final webpage under under fips-deploy/sokol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # create directories for platform in ['asmjs', 'wasm']: platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir): os.makedirs(platform_dir) # build the thumbnail gallery content = '' for sample in samples: name = sample[0] log.info('> adding thumbnail for {}'.format(name)) img_name = name + '.jpg' img_path = proj_dir + '/webpage/' + img_name if not os.path.exists(img_path): img_name = 'dummy.jpg' img_path = proj_dir + 'webpage/dummy.jpg' content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="asmjs/{}-emsc.html"><img class="image" src="{}"></img></a></div>\n'.format( name, img_name) content += ' <div class="thumb-bar">\n' content += ' <ul class="thumb-list">\n' content += ' <li class="thumb-item"><a class="thumb-link" href="asmjs/{}-emsc.html">asm.js</a></li>\n'.format( name) content += ' <li class="thumb-item"><a class="thumb-link" href="wasm/{}-emsc.html">wasm</a></li>\n'.format( name) content += ' </ul>\n' content += ' </div>\n' content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/webpage/index.html', 'r') as f: templ = Template(f.read()) html = templ.safe_substitute(doctitle=DocTitle, title=Title, subtitle=Subtitle, samples=content, separator=Separator) with open(webpage_dir + '/index.html', 'w') as f: f.write(html) # and the same with the CSS template with open(proj_dir + '/webpage/style.css', 'r') as f: templ = Template(f.read()) css = templ.safe_substitute(background=BackgroundColor) with open(webpage_dir + '/style.css', 'w') as f: f.write(css) # copy other required files for name in ['dummy.jpg', 'emsc.js', 'wasm.js', 'favicon.png']: log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name) # generate emscripten HTML pages if emscripten.check_exists(fips_dir): emsc_deploy_dir = '{}/fips-deploy/sokol-samples/{}'.format( ws_dir, EmscConfig) for sample in samples: name = sample[0] source = sample[1] log.info('> generate emscripten HTML page: {}'.format(name)) for ext in ['js']: src_path = '{}/{}-emsc.{}'.format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy(src_path, '{}/asmjs/'.format(webpage_dir)) with open(proj_dir + '/webpage/emsc.html', 'r') as f: templ = Template(f.read()) src_url = GitHubSamplesURL + source html = templ.safe_substitute(name=name + '-emsc', source=src_url, separator=GameSeparator) with open('{}/asmjs/{}-emsc.html'.format(webpage_dir, name, name), 'w') as f: f.write(html) # generate WebAssembly HTML pages if emscripten.check_exists(fips_dir): wasm_deploy_dir = '{}/fips-deploy/sokol-samples/{}'.format( ws_dir, WasmConfig) for sample in samples: name = sample[0] source = sample[1] log.info('> generate wasm HTML page: {}'.format(name)) for ext in ['js', 'wasm.mappedGlobals']: src_path = '{}/{}-emsc.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) for ext in ['wasm']: src_path = '{}/{}-emsc.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path): shutil.copy( src_path, '{}/wasm/{}-emsc.{}.txt'.format( webpage_dir, name, ext)) with open(proj_dir + '/webpage/wasm.html', 'r') as f: templ = Template(f.read()) src_url = GitHubSamplesURL + source html = templ.safe_substitute(name=name + '-emsc', source=src_url, separator=GameSeparator) with open('{}/wasm/{}-emsc.html'.format(webpage_dir, name), 'w') as f: f.write(html) # copy the screenshots for sample in samples: img_name = sample[0] + '.jpg' img_path = proj_dir + '/webpage/' + img_name if os.path.exists(img_path): log.info('> copy screenshot: {}'.format(img_name)) shutil.copy(img_path, webpage_dir + '/' + img_name)
def deploy_webpage(fips_dir, proj_dir, webpage_dir) : """builds the final webpage under under fips-deploy/oryol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + '/websamples.yml', 'r') as f : samples = yaml.load(f.read()) # create directories for platform in ['asmjs', 'wasm', 'pnacl'] : platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir) : os.makedirs(platform_dir) # build the thumbnail gallery content = '' for sample in samples : if sample['name'] != '__end__' : name = sample['name'] imgPath = sample['image'] types = sample['type'] desc = sample['desc'] head, tail = os.path.split(imgPath) if tail == 'none' : imgFileName = 'dummy.jpg' else : imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="asmjs/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(name,imgFileName,desc) content += ' <div class="thumb-bar">\n' content += ' <ul class="thumb-list">\n' if 'emscripten' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="asmjs/{}.html">asm.js</a></li>\n'.format(name) if 'pnacl' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="pnacl/{}.html">pnacl</a></li>\n'.format(name) if 'emscripten' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="wasm/{}.html">wasm</a></li>\n'.format(name) content += ' </ul>\n' content += ' </div>\n' content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/web/index.html', 'r') as f : templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f : f.write(html) # copy other required files for name in ['style.css', 'dummy.jpg', 'emsc.js', 'pnacl.js', 'wasm.js', 'about.html', 'favicon.png'] : log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate emscripten HTML pages if BuildEmscripten and emscripten.check_exists(fips_dir) : emsc_deploy_dir = '{}/fips-deploy/oryol/emsc-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'emscripten' in sample['type'] : log.info('> generate emscripten HTML page: {}'.format(name)) for ext in ['js', 'html.mem'] : src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/asmjs/'.format(webpage_dir)) with open(proj_dir + '/web/emsc.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/asmjs/{}.html'.format(webpage_dir, name, name), 'w') as f : f.write(html) # generate WebAssembly HTML pages if BuildWasm and emscripten.check_exists(fips_dir) : wasm_deploy_dir = '{}/fips-deploy/oryol/wasm-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'emscripten' in sample['type'] : log.info('> generate wasm HTML page: {}'.format(name)) for ext in ['js', 'wasm.mappedGlobals'] : src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) for ext in ['html.mem', 'wasm'] : src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/{}.{}.txt'.format(webpage_dir, name, ext)) with open(proj_dir + '/web/wasm.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f : f.write(html) # generate PNaCl HTML pages if BuildPNaCl and nacl.check_exists(fips_dir) : pnacl_deploy_dir = '{}/fips-deploy/oryol/pnacl-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'pnacl' in sample['type'] : log.info('> generate PNaCl HTML page: {}'.format(name)) for ext in ['nmf', 'pexe'] : src_path = '{}/{}.{}'.format(pnacl_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/pnacl/'.format(webpage_dir)) with open(proj_dir + '/web/pnacl.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/pnacl/{}.html'.format(webpage_dir, name), 'w') as f : f.write(html) # copy the screenshots for sample in samples : if sample['name'] != '__end__' : img_path = sample['image'] head, tail = os.path.split(img_path) if tail != 'none' : log.info('> copy screenshot: {}'.format(tail)) shutil.copy(img_path, webpage_dir + '/' + tail)
def deploy_webpage(fips_dir, proj_dir, webpage_dir) : """builds the final webpage under under fips-deploy/oryol-webpage""" ws_dir = util.get_workspace_dir(fips_dir) # load the websamples.yml file, should have been created during the last build with open(webpage_dir + '/websamples.yml', 'r') as f : samples = yaml.load(f.read()) # create directories for platform in ['asmjs', 'wasm', 'pnacl'] : platform_dir = '{}/{}'.format(webpage_dir, platform) if not os.path.isdir(platform_dir) : os.makedirs(platform_dir) # link to the Extension Samples content = '<div class="thumb">\n' content += ' <div class="thumb-title">To Extension Samples...</div>\n' content += ' <div class="img-frame"><a href="http://floooh.github.com/oryol-samples/index.html"><img class="image" src="ext_samples.jpg"></img></a></div>\n' content += '</div>\n' # build the thumbnail gallery for sample in samples : if sample['name'] != '__end__' : log.info('> adding thumbnail for {}'.format(sample['name'])) name = sample['name'] imgPath = sample['image'] types = sample['type'] desc = sample['desc'] head, tail = os.path.split(imgPath) if tail == 'none' : imgFileName = 'dummy.jpg' else : imgFileName = tail content += '<div class="thumb">\n' content += ' <div class="thumb-title">{}</div>\n'.format(name) content += ' <div class="img-frame"><a href="asmjs/{}.html"><img class="image" src="{}" title="{}"></img></a></div>\n'.format(name,imgFileName,desc) content += ' <div class="thumb-bar">\n' content += ' <ul class="thumb-list">\n' if BuildEmscripten and 'emscripten' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="asmjs/{}.html">asm.js</a></li>\n'.format(name) if BuildPNaCl and 'pnacl' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="pnacl/{}.html">pnacl</a></li>\n'.format(name) if BuildWasm and 'emscripten' in types : content += ' <li class="thumb-item"><a class="thumb-link" href="wasm/{}.html">wasm</a></li>\n'.format(name) content += ' </ul>\n' content += ' </div>\n' content += '</div>\n' # populate the html template, and write to the build directory with open(proj_dir + '/web/index.html', 'r') as f : templ = Template(f.read()) html = templ.safe_substitute(samples=content) with open(webpage_dir + '/index.html', 'w') as f : f.write(html) # copy other required files for name in ['style.css', 'dummy.jpg', 'emsc.js', 'pnacl.js', 'wasm.js', 'about.html', 'favicon.png', 'ext_samples.jpg'] : log.info('> copy file: {}'.format(name)) shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name) # generate emscripten HTML pages if BuildEmscripten and emscripten.check_exists(fips_dir) : emsc_deploy_dir = '{}/fips-deploy/oryol/emsc-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'emscripten' in sample['type'] : log.info('> generate emscripten HTML page: {}'.format(name)) for ext in ['js', 'html.mem'] : src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/asmjs/'.format(webpage_dir)) with open(proj_dir + '/web/emsc.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/asmjs/{}.html'.format(webpage_dir, name, name), 'w') as f : f.write(html) # generate WebAssembly HTML pages if BuildWasm and emscripten.check_exists(fips_dir) : wasm_deploy_dir = '{}/fips-deploy/oryol/wasm-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'emscripten' in sample['type'] : log.info('> generate wasm HTML page: {}'.format(name)) for ext in ['js', 'wasm.mappedGlobals'] : src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/'.format(webpage_dir)) for ext in ['html.mem', 'wasm'] : src_path = '{}/{}.{}'.format(wasm_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/wasm/{}.{}.txt'.format(webpage_dir, name, ext)) with open(proj_dir + '/web/wasm.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/wasm/{}.html'.format(webpage_dir, name), 'w') as f : f.write(html) # generate PNaCl HTML pages if BuildPNaCl and nacl.check_exists(fips_dir) : pnacl_deploy_dir = '{}/fips-deploy/oryol/pnacl-ninja-release'.format(ws_dir) for sample in samples : name = sample['name'] if name != '__end__' and 'pnacl' in sample['type'] : log.info('> generate PNaCl HTML page: {}'.format(name)) for ext in ['nmf', 'pexe'] : src_path = '{}/{}.{}'.format(pnacl_deploy_dir, name, ext) if os.path.isfile(src_path) : shutil.copy(src_path, '{}/pnacl/'.format(webpage_dir)) with open(proj_dir + '/web/pnacl.html', 'r') as f : templ = Template(f.read()) src_url = GitHubSamplesURL + sample['src']; html = templ.safe_substitute(name=name, source=src_url) with open('{}/pnacl/{}.html'.format(webpage_dir, name), 'w') as f : f.write(html) # copy the screenshots for sample in samples : if sample['name'] != '__end__' : img_path = sample['image'] head, tail = os.path.split(img_path) if tail != 'none' : log.info('> copy screenshot: {}'.format(tail)) shutil.copy(img_path, webpage_dir + '/' + tail)