Exemplo n.º 1
0
         def resolvePath( self, name, mustExist = True ):

            path = getattr( self, name )
            if not path: return

            path = utility.joinPath( self.toplevelPath, os.path.expanduser( path ) )

            utility.printItem( name + ": ", path )

            if not os.path.exists( path ) and mustExist:
               utility.printError( "Required path does not exist:\n\t", path )
               raise SystemExit( 1 )

            setattr( self, name, path )
Exemplo n.º 2
0
        def loadConfiguration(self, configPath):

            utility.printItem("configPath: ", configPath)

            parser = configparser.ConfigParser(dict_type=dict,
                                               allow_no_value=True,
                                               default_section="All")

            parser.read(configPath)

            section = platform.system()

            for name in self.propertyList():
                value = parser.get(section, name, fallback=getattr(self, name))
                setattr(self, name, value)
Exemplo n.º 3
0
def configureEnvironment():

    utility.printHeading("Configuring environment...")

    for name, value in config.propertyList().items():

        if value:
            print("\tSetting: ${" + utility.style.bold + name +
                  utility.style.none + "}")
            os.environ[name] = value
        else:
            print("\tUnused: " + utility.style.error + name +
                  utility.style.none)

    utility.printSuccess("Build environment variables are now set.")
Exemplo n.º 4
0
      def configurePlatformVersion( self ):

         if platform.system() == "Windows":

            self.platformVersion = "-".join( [ platform.system(), platform.release(), platform.machine() ] )

         else:

            import distro # TODO: Move this to global scope when distro supports Windows
            platformInfo = list( distro.linux_distribution( full_distribution_name = False ) )

            while "" in platformInfo:
               platformInfo.remove( "" )

            platformInfo.append( platform.machine() )
            self.platformVersion = "-".join( platformInfo )

         utility.printItem( "platformVersion: ", self.platformVersion )
Exemplo n.º 5
0
def configureSubmodules():

    utility.printHeading("Updating Git submodules...")

    os.chdir(config.toplevelPath)

    statusBefore = utility.captureCommandOutput("git submodule status")
    print(statusBefore)

    utility.runCommand("git submodule update --init --remote --recursive")

    statusAfter = utility.captureCommandOutput("git submodule status")
    print(statusAfter)

    if statusBefore != statusAfter:
        utility.printHeading("Updating product version...")
        config.updateProductVersion()

    utility.printSuccess("Git submodules are now up to date.")
Exemplo n.º 6
0
def buildProducts():

    utility.printHeading("Building products...")

    scripts = {
        "Darwin": "Scripts/Build/BuildDarwin.sh",
        "Linux": "Scripts/Build/BuildLinux.sh",
        "Windows": "Scripts\\Build\\BuildWindows.cmd",
    }

    scriptPath = utility.joinPath(config.toplevelPath,
                                  scripts[platform.system()])

    utility.runCommand('"' + scriptPath + '"')

    utility.printSuccess("Build completed successfully.")
Exemplo n.º 7
0
        def validateToplevelPath(self):

            queriedURL = utility.captureCommandOutput(
                "git config --get remote.origin.url")

            self.toplevelPath = utility.captureCommandOutput(
                "git rev-parse --show-toplevel")

            utility.printItem("toplevelPath: ", self.toplevelPath)
            utility.printItem("upstreamURL: ", self.upstreamURL)
            utility.printItem("queriedURL: ", queriedURL)

            if not os.path.exists(self.toplevelPath):
                utility.printError("Git top level path does not exist:\n\t",
                                   self.toplevelPath)
                raise SystemExit(1)

            if queriedURL != self.upstreamURL:
                utility.printError(
                    "The upstream URL at the current working directory does not match project upstream URL:\n\t",
                    queriedURL)
                raise SystemExit(1)
