1# Copyright 2020 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15.PHONY: help start 16 17SHELL := /bin/bash 18SRC_DIR := . 19DST_DIR := . 20PROTO_SRC_FILE := stress_test.proto 21PROTOC_DIR := ./env 22 23ifeq ($(OS),Windows_NT) 24 detected_OS := Windows 25 USER_NAME ?= 26else 27 detected_OS := $(shell uname) 28 USER_NAME ?= $(shell whoami) 29 ENV_PATH ?= $(shell pwd) 30endif 31 32ifeq ($(detected_OS),Darwin) 33 PROTOC_FILE := protoc-3.11.4-osx-x86_64.zip 34endif 35ifeq ($(detected_OS),Linux) 36 PROTOC_FILE := protoc-3.11.4-linux-x86_64.zip 37endif 38 39.DEFAULT: help 40help: 41 @echo "make start" 42 @echo " prepare development environment, use only once" 43 @echo "make proto-compile" 44 @echo " compile protubuf" 45 @echo "make clean" 46 @echo " delete test result and cache directories" 47 48start: 49ifeq ($(detected_OS),Windows) 50 @echo "please install python3.7.5 and pytyon3-pip manually" 51 py -m pip install --upgrade pip 52 python -m venv .\env 53endif 54ifeq ($(detected_OS),Darwin) 55 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 56 sudo chown -R $(USER_NAME) /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share 57 chmod u+w /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share 58 brew install sox 59 python -m venv env 60endif 61ifeq ($(detected_OS),Linux) 62 sudo apt-get install sox 63 python -m venv env 64endif 65 66proto-compile: ${PROTO_SRC_FILE} 67ifeq ($(detected_OS),Windows) 68 @echo "Download protoc-3.11.4-win64.zip from https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-win64.zip" 69 @echo "Decompress protoc-3.11.4-win64.zip and save proto.exe under env/bin folder" 70 @echo "Decompress protoc-3.11.4-win64.zip and copy include/* under env/include folder" 71 $(PROTOC_DIR)/protoc.exe -I=${SRC_DIR} --proto_path=$(PROTOC_DIR)/include --python_out=${DST_DIR} ${SRC_DIR}/${PROTO_SRC_FILE} 72else 73 curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/$(PROTOC_FILE) 74 sudo unzip -o $(PROTOC_FILE) -d $(PROTOC_DIR) bin/protoc 75 sudo unzip -o $(PROTOC_FILE) -d $(PROTOC_DIR) 'include/*' 76 rm -f $(PROTOC_FILE) 77 $(PROTOC_DIR)/bin/protoc -I=${SRC_DIR} --proto_path=$(PROTOC_DIR)/include --python_out=${DST_DIR} ${SRC_DIR}/${PROTO_SRC_FILE} 78endif 79 80clean: 81ifeq ($(detected_OS),Windows) 82 @for /d %%x in (dsp_*) do rd /s /q "%%x" 83 @for /d %%x in (enroll_*) do rd /s /q "%%x" 84 @for /d %%x in (__pycache*) do rd /s /q "%%x" 85else 86 @rm -rf __pycache__ 87 @rm -rf dsp_* 88 @rm -rf enroll* 89endif 90 @echo "cleanning completed" 91