Work on scripts.

master
Dominik Deák 5 years ago
parent 350611b26e
commit ac1c5e53c2
No known key found for this signature in database
GPG Key ID: 85514EC0CCE7007C
  1. 115
      Scripts/Detail/Config.py
  2. 6
      Scripts/build.py
  3. 3
      Scripts/config.txt

@ -5,39 +5,36 @@ import os, platform, configparser
import Detail.Utility as utility import Detail.Utility as utility
class Configuration: class Configuration( configparser.ConfigParser ):
upstreamURL = ""
toplevelPath = ""
synergyCorePath = ""
synergyBuildPath = ""
synergyVersionPath = ""
binariesPath = ""
toolsPath = ""
libQtPath = ""
vcvarsallPath = ""
cmakeGenerator = ""
# Constructor # Constructor
def __init__( self, configPath ):
# parser = configparser.ConfigParser def __init__( self, configPath ):
super().__init__( dict_type = dict, allow_no_value = True ) defaults = {
"upstreamURL" : "",
"toplevelPath" : "",
"synergyCorePath" : "",
"synergyBuildPath" : "",
"synergyVersionPath" : "",
"binariesPath" : "",
"toolsPath" : "",
"libQtPath" : "",
"vcvarsallPath" : "",
"cmakeGenerator" : "",
}
super().__init__( dict_type = dict, allow_no_value = True, default_section = "All", defaults = defaults )
self.read( configPath ) self.read( configPath )
self.__validateToplevelPath() def validateToplevelPath( config ):
self.__validateConfigPaths()
# Validation
def __validateToplevelPath( self ):
utility.printHeading( "Git configuration..." ) utility.printHeading( "Git configuration..." )
upstreamURL = self.get( "Common", "upstreamURL" ) section = platform.system();
upstreamURL = config[ section ][ "upstreamURL" ]
queriedURL = utility.captureCommandOutput( "git config --get remote.origin.url" ) queriedURL = utility.captureCommandOutput( "git config --get remote.origin.url" )
toplevelPath = utility.captureCommandOutput( "git rev-parse --show-toplevel" ) toplevelPath = utility.captureCommandOutput( "git rev-parse --show-toplevel" )
@ -46,72 +43,62 @@ class Configuration:
utility.printItem( "queriedURL: ", queriedURL ) utility.printItem( "queriedURL: ", queriedURL )
if not os.path.exists( toplevelPath ): if not os.path.exists( toplevelPath ):
utility.printError( "Git top level path does not exist: " + toplevelPath ) utility.printError( "Git top level path does not exist:\n\t", toplevelPath )
raise SystemExit( 1 ) raise SystemExit( 1 )
if queriedURL != upstreamURL: if queriedURL != upstreamURL:
utility.printError( "The upstream URL at the current working directory does not match project upstream URL: " + queriedURL ) utility.printError( "The upstream URL at the current working directory does not match project upstream URL:\n\t", queriedURL )
raise SystemExit( 1 ) raise SystemExit( 1 )
self.set( "Common", "toplevelPath", toplevelPath ) config[ section ][ "toplevelPath" ] = toplevelPath
def __validateConfigPath( self, sectionName, pathName, mustExist = True, isInternal = True ): def validateConfigPaths( config ):
path = self.get( sectionName, pathName, fallback = None ) def resolvePath( config, name, mustExist = True ):
if path == None: section = platform.system();
utility.printError( "Configuration [" + sectionName + "][" + pathName + "] was not defined." ) path = config[ section ][ name ]
raise SystemExit( 1 )
if isInternal:
toplevelPath = self.get( "Common", "toplevelPath" )
path = utility.joinPath( toplevelPath, path )
prefixPath = os.path.commonprefix( [ toplevelPath, path ] )
if not os.path.samefile( toplevelPath, prefixPath ):
utility.printError( "Path was not resolved within top-level path scope: " + path )
raise SystemExit( 1 )
self.set( sectionName, pathName, path ) if path != "":
utility.printItem( pathName + ": ", path ) path = utility.joinPath( config[ section ][ "toplevelPath" ], path )
utility.printItem( name + ": ", path )
if not os.path.exists( path ): if not os.path.exists( path ):
if mustExist: if mustExist:
utility.printError( "Required path does not exist: " + path ) utility.printError( "Required path does not exist:\n\t", path )
raise SystemExit( 1 ) raise SystemExit( 1 )
else: else:
utility.printWarning( "Path does not exist: " + path ) utility.printWarning( "Path does not exist:\n\t", path )
def __validateConfigPaths( self ): config[ section ][ name ] = path
utility.printHeading( "Path configuration..." ) utility.printHeading( "Path configuration..." )
self.__validateConfigPath( "Common", "synergyCorePath" ) resolvePath( config, "synergyCorePath" )
self.__validateConfigPath( "Common", "synergyBuildPath", mustExist = False ) resolvePath( config, "synergyBuildPath", mustExist = False )
self.__validateConfigPath( "Common", "binariesPath" ) resolvePath( config, "synergyVersionPath", mustExist = False )
self.__validateConfigPath( "Common", "toolsPath" ) resolvePath( config, "binariesPath" )
resolvePath( config, "toolsPath" )
self.__validateConfigPath( platform.system(), "synergyVersionPath", mustExist = False ) resolvePath( config, "libQtPath" )
resolvePath( config, "vcvarsallPath" )
if platform.system() == "Windows": validateToplevelPath( self )
self.__validateConfigPath( platform.system(), "libQtPath", isInternal = False ) validateConfigPaths( self )
self.__validateConfigPath( platform.system(), "vcvarsallPath", isInternal = False )
elif platform.system() == "Darwin":
self.__validateConfigPath( platform.system(), "libQtPath", isInternal = False )
# Convenience accessors # Convenience accessors
def toplevelPath( self ): def toplevelPath( self ):
return self.get( "Common", "toplevelPath" ) return self.get( platform.system(), "toplevelPath" )
def synergyCorePath( self ): def synergyCorePath( self ):
return self.get( "Common", "synergyCorePath" ) return self.get( platform.system(), "synergyCorePath" )
def synergyBuildPath( self ): def synergyBuildPath( self ):
return self.get( "Common", "synergyBuildPath" ) return self.get( platform.system(), "synergyBuildPath" )
def synergyVersionPath( self ): def synergyVersionPath( self ):
@ -119,23 +106,23 @@ class Configuration:
def binariesPath( self ): def binariesPath( self ):
return self.get( "Common", "binariesPath" ) return self.get( platform.system(), "binariesPath" )
def toolsPath( self ): def toolsPath( self ):
return self.get( "Common", "toolsPath" ) return self.get( platform.system(), "toolsPath" )
def libQtPath( self ): def libQtPath( self ):
return self.get( platform.system(), "libQtPath", fallback = "" ) return self.get( platform.system(), "libQtPath" )
def vcvarsallPath( self ): def vcvarsallPath( self ):
return self.get( platform.system(), "vcvarsallPath", fallback = "" ) return self.get( platform.system(), "vcvarsallPath" )
def cmakeGenerator( self ): def cmakeGenerator( self ):
return self.get( platform.system(), "cmakeGenerator", fallback = "" ) return self.get( platform.system(), "cmakeGenerator" )
scriptPath = utility.joinPath( utility.basePathAtSource( __file__ ), ".." ) scriptPath = utility.joinPath( utility.basePathAtSource( __file__ ), ".." )
configPath = utility.joinPath( scriptPath, "config.txt" ) configPath = utility.joinPath( scriptPath, "config.txt" )

@ -4,9 +4,9 @@
import Detail.Build import Detail.Build
# b = Detail.Build.BuildSystem() b = Detail.Build.BuildSystem()
# b.configure() b.configure()
# b.make() b.make()
# b.clean() # b.clean()

@ -1,7 +1,6 @@
[Common] [All]
upstreamURL = https://github.com/DEAKSoftware/Synergy-Binaries.git upstreamURL = https://github.com/DEAKSoftware/Synergy-Binaries.git
synergyCorePath = ./Synergy-Core synergyCorePath = ./Synergy-Core
synergyBuildPath = ./Synergy-Core/build synergyBuildPath = ./Synergy-Core/build
synergyVersionPath = ./Synergy-Core/build/version synergyVersionPath = ./Synergy-Core/build/version

Loading…
Cancel
Save