akaros/scripts/PATCHPLAN9
<<
>>
Prefs
   1#!/bin/sh
   2set -e
   3#Plan 9 source can be converted for akaros via a set of scripts.
   4#This is a WIP. 
   5# At this point, we take it just so far and do the rest
   6# by hand. Cocci has its issues, and we're not here to debug
   7# and fix them all. Also, we may create some post-conversion
   8# scripts as well. We'll see.
   9#
  10#We preserve the waserror/poperror style, which adds complications
  11#but leaves the source relatively clean.
  12#
  13#To convert plan 9 source, we have to do several things.
  14#We use spatch, the semantic patch tool. BUT, that tool can be
  15#painful for some stuff, so we also use sed. And in some cases
  16#we clean up things that we do with spatch with a sed pass.
  17#Ugly but effective. Some scripts are idempotent, so we mark
  18#them as such. 
  19#
  20# waserror/poperror fixing, via script/spatch/waserror.cocci
  21# N.B. Need r18 or later.
  22spatch --sp-file scripts/spatch/waserror.cocci --in-place $1
  23# General Plan 9 fixing, via script/spatch/waserror.cocci
  24spatch --sp-file scripts/spatch/plan9.cocci --in-place $1
  25spatch --sp-file scripts/spatch/scalar.cocci --in-place $1
  26spatch --sp-file scripts/spatch/typedef.cocci --in-place $1
  27spatch --sp-file scripts/spatch/locks.cocci --in-place $1
  28spatch --sp-file scripts/spatch/rendez.cocci --in-place $1
  29spatch --sp-file scripts/spatch/kproc.cocci --in-place $1
  30# include fixing. Idempotent. 
  31sh scripts/fixincludes $1
  32# Scalars. Idempotent.
  33sh scripts/scalar $1
  34# remove pragmas. Idempotent.
  35sed -i '/^#pragma/d' $1
  36# Stuff we might want to think about later. Idempotent
  37sh scripts/temporary_hack $1
  38# malloc. Idempotent.
  39spatch --sp-file scripts/spatch/malloc.cocci --in-place $1
  40# type names, via scripts/plan9. NOT idempotent.
  41# in fact, we almost certainly don't want it.
  42sh scripts/plan9 $1
  43# kref. Idempotent.
  44spatch --sp-file scripts/spatch/kref.cocci --in-place $1
  45
  46