diff options
| -rw-r--r-- | bin/flycheck-android-java.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/flycheck-android-java.py b/bin/flycheck-android-java.py index 111ff3a..7e75068 100644 --- a/bin/flycheck-android-java.py +++ b/bin/flycheck-android-java.py @@ -53,6 +53,22 @@ def filter_source_files(files): """Remove any item not looking like a Java source file.""" return [f for f in files if f.endswith('.java')] +def cleanup_output(tmp, real): + """Remove any file in tmp that is older than the one in real""" + offset = len(tmp) + if tmp[-1] != '/': + offset = offset + 1 + for (dirpath, _, files) in os.walk(tmp): + realpath = os.path.join(real, dirpath[offset:]) + for filename in files: + try: + mtime = os.path.getmtime(os.path.join(realpath, filename)) + tmp = os.path.join(dirpath, filename) + if os.path.getmtime(tmp) <= mtime: + os.remove(tmp) + except OSError: + pass + def run_javac(encoding, source, target, bootcp, cp, files, output, args, sourcefile, outdir): """Execute javac with the given options.""" @@ -67,13 +83,17 @@ def run_javac(encoding, source, target, bootcp, cp, files, output, args, command.extend(['-bootclasspath', bootcp]) if outdir: command.extend(['-d', outdir]) - tmp = [] + tmp = [outdir] if output: tmp.append(output) if cp: tmp.extend(cp) if tmp: command.extend(['-cp', ':'.join(tmp)]) + + if os.fork() == 0: + cleanup_output(outdir, output) + sys.exit(0) else: if cp: command.extend(['-cp', ':'.join(cp)]) |
