diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-01-12 00:14:04 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-01-12 00:14:04 +0100 |
| commit | 31238e1a0056984a3e40abe6668e60933cc29d6b (patch) | |
| tree | f57d36d6fa235a0652e7681466c02fad83fd0d34 /bin | |
| parent | 420f42cda4434bacf587b5082a25cce225502d26 (diff) | |
Add temporary output dir to classpath
This means you have to do real build less often as you change
the API of different classes. However, it instead means that we can
end up with outdated class files if you check out new code and
build without revisiting the buffer in Emacs. So, to work around
that, we check that no class file is older than the ones in
the real output dir. But to keep everything fast, this is launched
in a background process
Diffstat (limited to 'bin')
| -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)]) |
