Ejemplo n.º 1
0
def main():
    import argparse

    parser = argparse.ArgumentParser(description='Projeny Editor API')
    parser.add_argument("configPath", help="")
    parser.add_argument("project", help="")
    parser.add_argument('platform',
                        type=str,
                        choices=[x.lower() for x in Platforms.All],
                        help='')
    parser.add_argument('requestId',
                        type=str,
                        choices=[
                            'createProject', 'installRelease', 'listReleases',
                            'listProjects', 'listPackages', 'listDependencies',
                            'addPackage', 'setPackages', 'updateLinks',
                            'updateCustomSolution', 'openCustomSolution',
                            'openUnity', 'getPathVars'
                        ],
                        help='')
    parser.add_argument("param1", nargs='?', help="")
    parser.add_argument("param2", nargs='?', help="")
    parser.add_argument("param3", nargs='?', help="")

    args = parser.parse_args(sys.argv[1:])

    installBindings(args.configPath)
    Prj.installPlugins()

    Runner().run(args.project,
                 PlatformUtil.fromPlatformFolderName(args.platform),
                 args.requestId, args.param1, args.param2, args.param3)
Ejemplo n.º 2
0
    def setPathsForProjectPlatform(self, projectName, platform):

        self.setPathsForProject(projectName)

        self._varMgr.set('ShortPlatform', PlatformUtil.toPlatformFolderName(platform))

        self._varMgr.set('Platform', platform)

        self._varMgr.set('ProjectPlatformRoot', '[ProjectRoot]/[ShortProjectName]-[ShortPlatform]')
        self._varMgr.set('ProjectAssetsDir', '[ProjectPlatformRoot]/Assets')

        self._varMgr.set('UnityGeneratedProjectEditorPath', '[ProjectPlatformRoot]/[ShortProjectName]-[ShortPlatform].CSharp.Editor.Plugins.csproj')
        self._varMgr.set('UnityGeneratedProjectPath', '[ProjectPlatformRoot]/[ShortProjectName]-[ShortPlatform].CSharp.Plugins.csproj')

        # For reasons I don't understand, the unity generated project is named with 'Assembly' on some machines and not other
        # Problem due to unity version but for now just allow either or
        self._varMgr.set('UnityGeneratedProjectEditorPath2', '[ProjectPlatformRoot]/Assembly-CSharp-Editor-firstpass.csproj')
        self._varMgr.set('UnityGeneratedProjectPath2', '[ProjectPlatformRoot]/Assembly-CSharp-firstpass.csproj')

        self._varMgr.set('PluginsDir', '[ProjectAssetsDir]/Plugins')
        self._varMgr.set('PluginsAndroidDir', '[PluginsDir]/Android')
        self._varMgr.set('PluginsAndroidLibraryDir', '[PluginsDir]/Android/libs')
        self._varMgr.set('PluginsIosLibraryDir', '[PluginsDir]/iOS')
        self._varMgr.set('PluginsWebGlLibraryDir', '[PluginsDir]/WebGL')

        self._varMgr.set('StreamingAssetsDir', '[ProjectAssetsDir]/StreamingAssets')

        self._varMgr.set('IntermediateFilesDir', '[ProjectPlatformRoot]/obj')

        self._varMgr.set('SolutionPath', '[ProjectRoot]/[ProjectName]-[Platform].sln')
Ejemplo n.º 3
0
 def openUnity(self, projectName, platform):
     with self._log.heading('Opening Unity'):
         projectPath = self._sys.canonicalizePath(
             "[UnityProjectsDir]/{0}/{1}-{2}".format(
                 projectName,
                 self._commonSettings.getShortProjectName(projectName),
                 PlatformUtil.toPlatformFolderName(platform)))
         self._sys.executeNoWait(
             '"[UnityExePath]" -buildTarget {0} -projectPath "{1}"'.format(
                 self._getBuildTargetArg(platform), projectPath))
Ejemplo n.º 4
0
def main():
    import argparse

    parser = argparse.ArgumentParser(description='Projeny Editor API')
    parser.add_argument("configPath", help="")
    parser.add_argument("project", help="")
    parser.add_argument('platform', type=str, choices=[x.lower() for x in Platforms.All], help='')
    parser.add_argument('requestId', type=str, choices=['createProject', 'installRelease', 'listReleases', 'listProjects', 'listPackages', 'updateLinks', 'updateCustomSolution', 'openCustomSolution', 'openUnity', 'getPathVars'], help='')
    parser.add_argument("param1", nargs='?', help="")
    parser.add_argument("param2", nargs='?', help="")
    parser.add_argument("param3", nargs='?', help="")

    args = parser.parse_args(sys.argv[1:])

    installBindings(args.configPath)
    Prj.installPlugins()

    Runner().run(args.project, PlatformUtil.fromPlatformFolderName(args.platform), args.requestId, args.param1, args.param2, args.param3)
