Пример #1
0
def on_compiled(mode): # build, play, play_viewport, publish
    log.clear()
    sdk_path = armutils.get_sdk_path()
    wrd = bpy.data.worlds['Arm']

    # Print info
    if mode == 'publish':
        target_name = make_utils.get_kha_target(wrd.arm_project_target)
        print('Project published')
        files_path = armutils.get_fp() + '/build/' + target_name
        if target_name == 'html5':
            print('HTML5 files are located in ' + files_path)
        elif target_name == 'ios' or target_name == 'osx': # TODO: to macos
            print('XCode project files are located in ' + files_path + '-build')
        elif target_name == 'windows':
            print('VisualStudio 2015 project files are located in ' + files_path + '-build')
        elif target_name == 'android-native':
            print('Android Studio project files are located in ' + files_path + '-build/' + wrd.arm_project_name)
        else:
            print('Makefiles are located in ' + files_path + '-build')
        return

    # Launch project in new window
    elif mode =='play':
        if wrd.arm_play_runtime == 'Electron':
            electron_app_path = './build/electron.js'

            if armutils.get_os() == 'win':
                electron_path = sdk_path + 'win32/Kode Studio.exe'
            elif armutils.get_os() == 'mac':
                electron_path = sdk_path + 'Kode Studio.app/Contents/MacOS/Electron'
            else:
                electron_path = sdk_path + 'linux64/kodestudio'

            state.playproc = subprocess.Popen([electron_path, '--chromedebug', '--remote-debugging-port=9222', '--enable-logging', electron_app_path], stderr=subprocess.PIPE)
            watch_play()
        elif wrd.arm_play_runtime == 'Browser':
            # Start server
            os.chdir(armutils.get_fp())
            t = threading.Thread(name='localserver', target=lib.server.run)
            t.daemon = True
            t.start()
            html5_app_path = 'http://localhost:8040/build/html5'
            webbrowser.open(html5_app_path)
        elif wrd.arm_play_runtime == 'Krom':
            if armutils.get_os() == 'win':
                krom_location = sdk_path + '/win32/Krom/win32'
                krom_path = krom_location + '/Krom.exe'
            elif armutils.get_os() == 'mac':
                krom_location = sdk_path + '/Kode Studio.app/Contents/Krom/macos/Krom.app/Contents/MacOS'
                krom_path = krom_location + '/Krom'
            else:
                krom_location = sdk_path + '/linux64/Krom/linux'
                krom_path = krom_location + '/Krom'
            os.chdir(krom_location)
            state.playproc = subprocess.Popen([krom_path, armutils.get_fp() + '/build/window/krom', armutils.get_fp() + '/build/window/krom-resources'], stderr=subprocess.PIPE)
            watch_play()
Пример #2
0
def on_compiled(mode): # build, play, play_viewport, publish
    log.clear()
    sdk_path = armutils.get_sdk_path()

    # Print info
    if mode == 'publish':
        target_name = make_utils.get_kha_target(bpy.data.worlds['Arm'].arm_project_target)
        print('Project published')
        files_path = armutils.get_fp() + '/build/' + target_name
        if target_name == 'html5':
            print('HTML5 files are located in ' + files_path)
        elif target_name == 'ios' or target_name == 'osx': # TODO: to macos
            print('XCode project files are located in ' + files_path + '-build')
        elif target_name == 'windows':
            print('VisualStudio 2015 project files are located in ' + files_path + '-build')
        elif target_name == 'android-native':
            print('Android Studio project files are located in ' + files_path + '-build')
        else:
            print('Makefiles are located in ' + files_path + '-build')
        return

    # Launch project in new window
    elif mode =='play':
        wrd = bpy.data.worlds['Arm']
        if wrd.arm_play_runtime == 'Electron':
            electron_app_path = './build/electron.js'

            if armutils.get_os() == 'win':
                electron_path = sdk_path + 'win32/Kode Studio.exe'
            elif armutils.get_os() == 'mac':
                electron_path = sdk_path + 'Kode Studio.app/Contents/MacOS/Electron'
            else:
                electron_path = sdk_path + 'linux64/kodestudio'

            state.playproc = subprocess.Popen([electron_path, '--chromedebug', '--remote-debugging-port=9222', '--enable-logging', electron_app_path], stderr=subprocess.PIPE)
            watch_play()
        elif wrd.arm_play_runtime == 'Browser':
            # Start server
            os.chdir(armutils.get_fp())
            t = threading.Thread(name='localserver', target=lib.server.run)
            t.daemon = True
            t.start()
            html5_app_path = 'http://localhost:8040/build/html5'
            webbrowser.open(html5_app_path)
        elif wrd.arm_play_runtime == 'Krom':
            if armutils.get_os() == 'win':
                krom_location = sdk_path + '/win32/Krom/win32'
                krom_path = krom_location + '/Krom.exe'
            elif armutils.get_os() == 'mac':
                krom_location = sdk_path + '/Kode Studio.app/Contents/Krom/macos/Krom.app/Contents/MacOS'
                krom_path = krom_location + '/Krom'
            else:
                krom_location = sdk_path + '/linux64/Krom/linux'
                krom_path = krom_location + '/Krom'
            os.chdir(krom_location)
            state.playproc = subprocess.Popen([krom_path, armutils.get_fp() + '/build/window/krom', armutils.get_fp() + '/build/window/krom-resources'], stderr=subprocess.PIPE)
            watch_play()
