matrix-capnproto-fed

What if Matrix was written using Cap'n'proto and a RPC federation API?
git clone git://archive.git.mtrnord.blog/MTRNord/matrix-capnproto-fed.git
Log | Files | Refs | README | LICENSE

build.sh (948B)


      1 #!/usr/bin/env bash
      2 
      3 shopt -s globstar
      4 shopt -s extglob
      5 
      6 function getRealPath()
      7 {
      8     local -i traversals=0
      9     currentDir="$1"
     10     basename=''
     11     while :; do
     12         [[ "$currentDir" == '.' ]] && { echo "$1"; return 1; }
     13         [[ $traversals -eq 0 ]] && pwd=$(cd "$currentDir" 2>&1 && pwd) && { echo "$pwd/$basename"; return 0; }
     14         currentBasename="$(basename "$currentDir")"
     15         currentDir="$(dirname "$currentDir")"
     16         [[ "$currentBasename" == '..' ]] && (( ++traversals )) || { [[ traversals -gt 0 ]] && (( traversals-- )) || basename="$currentBasename/$basename"; }
     17     done
     18 }
     19 
     20 # Generate go code
     21 echo "Generate go code"
     22 path="./**/*.capnp"
     23 go_stdlib=$(getRealPath "../go-capnp/std")
     24 capnp compile -I $go_stdlib --verbose -ogo $path
     25 
     26 # Build go code
     27 echo "Build go code"
     28 rm -r bin
     29 mkdir -p bin
     30 go build -gcflags=all="-N -l" -o bin/server ./cmds/server/main.go
     31 go build -gcflags=all="-N -l" -o bin/client ./cmds/client/main.go