Ejemplo n.º 5
0
    def _getProjectAndPlatformFromFilePath(self, filePath):
        unityProjectsDir = self._sys.canonicalizePath(self._varMgr.expand('[UnityProjectsDir]'))
        filePath = self._sys.canonicalizePath(filePath)

        if not filePath.startswith(unityProjectsDir):
            raise Exception("The given file path is not within the UnityProjects directory")

        relativePath = filePath[len(unityProjectsDir)+1:]
        dirs = relativePath.split(os.path.sep)

        projectName = dirs[0]

        try:
            platformProjectDirName = dirs[1]
            platformDirName = platformProjectDirName[platformProjectDirName.rfind('-')+1:]

            platform = PlatformUtil.fromPlatformFolderName(platformDirName)
        except:
            platform = None

        return projectName, platform
Ejemplo n.º 6
0
    def runEditorFunctionRaw(self, projectName, platform, editorCommand,
                             extraArgs):

        logPath = self._varMgr.expandPath(UnityLogFileLocation)

        logWatcher = LogWatcher(logPath, self.onUnityLog)
        logWatcher.start()

        os.environ['ModestTreeBuildConfigOverride'] = "FromBuildScript"

        assertThat(self._varMgr.hasKey('UnityExePath'),
                   "Could not find path variable 'UnityExePath'")

        try:
            command = '"[UnityExePath]" -buildTarget {0} -projectPath "[UnityProjectsDir]/{1}/{2}-{3}"'.format(
                self._getBuildTargetArg(platform), projectName,
                self._commonSettings.getShortProjectName(projectName),
                PlatformUtil.toPlatformFolderName(platform))

            if editorCommand:
                command += ' -executeMethod ' + editorCommand

            command += ' ' + extraArgs

            self._sys.executeAndWait(command)
        except ProcessErrorCodeException as e:
            raise UnityReturnedErrorCodeException(
                "Error while running Unity!  Command returned with error code."
            )

        except:
            raise UnityUnknownErrorException(
                "Unknown error occurred while running Unity!")
        finally:
            logWatcher.stop()

            while not logWatcher.isDone:
                time.sleep(0.1)

            os.environ['ModestTreeBuildConfigOverride'] = ""
Ejemplo n.º 7
0
    def _initialize(self):
        self._platform = PlatformUtil.fromPlatformArgName(self._args.platform)

        if self._args.project and self._platform:
            self._packageMgr.setPathsForProjectPlatform(self._args.project, self._platform)
Ejemplo n.º 8
0
    def runEditorFunctionRaw(self, projectName, platform, editorCommand, extraArgs):

        logPath = self._varMgr.expandPath(UnityLogFileLocation)

        logWatcher = LogWatcher(logPath, self.onUnityLog)
        logWatcher.start()

        os.environ['ModestTreeBuildConfigOverride'] = "FromBuildScript"

        assertThat(self._varMgr.hasKey('UnityExePath'), "Could not find path variable 'UnityExePath'")

        try:
            command = '"[UnityExePath]" -buildTarget {0} -projectPath "[UnityProjectsDir]/{1}/{2}-{3}"'.format(self._getBuildTargetArg(platform), projectName, self._commonSettings.getShortProjectName(projectName), PlatformUtil.toPlatformFolderName(platform))

            if editorCommand:
                command += ' -executeMethod ' + editorCommand

            command += ' ' + extraArgs

            self._sys.executeAndWait(command)
        except ProcessErrorCodeException as e:
            raise UnityReturnedErrorCodeException("Error while running Unity!  Command returned with error code.")

        except:
            raise UnityUnknownErrorException("Unknown error occurred while running Unity!")
        finally:
            logWatcher.stop()

            while not logWatcher.isDone:
                time.sleep(0.1)

            os.environ['ModestTreeBuildConfigOverride'] = ""
Ejemplo n.º 9
0
 def openUnity(self, projectName, platform):
     with self._log.heading('Opening Unity'):
         projectPath = self._sys.canonicalizePath("[UnityProjectsDir]/{0}/{1}-{2}".format(projectName, self._commonSettings.getShortProjectName(projectName), PlatformUtil.toPlatformFolderName(platform)))
         self._sys.executeNoWait('"[UnityExePath]" -buildTarget {0} -projectPath "{1}"'.format(self._getBuildTargetArg(platform), projectPath))
Ejemplo n.º 10
0
    def _initialize(self):
        self._platform = PlatformUtil.fromPlatformArgName(self._args.platform)

        if self._args.project and self._platform:
            self._packageMgr.setPathsForProjectPlatform(
                self._args.project, self._platform)