Пример #3
0
def compile_project(target_name=None, is_publish=False, watch=False, patch=False):
    wrd = bpy.data.worlds['Arm']

    # Set build command
    if target_name == None:
        target_name = wrd.arm_project_target
    elif target_name == 'native':
        target_name = ''

    node_path = armutils.get_node_path()
    khamake_path = armutils.get_khamake_path()
    
    kha_target_name = make_utils.get_kha_target(target_name)
    cmd = [node_path, khamake_path, kha_target_name]

    ffmpeg_path = armutils.get_ffmpeg_path() # Path to binary
    if ffmpeg_path != '':
        cmd.append('--ffmpeg')
        cmd.append(ffmpeg_path) # '"' + ffmpeg_path + '"'

    if target_name == '' or target_name == '--run':
        cmd.append('-g')
        cmd.append(getattr(wrd, 'arm_gapi_' + armutils.get_os()))

    if kha_target_name == 'krom':
        if state.in_viewport:
            if armutils.glsl_version() >= 330:
                cmd.append('--shaderversion')
                cmd.append('330')
            else:
                cmd.append('--shaderversion')
                cmd.append('110')
        else:
            cmd.append('--to')
            cmd.append('build/window')

    # User defined commands
    cmd_text = wrd.arm_command_line
    if cmd_text != '':
        for s in bpy.data.texts[cmd_text].as_string().split(' '):
            cmd.append(s)

    if patch:
        if state.compileproc == None:
            # Quick build - disable krafix and haxe
            cmd.append('--nohaxe')
            cmd.append('--noshaders')
            cmd.append('--noproject')
            state.compileproc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
            if state.playproc == None:
                if state.in_viewport:
                    mode = 'play_viewport'
                else:
                    mode = 'play'
            else:
                mode = 'build'
            threading.Timer(0.1, watch_patch, [mode]).start()
            return state.compileproc
    elif watch:
        state.compileproc = subprocess.Popen(cmd)
        threading.Timer(0.1, watch_compile, ['build']).start()
        return state.compileproc
    else:
        return subprocess.Popen(cmd)
Пример #4
0
def compile_project(target_name=None, is_publish=False, watch=False, patch=False):
    sdk_path =  armutils.get_sdk_path()
    ffmpeg_path = armutils.get_ffmpeg_path()
    wrd = bpy.data.worlds['Arm']

    # Set build command
    if target_name == None:
        target_name = wrd.arm_project_target

    if armutils.get_os() == 'win':
        node_path = sdk_path + '/nodejs/node.exe'
        khamake_path = sdk_path + '/win32/Kha/make'
    elif armutils.get_os() == 'mac':
        node_path = sdk_path + '/nodejs/node-osx'
        khamake_path = sdk_path + '/Kode Studio.app/Contents/Kha/make'
    else:
        node_path = sdk_path + '/nodejs/node-linux64'
        khamake_path = sdk_path + '/linux64/Kha/make'
    
    kha_target_name = make_utils.get_kha_target(target_name)
    cmd = [node_path, khamake_path, kha_target_name]

    if ffmpeg_path != '':
        cmd.append('--ffmpeg')
        cmd.append('"' + ffmpeg_path + '"')

    if armutils.get_os() == 'win': # OpenGL for now
        cmd.append('-g')
        cmd.append('opengl2')

    if kha_target_name == 'krom':
        if state.in_viewport or patch:
            if armutils.glsl_version() >= 330:
                cmd.append('--shaderversion')
                cmd.append('330')
            else:
                cmd.append('--shaderversion')
                cmd.append('110')
        else:
            cmd.append('--to')
            cmd.append('build/window')

    # User defined commands
    cmd_text = wrd.arm_command_line
    if cmd_text != '':
        for s in bpy.data.texts[cmd_text].as_string().split(' '):
            cmd.append(s)

    if state.krom_running:
        if state.compileproc == None: # Already compiling
            # Patch running game, stay silent, disable krafix and haxe
            # cmd.append('--silent')
            cmd.append('--noproject')
            cmd.append('--haxe')
            cmd.append('""')
            cmd.append('--krafix')
            cmd.append('""')
            # Khamake throws error when krafix is not found, hide for now
            state.compileproc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
            threading.Timer(0.1, watch_patch).start()
            return state.compileproc
    elif watch == True:
        state.compileproc = subprocess.Popen(cmd)
        threading.Timer(0.1, watch_compile, ['build']).start()
        return state.compileproc
    else:
        return subprocess.Popen(cmd)