Home | History | Annotate | Download | only in ndk
      1 #!/bin/bash -u
      2 #
      3 # Copyright 2016 Google Inc. All Rights Reserved.
      4 #
      5 # This script is intended to be used by binary_search_state.py, as
      6 # part of the binary search triage on Android NDK apps. This script simply
      7 # deletes all given objects, signaling gradle to execute a recompilation of said
      8 # object files.
      9 #
     10 
     11 # Input is a file, with newline seperated list of files we will be switching
     12 OBJ_LIST_FILE=$1
     13 
     14 # Check that number of arguments == 1
     15 if [ $# -ne 1 ] ; then
     16   echo "ERROR:"
     17   echo "Got multiple inputs to switch script!"
     18   echo "Run binary_search_state.py with --file_args"
     19   exit 1
     20 fi
     21 
     22 # Remove any file that's being switched. This is because Gradle only recompiles
     23 # if:
     24 #   1. The resultant object file doesn't exist
     25 #   2. The hash of the source file has changed
     26 #
     27 # Because we have no reliable way to edit the source file, we instead remove the
     28 # object file and have the compiler wrapper insert the file from the appropriate
     29 # cache (good or bad).
     30 #
     31 # Not entirely relevant to the Teapot example, but something to consider:
     32 # This removing strategy has the side effect that all switched items cause the
     33 # invocation of the compiler wrapper, which can add up and slow the build
     34 # process. With Android's source tree, Make checks the timestamp of the object
     35 # file. So we symlink in the appropriate file and touch it to tell Make it needs
     36 # to be relinked. This avoids having to call the compiler wrapper in the
     37 # majority of cases.
     38 #
     39 # However, a similar construct doesn't seem to exist in Gradle. It may be better
     40 # to add a build target to Gradle that will always relink all given object
     41 # files. This way we can avoid calling the compiler wrapper while Triaging and
     42 # save some time. Not really necessary
     43 
     44 cat $OBJ_LIST_FILE | xargs rm
     45 exit 0
     46 
     47