build_bcloud_lib.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
  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. import os
  15. import shutil
  16. import sys
  17. dirname = sys.argv[1]
  18. bc_dirname = sys.argv[2]
  19. if os.path.exists(bc_dirname):
  20. raise Exception("Path {} is already exists.".format(bc_dirname))
  21. os.makedirs(bc_dirname)
  22. # copy include files
  23. shutil.copytree(os.path.join(dirname, "include"), os.path.join(bc_dirname, "include"))
  24. # copy libraries
  25. shutil.copytree(os.path.join(dirname, "lib"), os.path.join(bc_dirname, "lib"))
  26. third_libs = os.path.join(dirname, "third_libs")
  27. for root, dirs, files in os.walk(third_libs):
  28. for f in files:
  29. if f.strip().count(".so") > 0 or f.strip() == "plugins.xml":
  30. full_path = os.path.join(root, f)
  31. shutil.copy(
  32. full_path, os.path.join(bc_dirname, "lib"), follow_symlinks=False
  33. )