Example #1
0
						self.extra_source_inclusions(fullpath)
					if fp[1] == '.js':
						relative = prefix[1:]
						js_contents = self.make_function_from_file(fullpath, pack=False)
						if relative!='':
							key = "%s_%s" % (relative,f)
						else:
							key = f
						key = key.replace('.js','').replace('\\','_').replace('/','_').replace(' ','_').replace('.','_')
						self.js_files[fullpath] = (key, js_contents)
		if compile_bytecode:
			self.compile_into_bytecode(self.js_files)

if __name__ == "__main__":
	if len(sys.argv) != 2:
		print "Usage: %s <projectdir>" % sys.argv[0]
		sys.exit(1)

	project_dir = os.path.expanduser(sys.argv[1])
	resources_dir = os.path.join(project_dir, 'Resources')
	root_dir = os.path.join(project_dir, 'build', 'android')
	destdir = os.path.join(root_dir, 'bin', 'classes')
	sys.path.append("..")
	from tiapp import TiAppXML
	tiapp = TiAppXML(os.path.join(project_dir, 'tiapp.xml'))

	c = Compiler(tiapp, resources_dir, 'java', destdir, root_dir)
	project_deltafy = Deltafy(resources_dir)
	project_deltas = project_deltafy.scan()
	c.compile()
Example #2
0
                            key = "%s_%s" % (relative, f)
                        else:
                            key = f
                        key = key.replace('.js', '').replace(
                            '\\',
                            '_').replace('/',
                                         '_').replace(' ',
                                                      '_').replace('.', '_')
                        self.js_files[fullpath] = (key, js_contents)
        if compile_bytecode:
            self.compile_into_bytecode(self.js_files)


if __name__ == "__main__":
    if len(sys.argv) != 2:
        print "Usage: %s <projectdir>" % sys.argv[0]
        sys.exit(1)

    project_dir = os.path.expanduser(sys.argv[1])
    resources_dir = os.path.join(project_dir, 'Resources')
    root_dir = os.path.join(project_dir, 'build', 'android')
    destdir = os.path.join(root_dir, 'bin', 'classes')
    sys.path.append("..")
    from tiapp import TiAppXML
    tiapp = TiAppXML(os.path.join(project_dir, 'tiapp.xml'))

    c = Compiler(tiapp, resources_dir, 'java', destdir, root_dir)
    project_deltafy = Deltafy(resources_dir)
    project_deltas = project_deltafy.scan()
    c.compile()
Example #3
0
class DeltafyTests(unittest.TestCase):
	def setUp(self):
		self.d = Deltafy(tests_dir)
		self.deltas = self.d.scan()
	
	def touch(self, file):
		open(file, 'w').write("#")
	
	file_paths = [
		os.path.join(tests_dir, 'dir1', 'file1.txt'),
		os.path.join(tests_dir, 'dir1', '.ignore', 'file1.txt'),
		os.path.join(tests_dir, 'dir1', 'subdir1', 'file1.txt'),
		os.path.join(tests_dir, 'dir1', 'subdir1', 'ignore.txt'),
		os.path.join(tests_dir, 'dir1', 'subdir1', '.ignore', 'file1.txt'),
		os.path.join(tests_dir, 'dir2', 'file1.txt') ]
	
	def touch_all_files(self):
		for file_path in self.file_paths:
			self.touch(file_path)
	
	def test_initial_pass(self):
		self.assertEquals(len(self.deltas), len(self.file_paths))
		for file_path in self.file_paths:
			self.assertTrue(self.deltas.has_path(file_path))	

	def test_second_pass(self):
		self.assertEquals(len(self.deltas), 0)
	
	def test_file_modified(self):
		file_path = os.path.join(tests_dir, 'dir1', 'subdir1', 'file1.txt')
		open(file_path, 'w').write("change")
		self.deltas = self.d.scan()
		self.assertEquals(len(self.deltas), 1)
		self.assertEquals(self.deltas[0].get_path(), file_path)
		self.assertEquals(self.deltas[0].get_status(), Delta.MODIFIED)
	
	def test_file_created(self):
		file_path = os.path.join(tests_dir, 'dir2', 'file2.txt')
		self.touch(file_path)
		self.deltas = self.d.scan()
		self.assertEquals(len(self.deltas), 1)
		self.assertEquals(self.deltas[0].get_path(), file_path)
		self.assertEquals(self.deltas[0].get_status(), Delta.CREATED)
		self.assertTrue(self.deltas.has_path(file_path))
		self.assertTrue(self.deltas.is_updated(file_path))
	
	def test_file_deleted(self):
		file_path = os.path.join(tests_dir, 'dir2', 'file2.txt')
		os.unlink(file_path)
		self.deltas = self.d.scan()
		self.assertEquals(len(self.deltas), 1)
		self.assertEquals(self.deltas[0].get_path(), file_path)
		self.assertEquals(self.deltas[0].get_status(), Delta.DELETED)
	
	def test_files_modified(self):
		# modified time resolution is 1 second
		time.sleep(1)
		self.touch_all_files()
		
		self.deltas = self.d.scan()
		self.assertEquals(len(self.deltas), len(self.file_paths))
		i = 0
		for file_path in self.file_paths:
			self.assertTrue(self.deltas.has_path(file_path))
			self.assertTrue(self.deltas.is_updated(file_path))
			i+=1
	
	def test_exclude_files(self):
		time.sleep(1)
		
		exclude_dirs = ['.ignore']
		exclude_files = ['ignore.txt']
		def include(path, isfile):
			if not isfile and os.path.basename(path) in exclude_dirs: return False
			elif isfile and os.path.basename(path) in exclude_files: return False
			return True
		
		self.d = Deltafy(tests_dir, include_callback=include)
		self.touch_all_files()
		self.deltas = self.d.scan()
		
		self.assertEquals(len(self.deltas), 3)
		self.assertEquals(self.deltas[0].get_path(), self.file_paths[0])
		self.assertEquals(self.deltas[1].get_path(), self.file_paths[2])
		self.assertEquals(self.deltas[2].get_path(), self.file_paths[5])
	
	def test_clear(self):
		self.d.clear_state()
		paths = self.d.get_paths()
		self.assertEquals(len(paths), 0)
		deltas = self.d.scan()
		self.assertEquals(len(deltas), len(self.file_paths))