decrunchCallbacks[msg.data.callbackID] = null; }; function requestDecrunch(filename, data, callback) { decrunchWorker.postMessage({ filename: filename, data: new Uint8Array(data), callbackID: decrunchCallbacks.length }); decrunchCallbacks.push(callback); } ''' for file_ in data_files: if file_['dstpath'].endswith(CRUNCH_INPUT_SUFFIX): src_dds_name = file_['srcpath'] src_crunch_name = unsuffixed(src_dds_name) + CRUNCH_OUTPUT_SUFFIX # Preload/embed the .crn version instead of the .dds version, but use the .dds suffix for the target file in the virtual FS. file_['srcpath'] = src_crunch_name try: # Do not crunch if crunched version exists and is more recent than dds source crunch_time = os.stat(src_crunch_name).st_mtime dds_time = os.stat(src_dds_name).st_mtime if dds_time < crunch_time: continue except: pass # if one of them does not exist, continue on # guess at format. this lets us tell crunch to not try to be clever and use odd formats like DXT5_AGBR try: format = Popen(['file', file_['srcpath']], stdout=PIPE).communicate()[0]
from subprocess import Popen, PIPE sys.path += [ os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools') ] import shared import jsrun # creduce will only pass the filename of the C file as the first arg, so other # configuration options will have to be hardcoded. CSMITH_CFLAGS = ['-I', os.path.join(os.environ['CSMITH_PATH'], 'runtime')] EMCC_ARGS = ['-O2', '-s', 'ASM_JS=1'] filename = sys.argv[1] obj_filename = shared.unsuffixed(filename) js_filename = obj_filename + '.js' print('testing file', filename) try: print('2) Compile natively') shared.run_process([shared.CLANG_CC, '-O2', filename, '-o', obj_filename] + CSMITH_CFLAGS) print('3) Run natively') correct = jsrun.timeout_run( Popen([obj_filename], stdout=PIPE, stderr=PIPE), 3) except Exception as e: print('Failed or infinite looping in native, skipping', e) sys.exit(1) # boring print('4) Compile JS-ly and compare')
decrunchCallbacks[msg.data.callbackID] = null; }; function requestDecrunch(filename, data, callback) { decrunchWorker.postMessage({ filename: filename, data: new Uint8Array(data), callbackID: decrunchCallbacks.length }); decrunchCallbacks.push(callback); } ''' for file_ in data_files: if file_['dstpath'].endswith(CRUNCH_INPUT_SUFFIX): src_dds_name = file_['srcpath'] src_crunch_name = unsuffixed(src_dds_name) + CRUNCH_OUTPUT_SUFFIX # Preload/embed the .crn version instead of the .dds version, but use the .dds suffix for the target file in the virtual FS. file_['srcpath'] = src_crunch_name try: # Do not crunch if crunched version exists and is more recent than dds source crunch_time = os.stat(src_crunch_name).st_mtime dds_time = os.stat(src_dds_name).st_mtime if dds_time < crunch_time: continue except: pass # if one of them does not exist, continue on # guess at format. this lets us tell crunch to not try to be clever and use odd formats like DXT5_AGBR try: format = Popen(['file', file_['srcpath']],
decrunchCallbacks[msg.data.callbackID] = null; }; function requestDecrunch(filename, data, callback) { decrunchWorker.postMessage({ filename: filename, data: data, callbackID: decrunchCallbacks.length }); decrunchCallbacks.push(callback); } ''' for file_ in data_files: if file_['name'].endswith(CRUNCH_INPUT_SUFFIX): # Do not crunch if crunched version exists and is more recent than dds source crunch_name = unsuffixed(file_['name']) + CRUNCH_OUTPUT_SUFFIX file_['localname'] = crunch_name try: crunch_time = os.stat(crunch_name).st_mtime dds_time = os.stat(file_['name']).st_mtime if dds_time < crunch_time: continue except: pass # if one of them does not exist, continue on # guess at format. this lets us tell crunch to not try to be clever and use odd formats like DXT5_AGBR try: format = Popen(['file', file_['name']], stdout=PIPE).communicate()[0] if 'DXT5' in format: format = ['-dxt5'] elif 'DXT1' in format: format = ['-dxt1']
decrunchCallbacks[msg.data.callbackID] = null; }; function requestDecrunch(filename, data, callback) { decrunchWorker.postMessage({ filename: filename, data: data, callbackID: decrunchCallbacks.length }); decrunchCallbacks.push(callback); } ''' for file_ in data_files: if file_['name'].endswith(CRUNCH_INPUT_SUFFIX): # Do not crunch if crunched version exists and is more recent than dds source crunch_name = unsuffixed(file_['name']) + CRUNCH_OUTPUT_SUFFIX file_['localname'] = crunch_name try: crunch_time = os.stat(crunch_name).st_mtime dds_time = os.stat(file_['name']).st_mtime if dds_time < crunch_time: continue except: pass # if one of them does not exist, continue on # guess at format. this lets us tell crunch to not try to be clever and use odd formats like DXT5_AGBR try: format = Popen(['file', file_['name']], stdout=PIPE).communicate()[0] if 'DXT5' in format: format = ['-dxt5'] elif 'DXT1' in format:
''' import os, sys from subprocess import Popen, PIPE, STDOUT sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')] import shared, jsrun # creduce will only pass the filename of the C file as the first arg, so other # configuration options will have to be hardcoded. CSMITH_CFLAGS = ['-I', os.path.join(os.environ['CSMITH_PATH'], 'runtime')] ENGINE = shared.JS_ENGINES[0] EMCC_ARGS = ['-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1'] filename = sys.argv[1] obj_filename = shared.unsuffixed(filename) js_filename = obj_filename + '.js' print 'testing file', filename try: print '2) Compile natively' shared.run_process([shared.CLANG_CC, '-O2', filename, '-o', obj_filename] + CSMITH_CFLAGS) print '3) Run natively' correct = jsrun.timeout_run(Popen([obj_filename], stdout=PIPE, stderr=PIPE), 3) except Exception, e: print 'Failed or infinite looping in native, skipping', e sys.exit(1) # boring print '4) Compile JS-ly and compare' def try_js(args):