Browse Source

Git Bash choco flatc support

Lutz Roeder 6 years ago
parent
commit
f820034869
5 changed files with 25 additions and 44 deletions
  1. 3 13
      tools/armnn
  2. 3 13
      tools/mnn
  3. 15 4
      tools/onnx
  4. 1 1
      tools/tf
  5. 3 13
      tools/tflite

+ 3 - 13
tools/armnn

@@ -34,27 +34,17 @@ schema() {
                 make > /dev/null
                 popd > /dev/null
             fi
-            flatc=${flatc_dir}/flatc
+            export PATH=${flatc_dir}/flatc:${PATH}
             ;;
         darwin*)
             brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
-            flatc=flatc
             ;;
         msys*)
-            flatc_version=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
-            flatc_dir=./third_party/bin/flatbuffers/${flatc_version}
-            if [ ! -f "${flatc_dir}/flatc.exe" ]; then
-                mkdir -p "${flatc_dir}"
-                pushd "${flatc_dir}" > /dev/null
-                curl -sL -O https://github.com/google/flatbuffers/releases/download/${flatc_version}/flatc_windows_exe.zip
-                unzip flatc_windows_exe.zip > /dev/null
-                popd > /dev/null
-            fi
-            flatc=${flatc_dir}/flatc.exe
+            [ -x "$(command -v flatc)" ] || $(choco install flatc) > /dev/null
             ;;
     esac
     [[ $(grep -U $'\x0D' ./src/armnn-schema.js) ]] && crlf=1
-    ${flatc} --no-js-exports -o ./tools/. --js ./third_party/src/armnn/src/armnnSerializer/ArmnnSchema.fbs
+    flatc --no-js-exports -o ./tools/. --js ./third_party/src/armnn/src/armnnSerializer/ArmnnSchema.fbs
     mv ./tools/ArmnnSchema_generated.js ./src/armnn-schema.js
     cat <<EOT >> ./src/armnn-schema.js
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {

+ 3 - 13
tools/mnn

@@ -34,27 +34,17 @@ schema() {
                 make > /dev/null
                 popd > /dev/null
             fi
-            flatc=${flatc_dir}/flatc
+            export PATH=${flatc_dir}/flatc:${PATH}
             ;;
         darwin*)
             brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
-            flatc=flatc
             ;;
         msys*)
-            flatc_version=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
-            flatc_dir=./third_party/bin/flatbuffers/${flatc_version}
-            if [ ! -f "${flatc_dir}/flatc.exe" ]; then
-                mkdir -p "${flatc_dir}"
-                pushd "${flatc_dir}" > /dev/null
-                curl -sL -O https://github.com/google/flatbuffers/releases/download/${flatc_version}/flatc_windows_exe.zip
-                unzip flatc_windows_exe.zip > /dev/null
-                popd > /dev/null
-            fi
-            flatc=${flatc_dir}/flatc.exe
+            [ -x "$(command -v flatc)" ] || $(choco install flatc) > /dev/null
             ;;
     esac
     [[ $(grep -U $'\x0D' ./src/mnn-schema.js) ]] && crlf=1
-    ${flatc} --no-js-exports --gen-all -o ./tools/. --js ./third_party/src/mnn/schema/default/MNN.fbs
+    flatc --no-js-exports --gen-all -o ./tools/. --js ./third_party/src/mnn/schema/default/MNN.fbs
     mv ./tools/MNN_generated.js ./src/mnn-schema.js
     cat <<EOT >> ./src/mnn-schema.js
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {

+ 15 - 4
tools/onnx

@@ -50,8 +50,8 @@ install() {
     bold "onnx install"
     case "${OSTYPE}" in
         linux*)
-            [ -n "$(which cmake)" ] || sudo apt install -y cmake
-            [ -n "$(which protoc)" ] || sudo apt install -y protobuf-compiler libprotoc-dev
+            [ -x "$(command -v cmake)" ] || sudo apt install -y cmake
+            [ -x "$(command -v protoc)" ] || sudo apt install -y protobuf-compiler libprotoc-dev
             protobuf=protobuf
             ;;
         darwin*)
@@ -61,8 +61,19 @@ install() {
             protobuf="protobuf==3.7.1"
             ;;
         msys*)
-            [ -n "$(which protoc)" ] || choco install --yes protoc --version=3.8.0
-            protobuf="protobuf==3.8.0"
+            # [ -x "$(command -v protoc)" ] || $(choco install --yes protoc --version=3.8.0) > /dev/null
+            protoc_version=3.8.0
+            protoc_dir=./third_party/bin/protobuf/v${protoc_version}
+            if [ ! -f "${protoc_dir}/bin/protoc.exe" ]; then
+                mkdir -p "${protoc_dir}"
+                pushd "${protoc_dir}" > /dev/null
+                curl -sL -O https://github.com/protocolbuffers/protobuf/releases/download/v${protoc_version}/protoc-${protoc_version}-win32.zip
+                unzip protoc-${protoc_version}-win32.zip > /dev/null
+                rm protoc-${protoc_version}-win32.zip
+                popd > /dev/null
+            fi
+            export PATH=${protoc_dir}/bin:${PATH}
+            protobuf="protobuf==${protoc_version}"
             ;;
     esac
     venv

+ 1 - 1
tools/tf

@@ -79,7 +79,7 @@ metadata() {
     venv
     case "${OSTYPE}" in
         linux*)
-            [ -n "$(which protoc)" ] || sudo apt install -y protobuf-compiler libprotoc-dev
+            [ -x "$(command -v protoc)" ] || sudo apt install -y protobuf-compiler libprotoc-dev
             protoc=protoc
             ;;
         darwin*)

+ 3 - 13
tools/tflite

@@ -52,28 +52,18 @@ schema() {
                 make > /dev/null
                 popd > /dev/null
             fi
-            flatc=${flatc_dir}/flatc
+            export PATH=${flatc_dir}/flatc:${PATH}
             ;;
         darwin*)
             brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
-            flatc=flatc
             ;;
         msys*)
-            flatc_version=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
-            flatc_dir=./third_party/bin/flatbuffers/${flatc_version}
-            if [ ! -f "${flatc_dir}/flatc.exe" ]; then
-                mkdir -p "${flatc_dir}"
-                pushd "${flatc_dir}" > /dev/null
-                curl -sL -O https://github.com/google/flatbuffers/releases/download/${flatc_version}/flatc_windows_exe.zip
-                unzip flatc_windows_exe.zip > /dev/null
-                popd > /dev/null
-            fi
-            flatc=${flatc_dir}/flatc.exe
+            [ -x "$(command -v flatc)" ] || $(choco install flatc) > /dev/null
             ;;
     esac
     [[ $(grep -U $'\x0D' ./src/tflite-schema.js) ]] && crlf=1
     sed 's/namespace tflite;/namespace TFLITE;/g' < ./third_party/src/tensorflow/tensorflow/lite/schema/schema.fbs > ./tools/tflite.schema.fbs
-    ${flatc} --no-js-exports --js ./tools/tflite.schema.fbs
+    flatc --no-js-exports --js ./tools/tflite.schema.fbs
     rm ./tools/tflite.schema.fbs
     mv ./tflite.schema_generated.js ./src/tflite-schema.js
     cat <<EOT >> ./src/tflite-schema.js