diff --git a/post_extra_script.py b/post_extra_script.py index df94950..54a1782 100644 --- a/post_extra_script.py +++ b/post_extra_script.py @@ -22,13 +22,21 @@ def copy_files(): ] for src, dest in files: shutil.copyfile(src, f'release/{dest}') - print("==========> Bin files are copied to the /release folder.") + print("==========> Bin files are copied to the /release folder.\n") def convert_single_bin(): + build_dir = env.subst("$BUILD_DIR") + binary_path = os.path.join(build_dir, "firmware.bin") + bootloader_path = os.path.join(build_dir, "bootloader.bin") + partitions_path = os.path.join(build_dir, "partitions.bin") + release_path = os.path.join(env.subst("$PROJECT_DIR"), "release") + merged_file = os.path.join(release_path, f"esp32nat_Router+_full_v{version}_0x0.bin") + esptool_dir = env.PioPlatform().get_package_dir("tool-esptoolpy") + esptool_command = f'python {str(esptool_dir)}\\esptool.py --chip esp32 merge_bin -o {merged_file} --flash_freq 40m --flash_size 4MB 0x1000 {bootloader_path} 0x8000 {partitions_path} 0x10000 {binary_path}' + os.makedirs("release", exist_ok=True) - os.system( - f'esptool.py --chip esp32 merge_bin -o release/esp32nat_Router+_full_v{version}_0x0.bin --flash_freq 40m --flash_size 4MB 0x1000 release/bootloader.bin 0x10000 release/esp32nat_Router+_v{version}.bin 0x8000 release/partitions.bin') + env.Execute(esptool_command) zip_all_bins() @@ -47,7 +55,7 @@ def zip_all_bins(): zipObj.write( f'release/esp32nat_Router+_full_v{version}_0x0.bin', f'esp32nat_Router+_full_v{version}_0x0.bin') - print("==========> zip files created successfully") + print("\n==========> zip files created successfully") def after_build_program(source, target, env): @@ -57,4 +65,4 @@ def after_build_program(source, target, env): convert_single_bin() -env.AddPostAction("$BUILD_DIR/firmware.bin", after_build_program) +env.AddPostAction("buildprog", after_build_program) diff --git a/pre_extra_script.py b/pre_extra_script.py index 18fe343..2178719 100644 --- a/pre_extra_script.py +++ b/pre_extra_script.py @@ -3,6 +3,7 @@ import os import gzip import re +import platform print("\033[94m╔═╗┌─┐┌─┐ ╔╗╔┌─┐┌┬┐ ╦═╗┌─┐┬ ┬┌┬┐┌─┐┬─┐ _|_\n║╣ └─┐├─┘32─║║║├─┤ │ ╠╦╝│ ││ │ │ ├┤ ├┬┘ | \n╚═╝└─┘┴ ╝╚╝┴ ┴ ┴ ╩╚═└─┘└─┘ ┴ └─┘┴└─\033[0m\n") @@ -14,6 +15,7 @@ version = config.get("extra_script_settings", "version") jekyll_install_status = False +system_platform = platform.system() if os.system('jekyll -v') == 0: # print('Jekyll is installed on your system.') @@ -22,14 +24,14 @@ print( '\033[91mJekyll is not installed on your system. Please install Jekyll.\033[0m') - -# uncomment for linux and git bash users -# def build_site(): -# env.Execute("build_web_pages.sh") - -# for windows user -def build_site(): - env.Execute("build_web_pages.bat") +if system_platform =="Linux": + # for linux user + def build_site(): + env.Execute("build_web_pages.sh") +elif system_platform == "Windows": + # for windows user + def build_site(): + env.Execute("build_web_pages.bat") base_folder_path = './components/web_server/www/'