(program = None)
| 7 | |
| 8 | # SCons AttachConfig Command Function |
| 9 | def GenAttachConfigProject(program = None): |
| 10 | Rtt_Root = os.getcwd() |
| 11 | config_file = os.path.join(os.getcwd(), 'rtt_root', Rtt_Root, '.config') |
| 12 | config_bacakup = config_file+'.origin' |
| 13 | rtconfig_file = os.path.join(os.getcwd(), 'rtt_root', Rtt_Root, 'rtconfig.h') |
| 14 | rtconfig__bacakup = rtconfig_file+'.origin' |
| 15 | if GetOption('attach') == '?': |
| 16 | attachconfig=[] |
| 17 | GetAttachConfig("get",attachconfig,0) |
| 18 | print("\033[32m✅ AttachConfig has: \033[0m") |
| 19 | prefix=attachconfig[0] |
| 20 | for line in attachconfig: |
| 21 | temp_prefix=line.split(".", 1) |
| 22 | if prefix!=temp_prefix[0]: |
| 23 | print("\033[42m \033[30m------"+temp_prefix[0]+"------\033[0m") |
| 24 | prefix=temp_prefix[0] |
| 25 | print(line) |
| 26 | |
| 27 | |
| 28 | elif GetOption('attach') == 'default': |
| 29 | if os.path.exists(config_bacakup): |
| 30 | shutil.copyfile(config_bacakup, config_file) |
| 31 | os.remove(config_bacakup) |
| 32 | if os.path.exists(rtconfig__bacakup): |
| 33 | shutil.copyfile(rtconfig__bacakup, rtconfig_file) |
| 34 | os.remove(rtconfig__bacakup) |
| 35 | print("\033[32m✅ Default .config and rtconfig.h recovery success!\033[0m") |
| 36 | else: |
| 37 | attachconfig=GetOption('attach') |
| 38 | attachconfig_result=[] |
| 39 | GetAttachConfig("search",attachconfig,attachconfig_result) |
| 40 | if attachconfig_result==[]: |
| 41 | print("❌\033[31m Without this AttachConfig:"+attachconfig+"\033[0m") |
| 42 | return |
| 43 | if os.path.exists(config_bacakup)==False: |
| 44 | shutil.copyfile(config_file, config_bacakup) |
| 45 | if os.path.exists(rtconfig__bacakup)==False: |
| 46 | shutil.copyfile(rtconfig_file, rtconfig__bacakup) |
| 47 | with open(config_file, 'a') as destination: |
| 48 | for line in attachconfig_result: |
| 49 | destination.write(line + '\n') |
| 50 | from env_utility import defconfig |
| 51 | defconfig(Rtt_Root) |
| 52 | print("\033[32m✅ AttachConfig add success!\033[0m") |
| 53 | |
| 54 | def GetAttachConfig(action,attachconfig,attachconfig_result): |
| 55 | rtt_root = os.getcwd() |
no test coverage detected