build-all.sh 578 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/bin/bash

# 编译指定类型的所有项目 ./script/build-all.sh service

# 有命令错误直接退出脚本
set -e

# 项目类型
project_type=$1

if [[ -z $project_type ]]; then
  echo '项目类型不能为空'
  exit 1
fi

# 获取项目根目录
root=$(dirname $(cd $(dirname $0) && pwd))
cd $root

for sub in app/$project_type/*; do
  cd $sub
  echo "start build ${sub} ..."
  mkdir -p bin | true
  project=${sub##*/} # 根据路径截取项目名
  go build -o bin/hilo-$project_type-$project ./cmd/$project
  echo "finish build ${sub}"
  echo ''
  cd $root
done