Commit Graph

5997 Commits

Author SHA1 Message Date
Ben Liblit 7cbccb33fb Simplify how we refer to the outputs of certain tasks 2018-04-18 11:29:29 -05:00
Ben Liblit 0e629f68e7 Exclude a test that has started failing due to running out of memory
I don't know what changes are triggering this.  Presumably it's
something to do with the temporary-file code, but I don't see why that
would happen.  For now, let's just skip this test.
2018-04-18 11:29:29 -05:00
Ben Liblit b14804bfdc Don't put fixed-name, writable files into "java.io.tmpdir"
If multiple tests both write to "/tmp/cg.txt" (for example), then
these tests cannot safely run concurrently.  That never used to be a
problem with Maven, since our Maven tests were all strictly sequential
anyway.  But parallelized testing using Gradle requires that we do
better.  Fortunately, Java has perfectly reasonable APIs for
generating uniquely-named temporary files and directories.
2018-04-18 11:29:29 -05:00
Ben Liblit ba01621de5 Don't use build cache (a.k.a. task output caching) under Travis CI
The performance improvement offered by the build cache is modest when
run by Travis CI.  This is probably because Travis CI does not keep
the cache on any local machine.  Instead, Travis CI uploads the build
cache across a network at the end of each run, then restores the cache
across the network at the start of the next run.  So in many cases
we're simply trading network access to original downloads for network
access to the cache image.

Furthermore, it's probably a better test to perform Travis CI testing
jobs from something closer to a clean slate.  We really want to know
whether everything builds and passes tests correctly starting from
nothing.  We don't want to risk accidentally thinking something would
work simply because we have a cached copy of what it did when it
worked previously.
2018-04-18 11:29:29 -05:00
Ben Liblit 47539da731 Unpack Android SDK and install extra components as a single task
Previously we unpacked in one task, then installed two extra
components in two dependent tasks.  However, installing extra
components modifies some files in place, effectively making those
files both inputs and outputs.  That creates race conditions, and
probably interferes with task output caching.  Better, then, to treat
the unpack and extra installations all as a single task whose output
is the complete Android SDK tree with all required components
installed.
2018-04-18 11:29:29 -05:00
Ben Liblit 01fc8fcae5 If tests fail, print full stack traces to aid debugging 2018-04-18 11:29:29 -05:00
Ben Liblit bd42510c6b Enable both parallel builds and build output caching by default
This should give us a nice build-performance boost, both locally and
in Travis CI.  I've used parallel builds routinely for months now, and
they're working fine.  Build output caching is newer, but it also
seems to be working well and saves us tremendous time on downloads.
2018-04-18 11:29:29 -05:00
Ben Liblit 3a1b1d1d1e Allow parallel testing within each subproject
Without this setting, Gradle would run multiple "test" tasks from
multiple subprojects concurrently, but each "test" task would only run
a single test at a time.  Some of our subprojects' test tasks take a
long time to complete, which could easily leave us sequentially
testing on just one or two CPU cores while other cores sit idle.

With this change, Gradle will use as many task slots as are
available (e.g., when run with "--parallel") to run multiple
simultaneous JUnit test classes within any given subproject.  This
seems to be fine for us:  I am unaware of any shared global state that
would cause conflicts between two test classes within any given
subproject.
2018-04-18 11:29:29 -05:00
Ben Liblit 4840966807 Don't try to exhaustively anticipate all generated header names
When JNI headers for a given class, each nested class will end up with
its own additional header.  But I don't want to try to parse nested
class details out of the Java source files just so we can determine
exactly which headers will be created.  Instead, simply treat the
entire header destination directory as the output of this task.
2018-04-18 11:29:29 -05:00
Ben Liblit 36fe02d71c Improve build caching by reducing path sensitivity where appropriate 2018-04-18 11:29:29 -05:00
Ben Liblit 74523f5058 Enable caching of task outputs for custom build tasks 2018-04-18 11:29:29 -05:00
Ben Liblit 000b21f36e Rename a build task to more clearly reflect what it builds
This task has an input named "hello_hash.ml", and an output named
"hello_hash.jar".  So calling this task "generateHelloHash" is too
vague.  Now we call it "generateHelloHashJar" instead.
2018-04-18 11:29:29 -05:00
Ben Liblit c0ec959e4a Extend Gradle's "clean" task to remove some additional build targets 2018-04-18 11:29:29 -05:00
Ben Liblit 328b1ec52b Merge info from existing, hand-authored manifests when building jars 2018-04-18 11:29:29 -05:00
Ben Liblit 4dc1e41529 Tell Eclipse to ignore some questionable manifest contents
These manifest files are here for use by the Maven build, but Eclipse
is now using Gradle (via Buildship).  So the manifests as seen by
Eclipse do not entirely make sense.  I'm hesitant to change the
manifests directly, since presumably they were correct for Maven and
still are.

