#!/bin/bash # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # USAGE # # 1. Follow instructions in https://source.android.com/setup/build/downloading to download # the AOSP source and in https://source.android.com/setup/build/building to get proprietary # binaries. You will need lots of space (at least 100Gb). Let be its root as # an *absolute path*. # # 2. Replace /prebuilts/jdk/jdk9//bin/javac with the following script. # # #!/bin/bash # infer -q --capture --continue --starvation-only --no-starvation \ # --project-root --results-dir /infer-out -- \ # /usr/local/bin/javac "$@" # # Here, my local installation of java is in /usr/local/, change accordingly. I used a # Java *8* installation without problems, YMMV. # # 3. From do # # $ . build/envsetup.sh # $ export TEMPORARY_DISABLE_PATH_RESTRICTIONS=true # $ cd libcore/ojluni # $ mm -j1 javac-check # # ... and wait. It took me ~22h. # # 4. From run # # $ infer analyze --starvation-only --dev-android-strict-mode # # 5. From run this script, capturing stdout. # # $ /scripts/make-strict-mode.sh > \ # /infer/src/concurrency/StrictModeModels.ml # # 6. You may need to adapt the optional ~actuals_pred argument for methods in the above ML file. # The aim is to avoid false positives when there is an overloaded method with different # signatures and it so happens that one of the versions makes a violation when another does not. # Recompile Infer. SOURCE_FILES=$(grep "error:" infer-out/report.txt | cut -f1 -d: | sort -u | grep -v test ) MATCHERS="" cat < Staged.unstage' echo MATCHERS="$MATCHERS $MATCHER" fi done echo echo "let is_strict_mode_violation =" echo " let matchers = [" for M in $MATCHERS ; do echo " $M ;" done echo " ]" echo " in" echo " fun tenv pn actuals -> List.exists matchers ~f:(fun m -> m tenv pn actuals)"