Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elf2bin.py objcopy cleanup #7351

Merged
merged 4 commits into from
Jun 6, 2020

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Jun 5, 2020

Per https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp

Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it.

read_segment()'s dumpfile was never deleted, producing 5 'segment' files each build.

Instead, this patch creates a temporary directory which is later used for objcopy output. TemporaryDirectory() context manager will handle the deletion.
Plus, some minor refactoring to reduce line length and add some pythonisms (hopefully, not too much)

Noticed this issue accidentally by inspecting a specific Windows PC install using WSL circa January. /tmp was ~2.5GB and there was a lot of files.

tools/elf2bin.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix, but needs to have #7348 merged before it can go in. The TemporaryDirectory method isn't available in Python2 (which is the only one installed on Macs until the very latest release AFAIK).

Using a mkdtemp call and cleaning up afterward would allow it to go in even if #7348 isn't merged as that's available since Python2.

tools/elf2bin.py Show resolved Hide resolved
@earlephilhower earlephilhower added this to the 2.7.2 milestone Jun 6, 2020
@earlephilhower earlephilhower merged commit 23febc1 into esp8266:master Jun 6, 2020
@mcspr mcspr deleted the elf2bin-objcopy-cleanup branch June 8, 2020 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants