예제 #1
0
def convertToPVR(src, dst=None, **option):
    if app.getPlatformName() == 'osx':
        app.getPath('support/osx/pvrtc/texturetool'),
        arglist = [
            '-e',
            'PVRTC',
            '-f',
            'PVR',
            '--channel-weighting-linear',
        ]

        bbp = option.get('bbp', 4)
        if bbp == 4:
            arglist += ['--bits-per-pixel-4']
        else:
            arglist += ['--bits-per-pixel-2']

        if not dst:
            dst = src
        arglist += [
            '-o',
            dst,
            src,
        ]
        print 'convert to pvr %s -> %s' % (src, dst)
        return subprocess.call(arglist)
    else:
        logging.error('not supported!')
예제 #2
0
def run(**option):
    FNULL = open(os.devnull, 'wb')
    project = app.getProject()
    assert project.isLoaded()
    os.chdir(project.getHostPath())
    # if option.get( 'clean-bin', False ):
    # 	if sys.platform == 'darwin':
    # 		pass
    # 	else:
    # 		pass
    # 		#TODO
    # 	return 0

    arglist = []
    arglist += [app.getPythonPath(), app.getPath('support/waf/waf')]

    #check configure
    code = subprocess.call(arglist + ['list'], stdout=FNULL, stderr=FNULL)
    if code != 0:
        code = subprocess.call(arglist + ['configure'])
        if code != 0:
            logging.error('cannot configure building ')
            return -1

    if option.get('verbose', False):
        arglist.append('-v')

    if option.get('configure', False):
        subprocess.call(arglist + ['configure'])

    elif option.get('clean', False):
        arglist.append('clean')
        code = subprocess.call(arglist)

    else:
        targets = option.get('targets', ['osx'])
        if targets == 'native':
            if sys.platform == 'darwin':
                targets = ['osx', 'python']
            else:
                targets = ['win', 'python']
        config = option.get('profile', 'debug')
        for target in targets:
            suffix = '-%s-%s' % (target, config)
            arglist += ['build' + suffix]
            arglist += ['install' + suffix]
            try:
                code = subprocess.call(arglist)
                if code != 0:
                    logging.error('abnormal return code: %d ' % code)
                    return code
                else:
                    print '%s building completed' % target
                    return 0
            except Exception, e:
                logging.error('cannot build host: %s ' % e)
                return -1
예제 #3
0
파일: Build.py 프로젝트: pixpil/gii
def run( **option ):
	FNULL = open(os.devnull, 'wb')
	project = app.getProject()
	assert project.isLoaded()
	os.chdir( project.getHostPath() )
	# if option.get( 'clean-bin', False ):
	# 	if sys.platform == 'darwin':
	# 		pass	
	# 	else:
	# 		pass
	# 		#TODO	
	# 	return 0

	arglist = []
	arglist += [ app.getPythonPath(), app.getPath( 'support/waf/waf' ) ]

	#check configure
	code = subprocess.call( arglist + ['list'], stdout = FNULL, stderr = FNULL )
	if code != 0:
		code = subprocess.call( arglist + ['configure'] )
		if code != 0:
			logging.error( 'cannot configure building ' )
			return -1

	if option.get( 'verbose', False ):
		arglist.append( '-v' )
	
	if option.get( 'configure', False ):
		subprocess.call( arglist + ['configure'] )

	elif option.get( 'clean', False ):
		arglist.append( 'clean' )
		code = subprocess.call( arglist )

	else:
		targets = option.get( 'targets', [ 'osx' ] )
		if targets == 'native':
			if sys.platform == 'darwin':
				targets = [ 'osx', 'python' ]
			else:
				targets = [ 'win', 'python' ]		
		config = option.get( 'profile', 'debug' )
		for target in targets:
			suffix = '-%s-%s' % ( target, config )
			arglist += [ 'build' + suffix ]
			arglist += [ 'install' + suffix ]
			try:
				code = subprocess.call( arglist )
				if code!=0:
					logging.error( 'abnormal return code: %d ' % code)
					return code
				else:
					print '%s building completed' % target
					return 0
			except Exception, e:
				logging.error( 'cannot build host: %s ' % e)
				return -1
예제 #4
0
def convertToWebP(src, dst=None, **option):
    if app.getPlatformName() == 'osx':
        cwebp = app.getPath('support/osx/webp/cwebp')
    elif app.getPlatformName() == 'win':
        cwebp = app.getPath('support/win/webp/cwebp.exe')

    arglist = [
        cwebp, '-quiet'
        # '-hint', 'photo'
    ]
    quality = option.get('quality', 100)
    if quality == 'lossless':
        arglist += ['-lossless']
    else:
        arglist += ['-q', str(quality)]
    if not dst:
        dst = src
    arglist += [src, '-o', dst]

    # print 'convert to webp %s -> %s' % ( src, dst )
    # if src == dst: return #SKIP
    return subprocess.call(arglist)
