From b3accaa61906d024cfd4b419f66e53d2b2a8fe41 Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Mon, 8 Jul 2019 18:52:04 +0800 Subject: [PATCH] 1. add include auto generation script. 2. add private repo script. (#1735) --- tools/shell/generate-include/.gitignore | 2 ++ .../generate-include/check_include_diff.sh | 30 +++++++++++++++++++ tools/shell/generate-include/main.cpp | 6 ++++ tools/shell/generate-include/parse.py | 21 +++++++++++++ tools/shell/generate-include/run.sh | 9 ++++++ tools/shell/restore-private-repo.sh | 5 ++++ 6 files changed, 73 insertions(+) create mode 100644 tools/shell/generate-include/.gitignore create mode 100644 tools/shell/generate-include/check_include_diff.sh create mode 100644 tools/shell/generate-include/main.cpp create mode 100644 tools/shell/generate-include/parse.py create mode 100755 tools/shell/generate-include/run.sh create mode 100644 tools/shell/restore-private-repo.sh diff --git a/tools/shell/generate-include/.gitignore b/tools/shell/generate-include/.gitignore new file mode 100644 index 0000000000..af9eaaeff8 --- /dev/null +++ b/tools/shell/generate-include/.gitignore @@ -0,0 +1,2 @@ +include +include.zip diff --git a/tools/shell/generate-include/check_include_diff.sh b/tools/shell/generate-include/check_include_diff.sh new file mode 100644 index 0000000000..eb3dd9d1dc --- /dev/null +++ b/tools/shell/generate-include/check_include_diff.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env + +include1=$1 +include2=$2 + +root=$(pwd) + +cd $include1 +list1=$(find . -name "*" | sort -n | uniq) +cd $root +echo "$list1" > include1.list + +cd $include2 +list2=$(find . -name "*" | sort -n | uniq) +cd $root +echo "$list2" > include2.list + +diff include1.list include2.list + +if [ "$?" = "0" ] +then + echo "no diff" +else + echo "has diff" +fi + +rm include1.list +rm include2.list + +echo "done" diff --git a/tools/shell/generate-include/main.cpp b/tools/shell/generate-include/main.cpp new file mode 100644 index 0000000000..720f09f11a --- /dev/null +++ b/tools/shell/generate-include/main.cpp @@ -0,0 +1,6 @@ +#include "io/paddle_mobile.h" +#include "io/paddle_inference_api.h" + +int main() { + return 0; +} diff --git a/tools/shell/generate-include/parse.py b/tools/shell/generate-include/parse.py new file mode 100644 index 0000000000..ba5445c68b --- /dev/null +++ b/tools/shell/generate-include/parse.py @@ -0,0 +1,21 @@ +import sys + +output = "" +for line in sys.stdin: + line.strip() + tag = "\\" + if tag in line: + index = line.index("\\") + line = line[:index] + output += line +for line in output.split(" "): + line = line.strip() + if "/Applications" in line: + continue + if len(line) <= 0: + continue + if not line.endswith(".h"): + continue + if not line.startswith("../../../src/"): + continue + print(line[len("../../../src/"):]) diff --git a/tools/shell/generate-include/run.sh b/tools/shell/generate-include/run.sh new file mode 100755 index 0000000000..1af1bce416 --- /dev/null +++ b/tools/shell/generate-include/run.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +rm -rf include + +mkdir include + +g++ -I../../../src/ -M main.cpp | python parse.py | xargs -I % sh -c "dirname %" | sort | uniq | xargs -I % sh -c "mkdir -p include/%" + +g++ -I../../../src/ -M main.cpp | python parse.py | xargs -I % sh -c "cp ../../../src/% include/%" diff --git a/tools/shell/restore-private-repo.sh b/tools/shell/restore-private-repo.sh new file mode 100644 index 0000000000..d9d29ed3e5 --- /dev/null +++ b/tools/shell/restore-private-repo.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +git clone https://icode.baidu.com/baidu/bdbox/paddle-mobile-private-repo/ + +cp -R paddle-mobile-private-repo/paddle-mobile-metallib ../../metal/ -- GitLab