chiark / gitweb /
Be more consistent when doing cleans
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 10 Oct 2013 13:48:39 +0000 (15:48 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 10 Oct 2013 13:48:39 +0000 (15:48 +0200)
All update dirs, including ., will remove baddirs.
Right before build=, (ant|maven|gradle) clean will run

fdroidserver/build.py
fdroidserver/common.py

index 2341ea99363fe3999579794657b57aced9cae136..d9cb830923b129da23726119e9f75ac4dbce1994 100644 (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:
index 2831bfe0652c47e5e951daf84d2f41a543c96739..3bb6c491be2bd92a24073dce9fd600ff62ded569 100644 (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(';'):