Exemplo n.º 8
0
    def __init__(self, configPath):
        def programOptions(self):

            parser = argparse.ArgumentParser(
                description=
                "This utility builds the Synergy-Core binaries. The product version is extracted from the most recent Git tag. One can also build older versions "
                "by checking out specific git tags, see options below.")

            parser.add_argument(
                "--checkout",
                dest="productCheckout",
                help=
                "Checkout and build a specific Git tag (or commit hash) for the Synergy-Core submodule."
            )

            for key, value in vars(parser.parse_args()).items():
                setattr(self, key, value)

        def loadConfiguration(self, configPath):

            utility.printItem("configPath: ", configPath)

            parser = configparser.ConfigParser(dict_type=dict,
                                               allow_no_value=True,
                                               default_section="All")

            parser.read(configPath)

            section = platform.system()

            for name in self.propertyList():
                value = parser.get(section, name, fallback=getattr(self, name))
                setattr(self, name, value)

        def validateToplevelPath(self):

            queriedURL = utility.captureCommandOutput(
                "git config --get remote.origin.url")

            self.toplevelPath = utility.captureCommandOutput(
                "git rev-parse --show-toplevel")

            utility.printItem("toplevelPath: ", self.toplevelPath)
            utility.printItem("upstreamURL: ", self.upstreamURL)
            utility.printItem("queriedURL: ", queriedURL)

            if not os.path.exists(self.toplevelPath):
                utility.printError("Git top level path does not exist:\n\t",
                                   self.toplevelPath)
                raise SystemExit(1)

            if queriedURL != self.upstreamURL:
                utility.printError(
                    "The upstream URL at the current working directory does not match project upstream URL:\n\t",
                    queriedURL)
                raise SystemExit(1)

        def validateConfigurationPaths(self):
            def resolvePath(self, name, mustExist=True):

                path = getattr(self, name)
                if not path: return

                path = utility.joinPath(self.toplevelPath,
                                        os.path.expanduser(path))

                utility.printItem(name + ": ", path)

                if not os.path.exists(path) and mustExist:
                    utility.printError("Required path does not exist:\n\t",
                                       path)
                    raise SystemExit(1)

                setattr(self, name, path)

            resolvePath(self, "productRepoPath")
            resolvePath(self, "productBuildPath", mustExist=False)
            resolvePath(self, "binariesPath")
            resolvePath(self, "toolsPath")
            resolvePath(self, "libQtPath")
            resolvePath(self, "vcvarsallPath")

        def configurePlatformVersion(self):

            if platform.system() == "Windows":

                self.platformVersion = "-".join([
                    platform.system(),
                    platform.release(),
                    platform.machine()
                ])

            else:

                import distro  # TODO: Move this to global scope when distro supports Windows
                platformInfo = list(
                    distro.linux_distribution(full_distribution_name=False))

                while "" in platformInfo:
                    platformInfo.remove("")

                platformInfo.append(platform.machine())
                self.platformVersion = "-".join(platformInfo)

            utility.printItem("platformVersion: ", self.platformVersion)

        def configureProductVersion(self):

            self.updateProductVersion()

        programOptions(self)

        utility.printHeading("Loading configuration...")

        loadConfiguration(self, configPath)

        utility.printHeading("Git configuration...")

        validateToplevelPath(self)

        utility.printHeading("Path configuration...")

        validateConfigurationPaths(self)

        utility.printHeading("Version configuration...")

        configurePlatformVersion(self)
        configureProductVersion(self)
Exemplo n.º 9
0
    def updateProductVersion(self):

        os.chdir(self.productRepoPath)

        lastTag = utility.captureCommandOutput(
            "git describe --tags --abbrev=0")

        matches = re.search("v?(\d+(?:\.\d+)+)-(\w+)", lastTag)

        if not matches:
            utility.printError(
                "Unable to extract version information from Git tags.")
            raise SystemExit(1)

        self.productVersion = matches.group(1)
        self.productStage = matches.group(2)
        self.productRevision = utility.captureCommandOutput(
            "git rev-parse --short=8 HEAD")
        self.productPackageName = "-".join([
            self.productName, self.productVersion, self.productStage,
            self.platformVersion
        ]).lower()

        utility.printItem("productVersion: ", self.productVersion)
        utility.printItem("productStage: ", self.productStage)
        utility.printItem("productRevision: ", self.productRevision)
        utility.printItem("productPackageName: ", self.productPackageName)

        os.chdir(self.toplevelPath)
Exemplo n.º 10
0
                "Unable to extract version information from Git tags.")
            raise SystemExit(1)

        self.productVersion = matches.group(1)
        self.productStage = matches.group(2)
        self.productRevision = utility.captureCommandOutput(
            "git rev-parse --short=8 HEAD")
        self.productPackageName = "-".join([
            self.productName, self.productVersion, self.productStage,
            self.platformVersion
        ]).lower()

        utility.printItem("productVersion: ", self.productVersion)
        utility.printItem("productStage: ", self.productStage)
        utility.printItem("productRevision: ", self.productRevision)
        utility.printItem("productPackageName: ", self.productPackageName)

        os.chdir(self.toplevelPath)

    # Property list

    def propertyList(self):

        return dict(
            (name, getattr(self, name)) for name in dir(self)
            if not callable(getattr(self, name)) and not name.startswith('__'))


config = Configuration(
    utility.joinPath(utility.basePathAtSource(__file__), "..", "config.txt"))
Exemplo n.º 11
0
#!/usr/bin/env python3

import os

from Detail.Config import config
import Detail.Utility as utility

utility.printHeading("Cleaning project...")

os.chdir(config.productRepoPath)

utility.runCommand("git clean -fdx")

os.chdir(config.toplevelPath)

