1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

Be more consistent when doing cleans

All update dirs, including ., will remove baddirs.
Right before build=, (ant|maven|gradle) clean will run
This commit is contained in:
Daniel Martí 2013-10-10 15:48:39 +02:00
parent 87fd0d69d1
commit 0bde32fd99
2 changed files with 59 additions and 13 deletions

View File

@ -349,6 +349,47 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
build_dir, srclib_dir, extlib_dir, sdk_path, ndk_path,
javacc_path, mvn3, verbose, onserver)
# We need to clean via the build tool in case the binary dirs are
# different from the default ones
p = None
if 'maven' in thisbuild:
print "Cleaning Maven project..."
cmd = [mvn3, 'clean', '-Dandroid.sdk.path=' + sdk_path]
p = subprocess.Popen(cmd, cwd=root_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
elif 'gradle' in thisbuild:
print "Cleaning Gradle project..."
cmd = [gradle, 'clean']
if '@' in thisbuild['gradle']:
gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@')[1])
else:
gradle_dir = root_dir
p = subprocess.Popen(cmd, cwd=gradle_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
print "Cleaning Ant project..."
cmd = ['ant', 'clean']
p = subprocess.Popen(cmd, cwd=root_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(p.stdout.readline, ''):
if verbose:
# Output directly to console
sys.stdout.write(line)
sys.stdout.flush()
else:
output += line
for line in iter(p.stderr.readline, ''):
if verbose:
# Output directly to console
sys.stdout.write(line)
sys.stdout.flush()
else:
error += line
# Scan before building...
print "Scanning source for common problems..."
buildprobs = common.scan_source(build_dir, root_dir, thisbuild)
@ -449,7 +490,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
# Build the release...
if 'maven' in thisbuild:
print "Building Maven project..."
mvncmd = [mvn3, 'clean', 'package', '-Dandroid.sdk.path=' + sdk_path]
mvncmd = [mvn3, 'package', '-Dandroid.sdk.path=' + sdk_path]
if install:
mvncmd += ['-Dandroid.sign.debug=true']
else:
@ -511,7 +552,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
if flavour in ['main', 'yes', '']:
flavour = ''
commands = [gradle, 'clean']
commands = [gradle]
if 'preassemble' in thisbuild:
for task in thisbuild['preassemble'].split():
commands.append(task)
@ -541,7 +582,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
else:
print "Building Ant project..."
antcommands = ['ant', 'clean']
antcommands = ['ant']
if install:
antcommands += ['debug','install']
elif 'antcommand' in thisbuild:

View File

@ -1229,14 +1229,27 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
if os.path.exists(buildxml):
print 'Force-removing old build.xml'
os.remove(buildxml)
for baddir in [
'gen', 'bin', 'obj', # ant
'libs/armeabi-v7a', 'libs/armeabi', # jni
'libs/mips', 'libs/x86', # jni
'build', # gradle
'target']: # maven
badpath = os.path.join(build_dir, baddir)
if os.path.exists(badpath):
print "Removing '%s'" % badpath
shutil.rmtree(badpath)
for d in update_dirs:
cwd = os.path.join(root_dir, d)
# Remove gen and bin dirs in libraries
# rid of them...
for baddir in ['gen', 'bin', 'obj', 'libs/armeabi-v7a', 'libs/armeabi', 'libs/mips', 'libs/x86']:
for baddir in [
'gen', 'bin', 'obj', # ant
'libs/armeabi-v7a', 'libs/armeabi', # jni
'libs/mips', 'libs/x86']:
badpath = os.path.join(cwd, baddir)
if os.path.exists(badpath):
print "Removing %s in update dir %s" % (badpath, d)
print "Removing '%s'" % badpath
shutil.rmtree(badpath)
if verbose:
print "Update of '%s': exec '%s' in '%s'"%\
@ -1372,14 +1385,6 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
if basesrclib:
srclibpaths.append(basesrclib)
# There should never be bin, gen or native libs directories in the source, so just get
# rid of them...
for baddir in ['gen', 'bin', 'obj', 'libs/armeabi-v7a', 'libs/armeabi', 'libs/mips', 'libs/x86']:
badpath = os.path.join(root_dir, baddir)
if os.path.exists(badpath):
print "Removing %s" % badpath
shutil.rmtree(badpath)
# Apply patches if any
if 'patch' in build:
for patch in build['patch'].split(';'):