Skip to content

Commit

Permalink
ci: add more checker when install tools
Browse files Browse the repository at this point in the history
Signed-off-by: Huaqi Fang <578567190@qq.com>
  • Loading branch information
fanghuaqi committed Dec 29, 2023
1 parent 5aaa92e commit 2415bfb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 20 additions & 5 deletions .github/prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,22 @@ def setup_gd_openocd(toolsdir, gd_openocd_url, system_value, gd_openocd_folder_n
REUSE_ARCHIVE = True

def prepare_tools():
if platform.system() == "Windows":
ostype = platform.system()
print("Setup Tools for %s" % (ostype))
if platform.architecture()[0] != '64bit':
print("ERROR: Currently only support 64bit OS!")
sys.exit(1)
if ostype == "Windows":
# Windows Setup
setup_nuclei_studio(PREBLT_TOOLS, nuclei_win_url, ["windows_amd64"], REUSE_ARCHIVE)
setup_gd_openocd(PREBLT_TOOLS, gd_openocd_win_url, ["windows_amd64"], "gd_openocd", REUSE_ARCHIVE)
elif platform.system() == "Linux":
elif ostype == "Linux":
# Linux Setup
setup_nuclei_studio(PREBLT_TOOLS, nuclei_linux_url, ["linux_x86_64"], REUSE_ARCHIVE)
setup_gd_openocd(PREBLT_TOOLS, gd_openocd_linux_url, ["linux_x86_64"], "gd_openocd", REUSE_ARCHIVE)

else:
print("ERROR: Unsupported OS")
sys.exit(1)
pass

def install_pio_packages(nsdk_url="https://github.com/Nuclei-Software/nuclei-sdk#feature/gd32vw55x"):
Expand Down Expand Up @@ -201,14 +208,22 @@ def install_pio_packages(nsdk_url="https://github.com/Nuclei-Software/nuclei-sdk

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Prepare Nuclei Tools and Install PIO Packages.')
parser.add_argument('--sdk', "-s", default="https://github.com/Nuclei-Software/nuclei-sdk#feature/gd32vw55x", help='URL or PATH of Nuclei SDK')
parser.add_argument('--install', action='store_true', help="Always install required tools")
parser.add_argument('--pio', action='store_true', help="Setup PIO Package")
parser.add_argument('--sdk', "-s", default="https://github.com/Nuclei-Software/nuclei-sdk#feature/gd32vw55x", help='URL or PATH of Nuclei SDK')

args = parser.parse_args()

needinstall = True
if os.path.isdir(PREBLT_TOOLS):
needinstall = False
print("%s existed, maybe tools already installed!" % (PREBLT_TOOLS))
else:
if args.install:
print("Remove and reinstall %s" % (PREBLT_TOOLS))
shutil.rmtree(PREBLT_TOOLS)
needinstall = True

if needinstall:
prepare_tools()

if args.pio:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Install and Setup Nuclei Tools
run: |
python3 -u .github/prepare_tools.py
python3 -u .github/prepare_tools.py --install
- name: Upload cached packages
uses: actions/upload-artifact@v3
Expand All @@ -46,4 +46,4 @@ jobs:
- name: Build examples
run: |
python3 .github/build_examples.py
python3 -u .github/build_examples.py

0 comments on commit 2415bfb

Please sign in to comment.