-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Review Only - Do Not Merge] Adham/scripts #11
Open
phillipjohnston
wants to merge
13
commits into
main
Choose a base branch
from
adham/scripts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b8d34a1
Initial commit of project skeleton files.
AdhamEA dfe1f64
adding python Files
AdhamEA ea70938
adding another file
AdhamEA 932af80
adding python files
AdhamEA 9905891
updating python files
AdhamEA f9c6ee1
adding python files
AdhamEA 53dfc9f
updating a python file
AdhamEA 18427e1
updates...
AdhamEA 8a02a2a
Revert "Initial commit of project skeleton files."
phillipjohnston 0996f8c
updates...
AdhamEA 8f83394
updates ...
AdhamEA 3c6e5d0
Merge branch 'adham/scripts' of https://github.com/embeddedartistry/p…
AdhamEA 300dd92
updates...
AdhamEA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import getopt | ||
import sys | ||
import os | ||
import subprocess | ||
import platform | ||
import shutil | ||
from turtle import clone, update | ||
import git | ||
from git import Repo | ||
import adr_func | ||
|
||
|
||
|
||
use_adr=0 | ||
use_pottery=0 | ||
copy_license=0 | ||
use_git=1 | ||
use_submodules=1 | ||
replace_name = None | ||
check_dir="c:/subprojects" | ||
|
||
|
||
def help(): | ||
print("Usage: deploy_skeleton.sh [optional ags] dest_dir ") | ||
print("Optional args:") | ||
print("-a: initialize destination to use adr-tools") | ||
print(" -p: initialize destination to use pottery") | ||
print("-l: copy the license file") | ||
print("-r <name>: Replace template project/app name values with specified name") | ||
print("-g: Assume non-git environment. Installs submodule files directly.") | ||
print("-s: Don't use submodules, and copy files directly") | ||
print("-k : Check directory ") | ||
exit () | ||
|
||
if (platform.release() == "Darwin"): | ||
sed="sed -i ''" | ||
else: | ||
sed="sed -i" | ||
|
||
try : | ||
opts, args = getopt.getopt(sys.argv[1:], "aplghsrk:") | ||
except: | ||
print("Error !") | ||
help() | ||
for o , a in opts: | ||
if o == "-a" : | ||
use_adr = 1 | ||
elif o == "-p": | ||
use_pottery=1 | ||
elif o == "-l": | ||
copy_license=1 | ||
elif o == "-g": | ||
use_git=0 | ||
use_submodules=0 | ||
elif o =="-r": | ||
replace_name=args[0] | ||
elif o == "-k": | ||
check_dir=input("CHECK_DIRECTORY : ") | ||
elif o =="-h": | ||
help() | ||
|
||
else : | ||
print(f"Invalid option {args[0]}") | ||
help() | ||
|
||
|
||
|
||
pwd=os.getcwd() | ||
check_path_1= os.path.exists(f"{check_dir}/Tools") | ||
if(check_path_1==False): | ||
check_dir=os.chdir(f"{check_dir}") | ||
check_path_1= os.path.exists(f"{check_dir}") | ||
if(check_path_1==False): | ||
print("This script must be run from the project skeleton root or the tools/ directory.") | ||
exit () | ||
|
||
|
||
dest_dir=args[0] | ||
dest_path_2= os.path.exists(f"{dest_dir}") | ||
if(dest_path_2==False): | ||
dest_path_2= os.path.exists(f"{pwd}/{dest_dir}") | ||
if(dest_path_2==False): | ||
dest_dir=f"{pwd}/{dest_dir}" | ||
else: | ||
print(f"Destination directory {dest_dir} cannot be found. Does it exist?") | ||
exit() | ||
|
||
|
||
# Remove .DS_Store files | ||
|
||
|
||
findCMD = f'find . -name ".DS_Store"' | ||
out = subprocess.Popen(findCMD,shell=True,stdin=subprocess.PIPE | ||
,stdout=subprocess.PIPE,stderr=subprocess.PIPE) | ||
for file in os.listdir("c:"): | ||
if file.endswith(".DS_Store"): | ||
shutil.rmtree(file) | ||
|
||
|
||
core_files="docs src test tools .clang-format .clang-tidy Makefile meson.build meson_options.txt README.md" | ||
git_files=".gitattributes .github .gitignore" | ||
|
||
|
||
submodule_dirs="build" | ||
submodule_urls="git@github.com:embeddedartistry/meson-buildsystem.git" | ||
|
||
# Copy skeleton files to the destination | ||
|
||
shutil.copytree(core_files,dest_dir) | ||
path = os.path.join(dest_dir, f"{check_dir}") | ||
os.mkdir(path) | ||
shutil.copytree("subprojects/*.wrap",f"{dest_dir}/subprojects" ) | ||
shutil.rmtree(f"{dest_dir}/tools/deploy_skeleton.py") | ||
shutil.rmtree(f"{dest_dir}/tools/download_and_deploy.py") | ||
if (use_git == 1): | ||
shutil.copytree(git_files,dest_dir) | ||
if (use_submodules==0): | ||
repo = git.Repo(pwd) | ||
output = repo.git.submodule('update','--init','--recursive') | ||
shutil.copytree(submodule_dirs,dest_dir) | ||
if (copy_license == 1): | ||
shutil.copytree("LICENSE",dest_dir) | ||
|
||
## The following operations all take place in the destination directory | ||
|
||
os.chdir(dest_dir) | ||
|
||
# Initialize Submodules | ||
|
||
if (use_submodules==1): | ||
repo = git.Repo(submodule_urls) | ||
output = repo.git.submodule('add') | ||
index=Repo.init(submodule_dirs).index | ||
index.commit("Add submodules from project skeleton. ") | ||
else : | ||
findCMD = f'find {submodule_dirs} -name ".git*"' | ||
out = subprocess.Popen(findCMD,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE) | ||
for file in os.listdir(submodule_dirs): | ||
if file.endswith(".git*"): | ||
shutil.rmtree(submodule_dirs) | ||
if (use_git==1): | ||
repo.git.add(all=True ) | ||
|
||
index=Repo.init(submodule_dirs).index | ||
index.commit("Initial commit of project skeleton files.") | ||
|
||
if (replace_name !=""): | ||
subprocess.Popen(f"{sed} ",f's/PROJECT_NAME/{replace_name}/g "meson.build"') | ||
replace_name=f"{replace_name}// /_" | ||
subprocess.Popen(f"{sed} ",f's/PROJECT_NAME/{replace_name}/g "src/app/meson.build"') | ||
subprocess.Popen(f"{sed} ",f's/PROJECT_NAME/{replace_name}/g "test/meson.build"') | ||
|
||
if(use_git==1): | ||
index=Repo.init(submodule_dirs).index | ||
index.commit(f"Replace placeholder values in build files with {replace_name} ") | ||
|
||
if(use_adr==1): | ||
adr_func.adr_init('/docs') | ||
if use_git==1: | ||
repo.git.add(all=True ) | ||
index=Repo.init(submodule_dirs).index | ||
index.commit("Initiaize adr-tools") | ||
|
||
if(use_git==1): | ||
try: | ||
repo.git.pull("adham") | ||
repo.git.push("adham") | ||
except: | ||
print("WARNING: git push failed: check repository.") | ||
|
||
if(replace_name ==""): | ||
print("NOTE: Replace the placeholder project name in meson.build") | ||
print("NOTE: Replace the placeholder application name in src/app/meson.build") | ||
print("NOTE: Replace the placeholder test application name in test/meson.build") | ||
|
||
variable_1=os.path.isfile(f"{dest_dir}/LICENSE") | ||
variable_2=os.path.isfile(f"{dest_dir}/LICENSE.md") | ||
|
||
if ( (copy_license==0 and variable_1==False) or variable_2==False): | ||
print("NOTE: Your project does not have a LICENSE or LICENSE.md file in the project root.") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import git | ||
import shutil | ||
import platform | ||
|
||
|
||
pwd=os.getcwd() | ||
initial_dir=pwd | ||
|
||
linux_dir="\tmp" | ||
windows_dir="C://tmp" | ||
if (platform.system() == "Darwin" or platform.system() == "Linux" ): | ||
temporary_dir=linux_dir | ||
os.mkdir(temporary_dir) | ||
os.chdir(temporary_dir) | ||
git.Git().clone("https://github.com/embeddedartistry/project-skeleton","project-skeleton",depth=1,recursive=True) | ||
os.chdir(f"{temporary_dir}\project-skeleton\tools") | ||
exec(open('deploy_skeleton.py').read()) | ||
os.chdir(temporary_dir) | ||
shutil.rmtree(f"{temporary_dir}\project-skeleton") | ||
os.chdir(f"{initial_dir}") | ||
|
||
else: | ||
temporary_dir=windows_dir | ||
os.mkdir(temporary_dir) | ||
os.chdir(temporary_dir) | ||
git.Git().clone("https://github.com/embeddedartistry/project-skeleton","project-skeleton",depth=1,recursive=True) | ||
os.chdir(f"{temporary_dir}/project-skeleton/tools") | ||
exec(open('deploy_skeleton.py').read()) | ||
os.chdir(temporary_dir) | ||
shutil.rmtree(f"{temporary_dir}/project-skeleton") | ||
os.chdir(f"{initial_dir}") | ||
|
||
|
||
|
||
|
||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import git | ||
import shutil | ||
import platform | ||
|
||
pwd=os.getcwd() | ||
initial_dir=pwd | ||
linux_dir="/tmp" | ||
windows_dir="C:\\tmp" | ||
if (platform.system() == "Darwin" or platform.system() == "Linux" ): | ||
|
||
temporary_dir=linux_dir | ||
os.mkdir(temporary_dir) | ||
os.chdir(temporary_dir) | ||
git.Git().clone("https://github.com/embeddedartistry/config-files","config-files",depth=1) | ||
os.chdir(f"{temporary_dir}\config-files") | ||
exec(open('copy_config.sh').read()) | ||
os.chdir(temporary_dir) | ||
shutil.rmtree(f"{temporary_dir}\config-files") | ||
os.chdir(f"{initial_dir}") | ||
|
||
else : | ||
temporary_dir=windows_dir | ||
os.mkdir(temporary_dir) | ||
os.chdir(temporary_dir) | ||
git.Git().clone("https://github.com/embeddedartistry/config-files","config-files",depth=1) | ||
os.chdir(f"{temporary_dir}\\config-files") | ||
exec(open('copy_config.sh').read()) | ||
os.chdir(temporary_dir) | ||
shutil.rmtree(f"{temporary_dir}\\config-files") | ||
os.chdir(f"{initial_dir}") | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
import platform | ||
import os.path | ||
import wget | ||
import shutil | ||
import tarfile | ||
import sys | ||
|
||
|
||
# pwd | ||
pwd=os.getcwd() | ||
STARTING_DIR=pwd | ||
# taking arguments from the client | ||
args=sys.argv[1:] | ||
if (args[0]==None): | ||
TOOLCHAIN_INSTALL_DIR = "/usr/local/toolchains " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The space at the end is not needed. |
||
else : | ||
TOOLCHAIN_INSTALL_DIR = args[0] | ||
#TOOLCHAIN_INSTALL_DIR=input(" Please inssert TOOLCHAIN_INSTALL_DIR :") | ||
if(args[1]==None): | ||
TOOLCHAIN_DISABLE_SUDO = 0 | ||
else : | ||
TOOLCHAIN_DISABLE_SUDO = args[1] | ||
|
||
TOOLCHAIN_SUDO="sudo" | ||
|
||
if (TOOLCHAIN_DISABLE_SUDO==1): | ||
TOOLCHAIN_SUDO = None | ||
OSX_ARM_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-mac.tar.bz2" | ||
LINUX_ARM_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-aarch64-linux.tar.bz2" | ||
|
||
if (platform.release() == "Darwin"): | ||
ARM_URL = OSX_ARM_URL | ||
ARM_DIR=os.path.basename(f"{ARM_URL}"+"-mac.tar.bz2") | ||
else: | ||
ARM_URL=LINUX_ARM_URL | ||
ARM_DIR=os.path.basename(f"{ARM_URL}"+"-aarch64-linux.tar.bz2") | ||
|
||
ARM_ARCHIVE=os.path.basename(f"{ARM_URL}") | ||
|
||
|
||
################################### | ||
# Download and install dependency # | ||
################################### | ||
|
||
os.chdir('c:\\tmp') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same tmp problem here |
||
wget.download(ARM_URL,'c:\\tmp') | ||
os.makedirs(TOOLCHAIN_INSTALL_DIR,exist_ok=True) | ||
# Move current toolchain if it exists | ||
if (os.path.exists(f'{TOOLCHAIN_INSTALL_DIR}/gcc-arm-none-eabi')==True): | ||
os.system("sudo su-") | ||
shutil.rmtree(f"{TOOLCHAIN_INSTALL_DIR}/gcc-arm-none-eabi") | ||
shutil.move(f'{TOOLCHAIN_INSTALL_DIR}/gcc-arm-none-eabi',f'{TOOLCHAIN_INSTALL_DIR}/gcc-arm-none-eabi-bak') | ||
tar=tarfile.open(f"{ARM_ARCHIVE}") | ||
os.chdir(f"{TOOLCHAIN_INSTALL_DIR}") | ||
a=os.getcwd() | ||
tar.extractall(a) # specify which folder to extract to | ||
|
||
tar.close() | ||
shutil.move(f'{TOOLCHAIN_INSTALL_DIR}/{ARM_DIR}',f'{TOOLCHAIN_INSTALL_DIR}/gcc-arm-none-eabi') | ||
os.remove(f"{ARM_ARCHIVE}") | ||
os.chdir(f"{STARTING_DIR}") | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean up these whitespace gaps before the final merge.