Skip to content

Commit

Permalink
make sipdiff available on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 7, 2017
1 parent 07aa559 commit 0dc1257
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions scripts/sipdiff
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
#!/bin/bash
#!/usr/bin/env bash

# GNU prefix command for mac os support (gsed, gsplit)
GP=
if [[ "$OSTYPE" =~ darwin* ]]; then
GP=g
fi

for file in $*; do
d=${file#*/}
d=${d%/*}
f=${file##*/}
f=${f%.*}

tempfile=$(mktemp ${f}XXXX --suffix=.h)
tempfile=$(${GP}mktemp ${f}XXXX --suffix=.h)

# Remove comments
sed 's/a/aA/g;s/__/aB/g;s/#/aC/g' "src/$d/$f.h" | cpp -E $arg - | sed 's/aC/#/g;s/aB/__/g;s/aA/a/g' > $tempfile
${GP}sed 's/a/aA/g;s/__/aB/g;s/#/aC/g' "src/$d/$f.h" | cpp -E $arg - | ${GP}sed 's/aC/#/g;s/aB/__/g;s/aA/a/g' > $tempfile

# Remove override keyword
sed -i 's/ override;/;/g' $tempfile
${GP}sed -i 's/ override;/;/g' $tempfile

# Remove preprocessor directives
sed -i '/^#/d' $tempfile
${GP}sed -i '/^#/d' $tempfile

# Remove CORE_EXPORT etc
sed -i 's/ [A-Z]*_EXPORT//g' $tempfile
${GP}sed -i 's/ [A-Z]*_EXPORT//g' $tempfile

# Remove public keyword from inherited classes
sed -i 's/\(class.*:\) public\(.*\)/\1\2/g' $tempfile
${GP}sed -i 's/\(class.*:\) public\(.*\)/\1\2/g' $tempfile

vimdiff $tempfile python/$d/$f.sip

Expand Down

0 comments on commit 0dc1257

Please sign in to comment.