# Clean with capital -X switch to preserve user-edited config files
utility.runCommand("git clean -fdX")
Exemplo n.º 12
0
   def __init__( self, configPath ):

      def loadConfiguration( self, configPath ):

         utility.printItem( "configPath: ", configPath )

         parser = configparser.ConfigParser(
            dict_type = dict,
            allow_no_value = True,
            default_section = "All" )

         parser.read( configPath )

         section = platform.system()

         for name in self.propertyList():
            value = parser.get( section, name, fallback = getattr( self, name ) )
            setattr( self, name, value )

      def validateToplevelPath( self ):

         queriedURL = utility.captureCommandOutput( "git config --get remote.origin.url" )

         self.toplevelPath = utility.captureCommandOutput( "git rev-parse --show-toplevel" )

         utility.printItem( "toplevelPath: ", self.toplevelPath )
         utility.printItem( "upstreamURL: ", self.upstreamURL )
         utility.printItem( "queriedURL: ", queriedURL )

         if not os.path.exists( self.toplevelPath ):
            utility.printError( "Git top level path does not exist:\n\t", self.toplevelPath )
            raise SystemExit( 1 )

         if queriedURL != self.upstreamURL:
            utility.printError( "The upstream URL at the current working directory does not match project upstream URL:\n\t", queriedURL )
            raise SystemExit( 1 )

      def validateConfigurationPaths( self ):

         def resolvePath( self, name, mustExist = True ):

            path = getattr( self, name )
            if not path: return

            path = utility.joinPath( self.toplevelPath, os.path.expanduser( path ) )

            utility.printItem( name + ": ", path )

            if not os.path.exists( path ) and mustExist:
               utility.printError( "Required path does not exist:\n\t", path )
               raise SystemExit( 1 )

            setattr( self, name, path )

         resolvePath( self, "productRepoPath" )
         resolvePath( self, "productBuildPath", mustExist = False )
         resolvePath( self, "productVersionPath", mustExist = False )
         resolvePath( self, "binariesPath" )
         resolvePath( self, "toolsPath" )
         resolvePath( self, "libQtPath" )
         resolvePath( self, "vcvarsallPath" )

      def configurePlatformVersion( self ):

         if platform.system() == "Windows":

            self.platformVersion = "-".join( [ platform.system(), platform.release(), platform.machine() ] )

         else:

            import distro # TODO: Move this to global scope when distro supports Windows
            platformInfo = list( distro.linux_distribution( full_distribution_name = False ) )

            while "" in platformInfo:
               platformInfo.remove( "" )

            platformInfo.append( platform.machine() )
            self.platformVersion = "-".join( platformInfo )

         utility.printItem( "platformVersion: ", self.platformVersion )

      def configureProductVersion( self ):

         self.updateProductVersion()

      utility.printHeading( "Loading configuration..." )

      loadConfiguration( self, configPath )

      utility.printHeading( "Git configuration..." )

      validateToplevelPath( self )

      utility.printHeading( "Path configuration..." )

      validateConfigurationPaths( self )

      utility.printHeading( "Version configuration..." )

      configurePlatformVersion( self )
      configureProductVersion( self )
Exemplo n.º 13
0
   def updateProductVersion( self ):

      if not os.path.exists( self.productVersionPath ):

         utility.printWarning( "Unable to determine product version at this time; version file was missing:\n\t", self.productVersionPath )

      else:

         versionFile = open( self.productVersionPath, "r" )
         versionData = versionFile.read()
         versionFile.close()

         versionParts = re.findall( r'set \(SYNERGY_VERSION_\w+ "?(\w+)"?\)', versionData )

         if len( versionParts ) != 4:
            printError( "Failed to extract version information." )
            raise SystemExit( 1 )

         self.productVersion = ".".join( versionParts[ 0:3 ] )
         self.productStage = versionParts[ 3 ]
         self.productRevision = utility.captureCommandOutput( "git rev-parse --short=8 HEAD" )

      self.productPackageName = "-".join( [ self.productName, self.productVersion, self.productStage, self.platformVersion ] ).lower()

      utility.printItem( "productVersion: ", self.productVersion )
      utility.printItem( "productStage: ", self.productStage )
      utility.printItem( "productRevision: ", self.productRevision )
      utility.printItem( "productPackageName: ", self.productPackageName )
Exemplo n.º 14
0
      else:

         versionFile = open( self.productVersionPath, "r" )
         versionData = versionFile.read()
         versionFile.close()

         versionParts = re.findall( r'set \(SYNERGY_VERSION_\w+ "?(\w+)"?\)', versionData )

         if len( versionParts ) != 4:
            printError( "Failed to extract version information." )
            raise SystemExit( 1 )

         self.productVersion = ".".join( versionParts[ 0:3 ] )
         self.productStage = versionParts[ 3 ]
         self.productRevision = utility.captureCommandOutput( "git rev-parse --short=8 HEAD" )

      self.productPackageName = "-".join( [ self.productName, self.productVersion, self.productStage, self.platformVersion ] ).lower()

      utility.printItem( "productVersion: ", self.productVersion )
      utility.printItem( "productStage: ", self.productStage )
      utility.printItem( "productRevision: ", self.productRevision )
      utility.printItem( "productPackageName: ", self.productPackageName )

   # Property list

   def propertyList( self ):

      return dict( ( name, getattr( self, name ) ) for name in dir( self ) if not callable( getattr( self, name ) ) and not name.startswith( '__' ) )

config = Configuration( utility.joinPath( utility.basePathAtSource( __file__ ), "..", "config.txt" ) )