From 4bdc0f80c5fb49f3833811a920cd50072698fb04 Mon Sep 17 00:00:00 2001 From: GuilhermeWerner <26710260+GuilhermeWerner@users.noreply.github.com> Date: Wed, 24 Feb 2021 09:13:38 -0300 Subject: [PATCH] Create VSCode Tasks --- .vscode/tasks.json | 37 ++++++++++++++++++++++++ Scripts/Copyright.py | 34 ++++++++++++++++++++++ Scripts/Package.py | 67 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 .vscode/tasks.json create mode 100644 Scripts/Copyright.py create mode 100644 Scripts/Package.py diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..86a8e94 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,37 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Package (Windows)", + "type": "shell", + "command": "python", + "args": [ + "./Scripts/Package.py" + ], + }, + { + "label": "Package (Linux)", + "type": "shell", + "command": "python3", + "args": [ + "./Scripts/Package.py" + ], + }, + { + "label": "Copyright (Windows)", + "type": "shell", + "command": "python", + "args": [ + "./Scripts/Copyright.py" + ], + }, + { + "label": "Copyright (Linux)", + "type": "shell", + "command": "python3", + "args": [ + "./Scripts/Copyright.py" + ], + } + ] +} diff --git a/Scripts/Copyright.py b/Scripts/Copyright.py new file mode 100644 index 0000000..c81483f --- /dev/null +++ b/Scripts/Copyright.py @@ -0,0 +1,34 @@ +# Copyright (c) TribuFu. All Rights Reserved + +import os + +old_copyright_notice = "// Copyright (c) TribuFu. All Rights Reserved\n\n" +new_copyright_notice = "// Copyright (c) TribuFu. All Rights Reserved\n\n" + +def GetFiles(root): + source_files = [] + + for path, dirs, files in os.walk(os.path.normpath(root)): + for name in files: + if name.endswith(".rs"): + source_files.append(os.path.join(path, name)) + + return source_files + +for file in GetFiles("Source"): + reader = open(file, "r") + + file_content = reader.read() + + reader.close() + + new_content = file_content.replace(old_copyright_notice, new_copyright_notice) + + writer = open(file, "w", newline="") + + if old_copyright_notice in file_content or new_copyright_notice in file_content: + writer.write(new_content) + else : + writer.write(new_copyright_notice + file_content) + + writer.close() diff --git a/Scripts/Package.py b/Scripts/Package.py new file mode 100644 index 0000000..191352e --- /dev/null +++ b/Scripts/Package.py @@ -0,0 +1,67 @@ +# Copyright (c) TribuFu. All Rights Reserved + +import os +import subprocess +import platform +import shutil + +from pathlib import Path + +Path("./Package/Include").mkdir(parents=True, exist_ok=True) +Path("./Package/Library").mkdir(parents=True, exist_ok=True) + +shutil.copy2("./Source/TribuFu.h", "./Package/Include/TribuFu.h") + +if platform.system() == "Windows": + Path("./Package/Library/Windows").mkdir(parents=True, exist_ok=True) + + shutil.copy2("./Binaries/release/TribuFu.dll", "./Package/Library/Windows/TribuFu.dll") + shutil.copy2("./Binaries/release/TribuFu.dll.lib", "./Package/Library/Windows/TribuFu.dll.lib") + shutil.copy2("./Binaries/release/TribuFu.lib", "./Package/Library/Windows/TribuFu.lib") + + subprocess.check_call( + [ + "./Vendor/rcedit.exe", + "./Package/Library/Windows/TribuFu.dll", + "--set-file-version", + "0.0.1", + "--set-product-version", + "0.0.1", + "--set-version-string", + "CompanyName", + "TribuFu", + "--set-version-string", + "FileDescription", + "SDK for games and apps access TribuFu services.", + "--set-version-string", + "FileVersion", + "0.0.1", + "--set-version-string", + "InternalName", + "SDK", + "--set-version-string", + "LegalCopyright", + "Copyright (c) TribuFu. All Rights Reserved", + "--set-version-string", + "OriginalFilename", + "TribuFu.dll", + "--set-version-string", + "ProductName", + "TribuFu SDK", + "--set-version-string", + "ProductVersion", + "0.0.1", + ] + ) + +elif platform.system() == "Linux": + Path("./Package/Library/Linux").mkdir(parents=True, exist_ok=True) + + shutil.copy2("./Binaries/release/libTribuFu.so", "./Package/Library/Linux/libTribuFu.so") + shutil.copy2("./Binaries/release/libTribuFu.a", "./Package/Library/Linux/libTribuFu.a") + +elif platform.system() == "Mac": + Path("./Package/Library/Mac").mkdir(parents=True, exist_ok=True) + + shutil.copy2("./Binaries/release/libTribuFu.dylib", "./Package/Library/Mac/libTribuFu.dylib") + shutil.copy2("./Binaries/release/libTribuFu.a", "./Package/Library/Mac/libTribuFu.a")