From ea1762418b6116e62d622fa9503f20a6a991d00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 4 Jul 2013 23:54:34 +0200 Subject: [PATCH 1/5] Use old *_build folder in case of a new branch --- build/mixxx.py | 77 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/build/mixxx.py b/build/mixxx.py index 56d71dcad55..f847f2ce1ad 100644 --- a/build/mixxx.py +++ b/build/mixxx.py @@ -303,13 +303,6 @@ def virtualize_build_dir(self): branch_build_dir = os.path.join(cache_dir, branch_name) virtual_build_dir = os.path.join(branch_build_dir, self.build_dir) virtual_sconsign_file = os.path.join(branch_build_dir, 'sconsign.dblite') - try: - print "os.makedirs", virtual_build_dir - os.makedirs(virtual_build_dir) - except: - # os.makedirs throws an exception if virtual_build_dir already - # exists. - pass # Clean up symlinks from our original method of virtualizing. if os.path.islink(self.build_dir): @@ -317,44 +310,78 @@ def virtualize_build_dir(self): os.unlink(self.build_dir) sconsign_file = '.sconsign.dblite' - sconsign_branch_file = '.sconsign.branch' + sconsign_branch_file = '.sconsign.branch' #contains the branch name of last build sconsign_branch = '' is_branch_different = True if os.path.isfile(sconsign_branch_file): with open(sconsign_branch_file, 'r') as f: - sconsign_branch = f.read() + sconsign_branch = f.readline() + sconsign_branch = sconsign_branch.strip() + # check if there was a checkout of a different branch sine the last build is_branch_different = sconsign_branch != branch_name if not is_branch_different: + # nothing to do return if sconsign_branch: old_branch_build_dir = os.path.join(cache_dir, sconsign_branch) + old_virtual_build_dir = os.path.join(old_branch_build_dir, self.build_dir) + old_virtual_sconsign_file = os.path.join(old_branch_build_dir, 'sconsign.dblite') if os.path.isdir(self.build_dir): - old_virtual_build_dir = os.path.join(old_branch_build_dir, self.build_dir) + if os.path.isdir(old_virtual_build_dir): + raise Exception('%s already exists. ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % old_virtual_build_dir) print "shutil.move", self.build_dir, old_virtual_build_dir + #move build dir from last build to chach, named with the old branch name shutil.move(self.build_dir, old_virtual_build_dir) if os.path.isfile(sconsign_file): - old_virtual_sconsign_file = os.path.join(old_branch_build_dir, 'sconsign.dblite') print "shutil.move", sconsign_file, old_virtual_sconsign_file + #move sconsdign-dblite as well shutil.move(sconsign_file, old_virtual_sconsign_file) # Now there should be no folder self.build_dir or file sconsign_file. - if os.path.isdir(virtual_build_dir): - if os.path.isdir(self.build_dir): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % self.build_dir) - print "shutil.move", virtual_build_dir, self.build_dir - shutil.move(virtual_build_dir, self.build_dir) - if os.path.isfile(virtual_sconsign_file): - if os.path.isfile(sconsign_file): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % sconsign_file) - print "shutil.move", virtual_sconsign_file, sconsign_file - shutil.move(virtual_sconsign_file, sconsign_file) + if os.path.isdir(branch_build_dir): + if os.path.isdir(virtual_build_dir): + # found a build_dir in cache from a previous build + if os.path.isdir(self.build_dir): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % self.build_dir) + print "shutil.move", virtual_build_dir, self.build_dir + shutil.move(virtual_build_dir, self.build_dir) + if os.path.isfile(virtual_sconsign_file): + if os.path.isfile(sconsign_file): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % sconsign_file) + print "shutil.move", virtual_sconsign_file, sconsign_file + shutil.move(virtual_sconsign_file, sconsign_file) + else: + # no chached build dir found, assume this is a branch from the old branch + # if not, no problem because scons will rebuild all chaned files in any case + # copy the old_virtual_dir back + if old_virtual_build_dir: + if os.path.isdir(old_virtual_build_dir): + if os.path.isdir(self.build_dir): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % self.build_dir) + print "shutil.copytree", old_virtual_build_dir, self.build_dir + shutil.copytree(old_virtual_build_dir, self.build_dir) + if old_virtual_sconsign_file: + if os.path.isfile(old_virtual_sconsign_file): + if os.path.isfile(sconsign_file): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % sconsign_file) + print "shutil.copy", virtual_sconsign_file, sconsign_file + shutil.copy(old_virtual_sconsign_file, sconsign_file) + # create build dir in cache folder for later move + print "os.makedirs", branch_build_dir + os.makedirs(branch_build_dir) with open(sconsign_branch_file, 'w+') as f: print 'touch', sconsign_branch_file From fc8b872737cfde8870e6465aefdb6adde0a62b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 10 Jul 2013 00:20:03 +0200 Subject: [PATCH 2/5] Fix error if .sconsign.branch is missing. In this case, the current *_build folder is re-used. --- build/mixxx.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build/mixxx.py b/build/mixxx.py index f847f2ce1ad..7bfb02b74c0 100644 --- a/build/mixxx.py +++ b/build/mixxx.py @@ -362,26 +362,27 @@ def virtualize_build_dir(self): else: # no chached build dir found, assume this is a branch from the old branch # if not, no problem because scons will rebuild all chaned files in any case - # copy the old_virtual_dir back - if old_virtual_build_dir: - if os.path.isdir(old_virtual_build_dir): - if os.path.isdir(self.build_dir): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % self.build_dir) - print "shutil.copytree", old_virtual_build_dir, self.build_dir - shutil.copytree(old_virtual_build_dir, self.build_dir) - if old_virtual_sconsign_file: - if os.path.isfile(old_virtual_sconsign_file): - if os.path.isfile(sconsign_file): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % sconsign_file) - print "shutil.copy", virtual_sconsign_file, sconsign_file - shutil.copy(old_virtual_sconsign_file, sconsign_file) - # create build dir in cache folder for later move - print "os.makedirs", branch_build_dir - os.makedirs(branch_build_dir) + # copy the old_virtual_dir back + if sconsign_branch: + if old_virtual_build_dir: + if os.path.isdir(old_virtual_build_dir): + if os.path.isdir(self.build_dir): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % self.build_dir) + print "shutil.copytree", old_virtual_build_dir, self.build_dir + shutil.copytree(old_virtual_build_dir, self.build_dir) + if old_virtual_sconsign_file: + if os.path.isfile(old_virtual_sconsign_file): + if os.path.isfile(sconsign_file): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % sconsign_file) + print "shutil.copy", virtual_sconsign_file, sconsign_file + shutil.copy(old_virtual_sconsign_file, sconsign_file) + # create build dir in cache folder for later move + print "os.makedirs", branch_build_dir + os.makedirs(branch_build_dir) with open(sconsign_branch_file, 'w+') as f: print 'touch', sconsign_branch_file From 73180838c16d14b56a7acc03c23cb34446a8732e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 10 Jul 2013 00:28:02 +0200 Subject: [PATCH 3/5] fixed scoping of some re-used variables --- build/mixxx.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/mixxx.py b/build/mixxx.py index 7bfb02b74c0..fbeeb005b83 100644 --- a/build/mixxx.py +++ b/build/mixxx.py @@ -303,6 +303,9 @@ def virtualize_build_dir(self): branch_build_dir = os.path.join(cache_dir, branch_name) virtual_build_dir = os.path.join(branch_build_dir, self.build_dir) virtual_sconsign_file = os.path.join(branch_build_dir, 'sconsign.dblite') + old_branch_build_dir = '' + old_virtual_build_dir = '' + old_virtual_sconsign_file = '' # Clean up symlinks from our original method of virtualizing. if os.path.islink(self.build_dir): From 7dfd78037c77acd44f8410d602caa43a0c7751ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 10 Jul 2013 00:36:31 +0200 Subject: [PATCH 4/5] create branch folder in cache even when .sconsign.brach does not exists --- build/mixxx.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/mixxx.py b/build/mixxx.py index fbeeb005b83..0710c18aada 100644 --- a/build/mixxx.py +++ b/build/mixxx.py @@ -383,9 +383,10 @@ def virtualize_build_dir(self): 'move or delete it.' % sconsign_file) print "shutil.copy", virtual_sconsign_file, sconsign_file shutil.copy(old_virtual_sconsign_file, sconsign_file) - # create build dir in cache folder for later move - print "os.makedirs", branch_build_dir - os.makedirs(branch_build_dir) + + # create build dir in cache folder for later move + print "os.makedirs", branch_build_dir + os.makedirs(branch_build_dir) with open(sconsign_branch_file, 'w+') as f: print 'touch', sconsign_branch_file From 94155764ad726cf592c2ffc88ae8d89311b29f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 10 Jul 2013 09:28:44 +0200 Subject: [PATCH 5/5] removed if that always evaluates to true --- build/mixxx.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/build/mixxx.py b/build/mixxx.py index 0710c18aada..72fed2ce409 100644 --- a/build/mixxx.py +++ b/build/mixxx.py @@ -367,22 +367,20 @@ def virtualize_build_dir(self): # if not, no problem because scons will rebuild all chaned files in any case # copy the old_virtual_dir back if sconsign_branch: - if old_virtual_build_dir: - if os.path.isdir(old_virtual_build_dir): - if os.path.isdir(self.build_dir): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % self.build_dir) - print "shutil.copytree", old_virtual_build_dir, self.build_dir - shutil.copytree(old_virtual_build_dir, self.build_dir) - if old_virtual_sconsign_file: - if os.path.isfile(old_virtual_sconsign_file): - if os.path.isfile(sconsign_file): - raise Exception('%s exists without a .sconsign.branch file so ' - 'build virtualization cannot continue. Please ' - 'move or delete it.' % sconsign_file) - print "shutil.copy", virtual_sconsign_file, sconsign_file - shutil.copy(old_virtual_sconsign_file, sconsign_file) + if os.path.isdir(old_virtual_build_dir): + if os.path.isdir(self.build_dir): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % self.build_dir) + print "shutil.copytree", old_virtual_build_dir, self.build_dir + shutil.copytree(old_virtual_build_dir, self.build_dir) + if os.path.isfile(old_virtual_sconsign_file): + if os.path.isfile(sconsign_file): + raise Exception('%s exists without a .sconsign.branch file so ' + 'build virtualization cannot continue. Please ' + 'move or delete it.' % sconsign_file) + print "shutil.copy", virtual_sconsign_file, sconsign_file + shutil.copy(old_virtual_sconsign_file, sconsign_file) # create build dir in cache folder for later move print "os.makedirs", branch_build_dir