Fix build caching (#242)

Summary:
See https://github.com/facebook/flipper/issues/230 for a longer
explanation.

It turns out that many of the tasks in `native.gradle` (at least
`prepareGlog` which modifies files inside the source directory, but also
others) cause the cmake cache to invalidate.

Because we run those tasks unconditionally, we need to recompile all our
C++ code even when unmodified.

I fix this by adding a manual cache key to this which simply skips all
the tasks unless an up-to-date `external_cache_revision.txt` is found.
This is a bit hacky, but the alternatives are a) convincing cmake that
these modifications are not recompile-worthy which I have no idea how to
do and which might be impossible to do `mtime` on the files touches, or
b) having fine-grained `onlyIf` rules for every task which can easily
break. This seems the most straight-forward option.

Fixes #230.
Pull Request resolved: https://github.com/facebook/flipper/pull/242

Reviewed By: jknoxville

Differential Revision: D9381340

Pulled By: passy

fbshipit-source-id: a7db55aacac4a29076c29298d6c5b97d8bc91f66
This commit is contained in:
Pascal Hartig
2018-08-20 07:32:57 -07:00
committed by Facebook Github Bot
parent d8e5e31c9a
commit 02cf3a90a2
3 changed files with 48 additions and 56 deletions

View File

@@ -1,37 +0,0 @@
cmake_minimum_required (VERSION 3.6.0)
PROJECT(libevent C)
enable_language(C)
set(PACKAGE_NAME libevent)
set(LIBEVENT_DIR libevent-release-2.1.8-stable)
list(APPEND DIR_LIST ${LIBEVENT_DIR}/)
list(APPEND DIR_LIST ${LIBEVENT_DIR}/include)
include_directories(${DIR_LIST})
list(APPEND SRCFILES ${LIBEVENT_DIR}/event.c
${LIBEVENT_DIR}/buffer.c
${LIBEVENT_DIR}/bufferevent.c
${LIBEVENT_DIR}/bufferevent_filter.c
${LIBEVENT_DIR}/bufferevent_ratelim.c
${LIBEVENT_DIR}/bufferevent_sock.c
${LIBEVENT_DIR}/epoll.c
${LIBEVENT_DIR}/epoll_sub.c
${LIBEVENT_DIR}/evdns.c
${LIBEVENT_DIR}/event_tagging.c
${LIBEVENT_DIR}/evmap.c
${LIBEVENT_DIR}/evrpc.c
${LIBEVENT_DIR}/evthread.c
${LIBEVENT_DIR}/evthread_pthread.c
${LIBEVENT_DIR}/evutil.c
${LIBEVENT_DIR}/evutil_rand.c
${LIBEVENT_DIR}/http.c
${LIBEVENT_DIR}/listener.c
${LIBEVENT_DIR}/log.c
${LIBEVENT_DIR}/poll.c
${LIBEVENT_DIR}/select.c
${LIBEVENT_DIR}/signal.c
${LIBEVENT_DIR}/strlcpy.c
)
add_library(${PACKAGE_NAME} SHARED ${SRCFILES})
install(TARGETS ${PACKAGE_NAME} DESTINATION ./build/)
target_link_libraries(${PACKAGE_NAME})