Perhaps some day we'll be using Gradle to generate manifests.  Until
that day comes, we're better off leaving the manifests as they are and
just suppressing Eclipse's warnings instead.
2018-04-18 11:29:29 -05:00
Ben Liblit 7dcff25dcf After Builldship import, put "dx.jar" where the manifest expects it 2018-04-18 11:29:29 -05:00
Ben Liblit 72e5eb2b8d Restore old manifests in hope of fixing Maven regressions 2018-04-18 11:29:29 -05:00
Ben Liblit 7b96281e77 Bail out if any Travis CI testing commands fail
Previously we could fail some "mvn" stage but keep running anyway,
thereby fooling us into thinking that everything was OK.
2018-04-18 11:29:29 -05:00
Ben Liblit 3961b3a20e Incremental improvements to Windows JDK library configuration
This still doesn't actually work, but it's closer than it was before.
There's still some problem with improper mixing of 32-bit ("x86") and
64-bit ("x64") libraries.
2018-04-18 11:29:29 -05:00
Ben Liblit 298d6654d6 Clean up questionable memory management during string construction
Avoid allocating memory using strdup() and then releasing it using
operator delete.  strdup()-allocated memory should be released using
free(), not delete.  But in these specific cases, there really was
never any good reason to duplicate the C-style strings in the first
place.  Instead, we can safely pass those NUL-terminated char pointers
directly in calls to JNI's NewStringUTF().  NewStringUTF() does not
take ownership of its argument, but rather clones that string data
internally before returning.  So using strdup() and delete was just
unnecessary memory churn.

In cases where we need to format, concatenate, or construct new
strings, don't use sprintf() into variable-sized, stack-allocated
arrays.  Variable-sized arrays are not portable, and in particular are
rejected by Microsoft's Visual Studio 2017 C++ compiler.  Instead, do
our string formatting and manipulations using std::ostringstream
and/or std::string.  We just need to be a bit careful about the
lifetimes and ownership responsibilities of allocated data.  In
brief, (1) ostringstream::str() returns a temporary string instance
that expires at the end of the enclosing statement, independent of the
lifetime of the ostringstream instance; while (2) string::c_str()
returns an pointer to internal data that remains valid as long as the
string on which it was called is valid and unmodified.
2018-04-18 11:29:29 -05:00
Ben Liblit 216981f7e3 Somebody decided to use three-space indentation in this file only
OK, whatever makes you happy.
2018-04-18 11:29:29 -05:00
Ben Liblit 86fe6e9334 Fill in likely (but untested) JVM library path on Windows 2018-04-18 11:29:29 -05:00
Ben Liblit 5f2d64f85a Factor out common code for installing Android SDK components 2018-04-18 11:29:28 -05:00
Ben Liblit 587d0a95dc Skip DroidBench tests on Windows, for now
The default location of DroidBench in "/tmp/DroidBench" does not work
well on Windows. So let's disable these tests until someone has time to
make that path more portable.
2018-04-18 11:29:28 -05:00
Ben Liblit c642ec4039 Fix Android SDK installation under Windows 2018-04-18 11:29:28 -05:00
Ben Liblit 9295bcdd0d Switch to a different DroidBench download URL
This URL skips over a redirect that the previous URL went through.
This URL also avoids an annoying "Invalid cookie header" warning that
the previous URL produced.
2018-04-18 11:29:28 -05:00
Ben Liblit afd4bb49bb Use download task instead of "git clone" to get DroidBench
This gives us better progress reporting during the download, better
caching, better file-level dependency tracking, etc.
2018-04-18 11:29:28 -05:00
Ben Liblit 1d2a8a3e7e Factor out recurring pattern in download tasks 2018-04-18 11:29:28 -05:00
Ben Liblit 848530f39a Experimental combined task for download and checksum verification
Not working yet:
<https://github.com/michel-kraemer/gradle-download-task/issues/108>.
2018-04-18 11:29:28 -05:00
Ben Liblit 03e43d100b Update gradle-download-plugin and use some of its new features
We now download and verify checksums as a single task, rather than as
two separate tasks.  This simplifies other task dependencies, since we
no longer have a checksum-verified "stamp" file separate from the
download itself.  Unfortunately the combined task now has a
significant amount of repeated boilerplate.  I'm hoping to refactor
that all out into a custom task class, but haven't yet figured out the
details:
<https://github.com/michel-kraemer/gradle-download-task/issues/108>.

We now also use ETags to be smarter about when a fresh download is or
is not actually needed.  I think there are still opportunities for
improved caching here, but this is a step in the right direction.
2018-04-18 11:29:28 -05:00
Ben Liblit 9baf192416 If Travis CI gives us multiple CPUs, we may as well use them
I believe Travis CI jobs get two CPUs by default.

