Skip to content

Commit 41ce4b2

Browse files
Ensure makeboards.py writes UNIX newlines (#2264)
The repo and development use only '\n' (UNIX) EOLs. When a user runs makeboards on a Windows system they end up changing every line in boards.txt and the JSON files to Windows '\r\n' format. Explicitly set the newline character when opening the output files to avoid this.
1 parent e8a2654 commit 41ce4b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/makeboards.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,14 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
356356
.replace('USBPWR', str(pwr))\
357357
.replace(' EXTRA_INFO', m_extra.rstrip())
358358
jsondir = os.path.abspath(os.path.dirname(__file__)) + "/json"
359-
f = open(jsondir + "/" + name + ".json", "w")
359+
f = open(jsondir + "/" + name + ".json", "w", newline='\n')
360360
f.write(json)
361361
f.close()
362362

363363
pkgjson = json.load(open(os.path.abspath(os.path.dirname(__file__)) + '/../package/package_pico_index.template.json'))
364364
pkgjson['packages'][0]['platforms'][0]['boards'] = []
365365

366-
sys.stdout = open(os.path.abspath(os.path.dirname(__file__)) + "/../boards.txt", "w")
366+
sys.stdout = open(os.path.abspath(os.path.dirname(__file__)) + "/../boards.txt", "w", newline='\n')
367367
WriteWarning()
368368
BuildGlobalMenuList()
369369

@@ -530,5 +530,5 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
530530
MakeBoard("generic", "Generic", "RP2040", "0x2e8a", "0xf00a", 250, "GENERIC_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
531531

532532
sys.stdout.close()
533-
with open(os.path.abspath(os.path.dirname(__file__)) + '/../package/package_pico_index.template.json', 'w') as f:
533+
with open(os.path.abspath(os.path.dirname(__file__)) + '/../package/package_pico_index.template.json', 'w', newline='\n') as f:
534534
f.write(json.dumps(pkgjson, indent=3))

0 commit comments

Comments
 (0)