Browse Source

change: 改写info.json时使用xmake提供的json解析库

Wendal Chen 3 years ago
parent
commit
547085a994
1 changed files with 9 additions and 5 deletions
  1. 9 5
      xmake.lua

+ 9 - 5
xmake.lua

@@ -463,16 +463,20 @@ target("air10x")
                 if AIR10X_FLASH_FS_REGION_SIZE then
                 if AIR10X_FLASH_FS_REGION_SIZE then
                     print("AIR10X_FLASH_FS_REGION_SIZE",AIR10X_FLASH_FS_REGION_SIZE)
                     print("AIR10X_FLASH_FS_REGION_SIZE",AIR10X_FLASH_FS_REGION_SIZE)
                     local info_data = io.readfile("./soc_tools/"..TARGET_NAME..".json")
                     local info_data = io.readfile("./soc_tools/"..TARGET_NAME..".json")
-                    local LVGL_CONF = info_data:gsub("\"size\" : 112\n","\"size\" : "..AIR10X_FLASH_FS_REGION_SIZE.."\n")
-                    local offset,LVGL_JSON
+                    import("core.base.json")
+                    local data = json.decode(info_data)
+                    data.rom.fs.script.size = tonumber(AIR10X_FLASH_FS_REGION_SIZE)
                     if TARGET_NAME == "AIR101" then
                     if TARGET_NAME == "AIR101" then
                         offset = string.format("%X",0x81FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
                         offset = string.format("%X",0x81FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
-                        LVGL_JSON = LVGL_CONF:gsub("\"offset\" : \"81E0000\",\n","\"offset\" : \""..offset.."\",\n")
+                        data.download.script_addr = offset
+                        data.rom.fs.script.offset = offset
                     else
                     else
                         offset = string.format("%X",0x80FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
                         offset = string.format("%X",0x80FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
-                        LVGL_JSON = LVGL_CONF:gsub("\"offset\" : \"80E0000\",\n","\"offset\" : \""..offset.."\",\n")
+                        data.download.script_addr = offset
+                        data.rom.fs.script.offset = offset
                     end
                     end
-                    io.writefile("./soc_tools/info.json", LVGL_JSON)
+                    io.writefile("./soc_tools/info.json", json.encode(data))
+                    print(json.encode(data))
                 else
                 else
                     print("AIR10X_FLASH_FS_REGION_SIZE", "default", 112)
                     print("AIR10X_FLASH_FS_REGION_SIZE", "default", 112)
                     os.cp("./soc_tools/"..TARGET_NAME..".json", "./soc_tools/info.json")
                     os.cp("./soc_tools/"..TARGET_NAME..".json", "./soc_tools/info.json")