From 6e0de04591eb5335dc304d2d724de0b2d4c9aa50 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 25 Aug 2023 00:13:32 -0500 Subject: [PATCH] [buildcore] Update buildcore --- deps/buildcore/scripts/util.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 deps/buildcore/scripts/util.py diff --git a/deps/buildcore/scripts/util.py b/deps/buildcore/scripts/util.py new file mode 100644 index 00000000..f87331bd --- /dev/null +++ b/deps/buildcore/scripts/util.py @@ -0,0 +1,38 @@ +# +# Copyright 2016 - 2021 gary@drinkingtea.net +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import os +import platform +import shutil + + +def mkdir_p(path: str): + if not os.path.exists(path): + os.mkdir(path) + + +# this exists because Windows is utterly incapable of providing a proper rm -rf +def rm(path: str): + file_exists = os.path.exists(path) + is_link = os.path.islink(path) + is_dir = os.path.isdir(path) + if (file_exists or is_link) and not is_dir: + os.remove(path) + elif os.path.isdir(path): + shutil.rmtree(path) + + +def get_os() -> str: + return os.uname().sysname.lower() + + +def get_arch() -> str: + arch = platform.machine() + if arch == 'amd64': + arch = 'x86_64' + return arch