You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.9 KiB

#!/bin/echo "This module must be imported by other Python scripts."
import os, platform, configparser
import Detail.Utility as utility
4 years ago
class Configuration( configparser.ConfigParser ):
# Constructor
4 years ago
def __init__( self, configPath ):
4 years ago
4 years ago
defaults = {
"upstreamURL" : "",
"toplevelPath" : "",
"synergyCorePath" : "",
"synergyBuildPath" : "",
"synergyVersionPath" : "",
"binariesPath" : "",
"toolsPath" : "",
"libQtPath" : "",
"vcvarsallPath" : "",
"cmakeGenerator" : "",
4 years ago
"linuxdeployURL" : "",
4 years ago
}
super().__init__( dict_type = dict, allow_no_value = True, default_section = "All", defaults = defaults )
self.read( configPath )
4 years ago
def validateToplevelPath( config ):
4 years ago
utility.printHeading( "Git configuration..." )
4 years ago
section = platform.system();
4 years ago
upstreamURL = config[ section ][ "upstreamURL" ]
queriedURL = utility.captureCommandOutput( "git config --get remote.origin.url" )
toplevelPath = utility.captureCommandOutput( "git rev-parse --show-toplevel" )
4 years ago
utility.printItem( "toplevelPath: ", toplevelPath )
utility.printItem( "upstreamURL: ", upstreamURL )
utility.printItem( "queriedURL: ", queriedURL )
4 years ago
if not os.path.exists( toplevelPath ):
utility.printError( "Git top level path does not exist:\n\t", toplevelPath )
raise SystemExit( 1 )
4 years ago
if queriedURL != upstreamURL:
utility.printError( "The upstream URL at the current working directory does not match project upstream URL:\n\t", queriedURL )
raise SystemExit( 1 )
4 years ago
config[ section ][ "toplevelPath" ] = toplevelPath
4 years ago
def validateConfigPaths( config ):
4 years ago
utility.printHeading( "Path configuration..." )
4 years ago
def resolvePath( config, name, mustExist = True ):
4 years ago
section = platform.system();
path = config[ section ][ name ]
4 years ago
if path != "":
path = utility.joinPath( config[ section ][ "toplevelPath" ], path )
utility.printItem( name + ": ", path )
4 years ago
if not os.path.exists( path ) and mustExist:
utility.printError( "Required path does not exist:\n\t", path )
raise SystemExit( 1 )
4 years ago
config[ section ][ name ] = path
4 years ago
resolvePath( config, "synergyCorePath" )
resolvePath( config, "synergyBuildPath", mustExist = False )
resolvePath( config, "synergyVersionPath", mustExist = False )
resolvePath( config, "binariesPath" )
resolvePath( config, "toolsPath" )
resolvePath( config, "libQtPath" )
resolvePath( config, "vcvarsallPath" )
4 years ago
validateToplevelPath( self )
validateConfigPaths( self )
# Convenience accessors
4 years ago
def toplevelPath( self ):
4 years ago
return self.get( platform.system(), "toplevelPath" )
def synergyCorePath( self ):
4 years ago
return self.get( platform.system(), "synergyCorePath" )
def synergyBuildPath( self ):
4 years ago
return self.get( platform.system(), "synergyBuildPath" )
def synergyVersionPath( self ):
return self.get( platform.system(), "synergyVersionPath" )
def binariesPath( self ):
4 years ago
return self.get( platform.system(), "binariesPath" )
def toolsPath( self ):
4 years ago
return self.get( platform.system(), "toolsPath" )
def libQtPath( self ):
4 years ago
return self.get( platform.system(), "libQtPath" )
def vcvarsallPath( self ):
4 years ago
return self.get( platform.system(), "vcvarsallPath" )
def cmakeGenerator( self ):
4 years ago
return self.get( platform.system(), "cmakeGenerator" )
4 years ago
def linuxdeployURL( self ):
return self.get( platform.system(), "linuxdeployURL" )
scriptPath = utility.joinPath( utility.basePathAtSource( __file__ ), ".." )
configPath = utility.joinPath( scriptPath, "config.txt" )
config = Configuration( configPath )