Explorar o código

Update scripts

Lutz Roeder hai 4 meses
pai
achega
3203e0292b
Modificáronse 2 ficheiros con 21 adicións e 19 borrados
  1. 10 14
      tools/coreml
  2. 11 5
      tools/onnx

+ 10 - 14
tools/coreml

@@ -3,31 +3,27 @@
 set -e
 pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
 
+src_dir=./third_party/source/coremltools
+
 case "${OSTYPE}" in
     msys*) python="winpty python";;
     *) python="python";;
 esac
 
-venv() {
-    env_dir=./third_party/env/coremltools
-    [ -d "${env_dir}" ] || ${python} -m venv ${env_dir}
-    case "${env_dir}" in
-        msys*) source ${env_dir}/Scripts/activate;;
-        *) source ${env_dir}/bin/activate;;
-    esac
-    ${python} -m pip install --quiet --upgrade pip
-}
-
 clean() {
     echo "coreml clean"
-    rm -rf "./third_party/source/env/coremltools"
-    rm -rf "./third_party/source/coremltools"
+    rm -rf "${src_dir}"
 }
 
 sync() {
     echo "coreml sync"
-    [ -d "./third_party/source/coremltools" ] || git clone --quiet https://github.com/apple/coremltools.git "./third_party/source/coremltools"
-    git -C "./third_party/source/coremltools" pull --quiet --prune
+    if [ ! -d "${src_dir}" ]; then
+        git clone --quiet --depth=1 --branch main --single-branch https://github.com/apple/coremltools.git "${src_dir}"
+    else
+        git -C "${src_dir}" fetch --quiet --depth=1 origin main
+        git -C "${src_dir}" reset --quiet --hard FETCH_HEAD
+        git -C "${src_dir}" gc --quiet --prune=all
+    fi
 }
 
 schema() {

+ 11 - 5
tools/onnx

@@ -3,6 +3,9 @@
 set -e
 pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
 
+env_dir=./third_party/env/onnx
+src_dir=./third_party/source/onnx
+
 case "${OSTYPE}" in
     msys*) python="winpty python";;
     *) python="python";;
@@ -20,17 +23,20 @@ venv() {
 
 clean() {
     echo "onnx clean"
-    rm -rf "./third_party/env/onnx"
-    rm -rf "./third_party/source/onnx"
+    rm -rf "${env_dir}"
+    rm -rf "${src_dir}"
     rm -rf "./third_party/source/onnxruntime"
 }
 
 sync() {
     echo "onnx sync"
-    if [ ! -d "./third_party/source/onnx" ]; then
-        git clone --quiet --recursive https://github.com/onnx/onnx.git "./third_party/source/onnx"
+    if [ ! -d "${src_dir}" ]; then
+        git clone --quiet --depth=1 --branch main --single-branch https://github.com/onnx/onnx.git "${src_dir}"
+    else
+        git -C "${src_dir}" fetch --quiet --depth=1 origin main
+        git -C "${src_dir}" reset --quiet --hard FETCH_HEAD
+        git -C "${src_dir}" gc --quiet --prune=all
     fi
-    pushd "./third_party/source/onnx" > /dev/null
     git pull --quiet --prune
     git submodule sync --quiet
     git submodule update --quiet --init --recursive