Doing parallel builds regularly is also a good way to help us discover
any build race conditions we may have.  There's no guarantee that any
such races will be revealed, but even exposing them
nondeterministically is better than having no possibility of exposing
them at all.
2018-04-18 11:29:28 -05:00
Ben Liblit 3cb91d1e67 Fix a shellcheck warning when setting a variable to the empty string 2018-04-18 11:29:28 -05:00
Ben Liblit 361b689966 Update to Gradle 4.6
No significant new features of interest for us in this release, but I
like to keep current.
2018-04-18 11:29:28 -05:00
Ben Liblit ea239ba484 Add a new README with Gradle-specific instructions and tips 2018-04-18 11:29:28 -05:00
Ben Liblit 49e5aa4f52 Remove two Maven repositories that we no longer use for anything
We used to use these to find various Eclipse packages, but that was
always a dodgy affair since we never quite knew whether we had
matching versions of everything.  Now that we are using the
"com.diffplug.gradle.p2.asmaven" plug-in, though, we have much better
control over getting exactly the Eclipse material we need.  These two
Maven repositories no longer provide anything we use, and therefore
can be removed.
2018-04-18 11:29:28 -05:00
Ben Liblit c0e6cd37b0 We only expect ".gradle" directories in two specific places 2018-04-18 11:29:28 -05:00
Ben Liblit 17fc048599 Generalize post-import Eclipse run configuration for more fixups
Previously this launcher's job was to run "processTestResources" and
any other Gradle tasks needed to create files that Eclipse was
expecting to be available.  But we also want to use it to revert the
bad changes that Buildship applies to ".launch" configuration files.

This is a temporary hack to work around
<https://github.com/eclipse/buildship/issues/653>.
2018-04-18 11:29:28 -05:00
Ben Liblit c6a6ef8b97 Minor indentation fix 2018-04-18 11:29:28 -05:00
Ben Liblit bcbd298808 Extra help for finding "cast" native library on macOS
Unlike Linux, macOS has no "RPATH" facility for embedding additional
search paths within shared libraries.  Instead, we need to set
"DYLD_LIBRARY_PATH" appropriately in the environment.  This
environment variable is the macOS analogue of "LD_LIBRARY_PATH" on
Linux.

Note that adding the required path to the "java.library.path" system
property will *not* work.  This property only affects where the JVM
looks for shared objects that it is loading directly.  This property
does not influence the search for other, transitively-required shared
objects.

Fixes #3.
2018-04-18 11:29:28 -05:00
Ben Liblit 48ffce525c Fix remaining Javadoc warnings
This fixes the last of our Javadoc warnings without creating a
circular dependency between ":com.ibm.wala.cast:javadoc" and
":com.ibm.wala.cast.js:javadoc".  Fixes #4, wherein more details about
this tricky dependency challenge can be found.
2018-04-18 11:29:28 -05:00
Ben Liblit 2a75244914 Use ".singleFile" instead of "[0]" when we expect just one file
This documents our intent more clearly, and actively checks for
mistakes rather than silently ignoring unexpected extra files.
2018-04-18 11:29:28 -05:00
Ben Liblit 1d8869bb0a Start exploring publication features by adding source jar archives 2018-04-18 11:29:28 -05:00
Ben Liblit 7fd8f02382 Replicate test include/exclude patterns already used in Maven builds 2018-04-18 11:29:28 -05:00
Ben Liblit 9a2af5bbb8 Add "com.ibm.wala.core.testdata" to classpath for testing
This lets the "DynamicCallGraphTest" tests pass.  The tests in that
class expect to find some element of the classpath that includes the
substring "com.ibm.wala.core.testdata".  They then treat that as a
collection of bytecode files to instrument.
2018-04-18 11:29:28 -05:00
Ben Liblit 4c179e51bc Skip a test intentionally; Maven already does the same
Big thanks to Julian for showing me where this exclusion logic lives
in the Maven configuration.  There's a "**/*AndroidLibs*.java"
exclusion pattern in the top-level "pom.xml".
2018-04-18 11:29:28 -05:00
Ben Liblit fca0f7c117 Fix jar exclusion patterns to match what Ant uses
One previously-failing test class now passes.  Progress!
2018-04-18 11:29:28 -05:00
Ben Liblit c2b1930248 Add some Eclipse dependencies needed only when running tests
This allows two test classes to pass that previously were failing.
Yay!
2018-04-18 11:29:28 -05:00
Ben Liblit bb98b2f84d Add a resource directory containing a zip archive used for testing
The excluded test in this subproject still does not pass, though now
it's failing for a different reason than before.  Progress, I suppose!
2018-04-18 11:29:28 -05:00
Ben Liblit 20be2b59c4 Disable Gradle linter check for unused dependencies in Travis CI
It's telling me to remove "eclipse-deps:org.eclipse.core.runtime:+"
and "org.osgi:org.osgi.core:4.2.0" as unused dependencies in the
"com.ibm.wala.cast.java.ecj" subproject.  However, these two
dependencies (jar files) are actually needed; compilation fails
without them.
2018-04-18 11:29:28 -05:00
Ben Liblit d0bf53474b Also get Eclipse JSDT from a P2 repository, but not the same one 2018-04-18 11:29:28 -05:00