blob: 7736e167de1d136ce2b08d391dffd0f341370bdf [file] [log] [blame]
#!/bin/bash
# Copyright (c) 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Usage: ./feature-extractor.sh /path/to/build-mapper/output-directory
# Provided that the directory given has a number of folders called "x.build",
# in chronological order, this script will work.
export FEATURE_DIR="$(realpath $(dirname $0))/features"
export OUTPUT_DIR="$(realpath $1)"
cd $OUTPUT_DIR
features=""
for feature in $FEATURE_DIR/binary/*; do
[ -x $feature ] && (
features="$features $feature"
ls -tr | grep '\.build' | (
read prev
while read next; do
$feature $prev $next
prev=$next
done
) > "$(basename $feature).feature"
) &
done
for feature in $FEATURE_DIR/unary/*; do
[ -x $feature ] && (
features="$features $feature"
ls -tr | grep '\.build' | (
read prev
while read next; do
$feature $next
done
) > "$(basename $feature).feature"
) &
done
for feature in $FEATURE_DIR/unary/*; do
[ -x $feature ] && (
features="$features $feature-change"
ls -tr | grep '\.build' | (
read prev
while read next; do
u=$($feature $prev)
v=$($feature $next)
echo $((v-u))
prev=$next
done
) > "$(basename $feature)-change.feature"
) &
done
wait
# Order the commits in time order.
for file in $features; do
echo "Reversing $file"
tac $file > .tmp
echo "Moving $file"
mv .tmp $file
done