예제 #5
0
파일: IOSDevice.py 프로젝트: pixpil/gii
 def __init__(self, deviceItem):
     tool = app.getPath('support/deploy/ios-deploy')
     arglist = [tool]
     localPath = app.getProject().getHostPath(
         'ios/build/Release-iphoneos/YAKA.app')
     arglist += ['--id', deviceItem.getId()]
     arglist += ['--bundle', localPath]
     arglist += ['--debug']
     try:
         code = subprocess.call(arglist)
         if code != 0: return code
     except Exception as e:
         logging.error('error in debugging device: %s ' % e)
         return -1
예제 #6
0
파일: Build.py 프로젝트: pixpil/gii
def run( **option ):
	FNULL = open(os.devnull, 'wb')
	project = app.getProject()
	assert project.isLoaded()
	os.chdir( project.getHostPath() )
	# if option.get( 'clean-bin', False ):
	# 	if sys.platform == 'darwin':
	# 		pass	
	# 	else:
	# 		pass
	# 		#TODO	
	# 	return 0
	buildEnv = os.environ.copy()
	globalBuildEnv = app.getUserSetting( 'build_env', None )
	if globalBuildEnv:
		for k, v in globalBuildEnv.items():
			buildEnv[ k ] = v
	projectBuildEnv = project.getUserSetting( 'build_env', None )
	if projectBuildEnv:
		for k, v in projectBuildEnv.items():
			buildEnv[ k ] = v

	buildEnv[ 'JOBS' ] = '8'
	WAFCmd = [ app.getPythonPath(), app.getPath( 'support/common/%s/waf' % WAF_NAME ) ]
	def callWAF( cmd, *args, **kwargs ):
		kwargs[ "env" ] = buildEnv
		if isinstance( cmd, list ):
			arglist = WAFCmd + cmd + list( args )
		else:
			arglist = WAFCmd + [ cmd ] + list( args )
		return subprocess.call( arglist, **kwargs )

	#check configure
	# code = callWAF( 'list', stdout = FNULL, stderr = FNULL )
	# if code != 0:
	# 	code = callWAF( 'configure' )
	# 	if code != 0:
	# 		logging.error( 'cannot configure building ' )
	# 		return -1

	#main body
	building = True
	cmds = []
	args = []
	
	#misc settings
	if option.get( 'verbose', False ):
		args.append( '-v' )

	args.append( '-j%d' % max( 2, multiprocessing.cpu_count()) )
	#configure
	if option.get( 'configure', False ):
		return callWAF( 'configure', *args )

	#commands
	if option.get( 'clean', False ):
		cmds += [ 'clean' ]

	if option.get( 'dist', False ):
		cmds += [ 'dist' ]

	if option.get( 'project', False ):
		cmds += [ 'project' ]

	else:
		if option.get( 'build', True ):
			cmds += [ 'build' ]

		if option.get( 'install', True ):
			cmds += [ 'install' ]


	targets = option.get( 'targets', [ 'host' ] )		

	if isinstance( targets, str ):
		targets = [ targets ]

	#expand native
	if 'host' in targets:
		targets.remove( 'host' )
		if platform.system() == 'Darwin':
			if not ( 'osx' in targets ):
				targets.append( 'osx' )
				
		elif platform.system() == 'Windows':
			if not ( 'win' in targets ):
				targets.append( 'win' )

		elif platform.system() == 'Linux':
			if not ( 'linux' in targets ):
				targets.append( 'linux' )

	if 'native' in targets:
		targets.remove( 'native' )
		if platform.system() == 'Darwin':
			if not ( 'osx' in targets ):
				targets.append( 'osx' )
			if not ( 'python' in targets ):
				targets.append( 'python' )
				
		elif platform.system() == 'Windows':
			if not ( 'win' in targets ):
				targets.append( 'win' )
			if not ( 'python' in targets ):
				targets.append( 'python' )

		elif platform.system() == 'Linux':
			if not ( 'linux' in targets ):
				targets.append( 'linux' )

	build_type = option.get( 'build_type', 'debug' )

	cmdList = []
	for target in targets:
		contextName = '%s-%s' % ( target, build_type )
		suffix = '-' + contextName
		for cmd in cmds:
			cmdList += [ cmd + suffix ]
	print( cmdList )
	return callWAF( cmdList, *args )