github.com/maruel/nin@v0.0.0-20220112143044-f35891e3ce7e/regen.sh (about) 1 #!/bin/bash 2 # Copyright 2021 Google LLC 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 #TODO(maruel): Figure out why go generate doesn't work well. 17 18 set -eu 19 20 #TODO(maruel): Measure impact and usefulness of -8. 21 22 if ! re2go -help &> /dev/null; then 23 if [ ! -f ../re2c/out/re2go ]; then 24 echo "re2go is needed to generate the high performance regexp." 25 echo "Installing" 26 echo "" 27 git clone -b 2.2 https://github.com/skvadrik/re2c ../re2c 28 mkdir ../re2c/out 29 cd ../re2c/out 30 cmake .. 31 cmake --build . -j 4 32 cd - 33 fi 34 export PATH=$PATH:$(pwd)/../re2c/out 35 elif [[ -f ../re2c/out/re2go ]]; then 36 export PATH=$PATH:$(pwd)/../re2c/out 37 fi 38 39 echo "Generating depfile_parser.go" 40 re2go depfile_parser.in.go -o depfile_parser.go -i --no-generation-date --no-version 41 sed -i -e "/build.\+neverbuild/d" depfile_parser.go 42 gofmt -s -w depfile_parser.go 43 44 echo "Generating lexer.go" 45 re2go lexer.in.go -o lexer.go -i --no-generation-date --no-version 46 sed -i -e "/build.\+neverbuild/d" lexer.go 47 gofmt -s -w lexer.go