diff options
author | Max Linke <max_linke@gmx.de> | 2013-12-07 15:42:09 +0100 |
---|---|---|
committer | Max Linke <max_linke@gmx.de> | 2013-12-07 15:42:09 +0100 |
commit | e1ff6e6dedfc9f0ebd1e62ae03d04f99b02bbfd8 (patch) | |
tree | a3bb8609499ccc5803d2b996c3f557fd038d92fd /build/util.py | |
parent | bbd0885af8dbee7edbb942b12ed37035c1746101 (diff) |
make build script pep8 conform
I hate that my pep8 checker goes crazy everytime I open one of them
Diffstat (limited to 'build/util.py')
-rw-r--r-- | build/util.py | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/build/util.py b/build/util.py index d47ae31baf..9101a66746 100644 --- a/build/util.py +++ b/build/util.py @@ -1,9 +1,11 @@ from SCons import Script -import os, os.path, sys, platform +import os +import os.path import re CURRENT_VCS = None + def get_current_vcs(): if CURRENT_VCS is not None: return CURRENT_VCS @@ -11,18 +13,20 @@ def get_current_vcs(): return "git" return "tar" + def on_git(): cwd = os.getcwd() basename = " " while len(basename) > 0: try: - os.stat(os.path.join(cwd,".git")) + os.stat(os.path.join(cwd, ".git")) return True except: pass - cwd,basename = os.path.split(cwd) + cwd, basename = os.path.split(cwd) return False + def get_revision(): global CURRENT_VCS if CURRENT_VCS is None: @@ -33,6 +37,7 @@ def get_revision(): return "" return None + def get_modified(): global CURRENT_VCS if CURRENT_VCS is None: @@ -43,6 +48,7 @@ def get_modified(): return "" return None + def get_branch_name(): global CURRENT_VCS if CURRENT_VCS is None: @@ -53,6 +59,7 @@ def get_branch_name(): return "" return None + def export_source(source, dest): global CURRENT_VCS if CURRENT_VCS is None: @@ -61,11 +68,14 @@ def export_source(source, dest): return export_git(source, dest) return None + def get_git_revision(): return len(os.popen("git log --pretty=oneline --first-parent").read().splitlines()) + def get_git_modified(): - modified_matcher = re.compile("^#.*: (?P<filename>.*?)$") # note output might be translated + modified_matcher = re.compile( + "^#.*: (?P<filename>.*?)$") # note output might be translated modified_files = [] for line in os.popen("git status").read().splitlines(): match = modified_matcher.match(line) @@ -74,21 +84,26 @@ def get_git_modified(): modified_files.append(match['filename'].strip()) return "\n".join(modified_files) + def get_git_branch_name(): # this returns the branch name or 'HEAD' in case of detached HEAD - branch_name = os.popen("git rev-parse --abbrev-ref HEAD").readline().strip() + branch_name = os.popen( + "git rev-parse --abbrev-ref HEAD").readline().strip() if branch_name == 'HEAD': branch_name = '(no branch)' return branch_name + def export_git(source, dest): os.mkdir(dest) return os.system('git archive --format tar HEAD %s | tar x -C %s' % (source, dest)) + def get_build_dir(platformString, bitwidth): - build_dir = '%s%s_build' % (platformString[0:3],bitwidth) + build_dir = '%s%s_build' % (platformString[0:3], bitwidth) return build_dir + def get_mixxx_version(): """Get Mixxx version number from defs_version.h""" # have to handle out-of-tree building, that's why the '#' :( @@ -106,6 +121,7 @@ def get_mixxx_version(): version = version.split()[-1].replace('"', '') return version + def get_flags(env, argflag, default=0): """ * get value passed as an argument to scons as argflag=value @@ -115,13 +131,14 @@ def get_flags(env, argflag, default=0): """ flags = Script.ARGUMENTS.get(argflag, -1) if int(flags) < 0: - if env.has_key(argflag): + if argflag in env: flags = env[argflag] - else: #default value + else: # default value flags = default env[argflag] = flags return flags + def get_mssdk_path(): """Look for the Microsoft SDK path checking the various environment variables they set.""" @@ -134,23 +151,32 @@ def get_mssdk_path(): return "" # Checks for pkg-config on Linux -def CheckForPKGConfig( context, version='0.0.0' ): - context.Message( "Checking for pkg-config (at least version %s)... " % version ) - ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0] - context.Result( ret ) + + +def CheckForPKGConfig(context, version='0.0.0'): + context.Message( + "Checking for pkg-config (at least version %s)... " % version) + ret = context.TryAction( + "pkg-config --atleast-pkgconfig-version=%s" % version)[0] + context.Result(ret) return ret # Uses pkg-config to check for a minimum version -def CheckForPKG( context, name, version="" ): + + +def CheckForPKG(context, name, version=""): if version == "": - context.Message( "Checking for %s... \t" % name ) - ret = context.TryAction( "pkg-config --exists '%s'" % name )[0] + context.Message("Checking for %s... \t" % name) + ret = context.TryAction("pkg-config --exists '%s'" % name)[0] else: - context.Message( "Checking for %s (%s or higher)... \t" % (name,version) ) - ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0] - context.Result( ret ) + context.Message( + "Checking for %s (%s or higher)... \t" % (name, version)) + ret = context.TryAction( + "pkg-config --atleast-version=%s '%s'" % (version, name))[0] + context.Result(ret) return ret + def write_build_header(path): f = open(path, 'w') try: |