Skip to content

exporters - group by directories in prj root #3559

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

Merged
merged 1 commit into from
Jan 12, 2017

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Jan 10, 2017

Update exporter grouping code to group by directories in the root of the project rather than by the parent directory of each file. This reduces the number of groups and allows all mbed-os code to reside in its own folder.

@c1728p9 c1728p9 requested a review from theotherjimmy January 10, 2017 17:34
key = basename(dirname(src))
if key == ".":
key = basename(realpath(self.export_dir))
rel_path = os.path.relpath(src, self.project_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work on the online environment. Please use relpath(src, self.resources.file_basepath[src])

Update exporter grouping code to group by directories in the root
of the project rather than by the parent directory of each file. This
reduces the number of groups and allows all mbed-os code to reside
in its own folder.
@c1728p9 c1728p9 force-pushed the simplify_exporter_dirs branch from ab564dd to 329be06 Compare January 10, 2017 17:43
@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 10, 2017

/morph export-build

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph export-build

Output

mbed Build Number: 76

All exports and builds passed!

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 10, 2017

@VeliMattiLahtela the cliapp job failed for this PR so I restarted it.

@bridadan
Copy link
Contributor

@c1728p9 Do you mind showing a before and after of the project layout? So for https://github.com/ARMmbed/mbed-os-example-client would it look something like:

Before:

/source
/lwip
/targets
/TARGET_X
/TOOLCHAIN_X
(etc)

After:

/artmel-rf-driver
   - all files in all subdirectories flattened here
/esp8266-driver
   - all files in all subdirectories flattened here
/mbed-client
   - all files in all subdirectories flattened here
/mbed-os
   - all files in all subdirectories flattened here
(etc)

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 10, 2017

Here is what it looks like before (left) and after (right):
before_and_after

@bridadan
Copy link
Contributor

@c1728p9 Are all of the mbed-os files flattened within the "mbed-os" directory in the "After" picture?

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 11, 2017

yeah

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 11, 2017

@c1728p9 Are all of the mbed-os files flattened within the "mbed-os" directory in the "After" picture?

If that's true, one folder will contain all mbed-os files without any structure? I don't like that. Having at least some tree there would be nice. As it is it's not ideal neither.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 11, 2017

I agree, having a tree structure would be ideal. Correct me if I'm wrong but I was under the assumption that uvision only allowed one level of groups (directories). With this patch those groups match those of the root directory of the project. Prior to this patch each file was placed in a group with the name of its parent directory.

@bridadan
Copy link
Contributor

Correct me if I'm wrong but I was under the assumption that uvision only allowed one level of groups (directories)

I believe that's correct yes.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 12, 2017

I restarted jenkins CI. Once that green, should be ready to integrate

@adbridge adbridge merged commit 33aff48 into ARMmbed:master Jan 12, 2017
Copy link
Contributor

@sarahmarshy sarahmarshy left a comment

Choose a reason for hiding this comment

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

The non-nested groups is a limitation of uvision. It might be annoying now to edit mbed-os, as those files will be flattened, as mentioned above. However, the normal user probably wants to use uvision to modify their own source anyway.

key = basename(realpath(self.export_dir))
rel_path = relpath(src, self.resources.file_basepath[src])
path_list = os.path.normpath(rel_path).split(os.sep)
assert path_list >= 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the assert here? Wouldn't this trigger a runtime traceback if it were true?

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, what is the check trying to accomplish? It is not comparing the length of the list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. This is a mistake and should be removed or updated to be "len(path_list )".

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @c1728p9. Probably the easiest way to fix this is to just submit another PR, changing this assert to an exception that actually checks len(path_list). @sarahmarshy feel free to submit this if you know the proper way of handling the exception!

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that correct behavior though? say src is C:\Project\mbed-os\src.cpp. Then relpath=mbed-os\src.cpp, then path_list = [mbed-os, src.cpp], which would be a list length >=1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created #3574 to fix this. This assert triggers in the case where the list is empty, as this is invalid and would cause an exception later anyway. This assert doesn't really matter though and I can remove it if you would like.

@c1728p9 c1728p9 deleted the simplify_exporter_dirs branch January 12, 2017 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants