github.com/m3db/m3@v1.5.1-0.20231129193456-75a402aa583b/scripts/auto-gen.sh (about)

     1  #!/bin/bash
     2  source "$(dirname $0)/auto-gen-helpers.sh"
     3  set -e
     4  
     5  if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then
     6      echo "usage: auto-gen.sh output_directory file_generation_rules_directory"
     7      exit 1
     8  fi
     9  
    10  if [[ "$2" = *"generated/mocks"* ]]; then
    11      remove_matching_files $1 "*_mock.go"
    12      remove_matching_files $1 "*_mock_test.go"
    13  elif [[ "$2" = *"generated/generics"* ]]; then
    14      remove_matching_files $1 "*_gen.go"
    15  elif [[ "$2" = *"generated/proto"* ]]; then
    16      remove_matching_files $1 "*.pb.go"
    17  else
    18      autogen_clear $1
    19  fi
    20  
    21  go generate $PACKAGE/$2
    22  
    23  if [[ "$2" = *"generated/mocks"* ]]; then
    24      gen_cleanup "*_mock.go"
    25      gen_cleanup "*_mock_test.go"
    26  elif [[ "$2" = *"generated/generics"* ]]; then
    27      gen_cleanup "*_gen.go"
    28  else
    29      autogen_cleanup $1
    30  fi