NVSL / Swoop

Other
8 stars 10 forks source link

Library names do not uniquely identify a library #18

Open ppannuto opened 4 years ago

ppannuto commented 4 years ago

This unfortunate situation is a product of managed libraries. It is valid to have two libraries with the same name in a project:

<library name="regulators">
...
<library name="regulators" urn="urn:adsk.eagle:library:20878889">

where the former is a regular library, and the latter is a managed library.

This results in the "sanity check" producing spurious errors because it only uses the name to search libraries.

  File "/usr/local/lib/python3.7/site-packages/Swoop/Swoop.py", line 48058, in check_sanity
    raise SwoopError("DeviceSet '" + self.find_library().name + ":" + self.deviceset + "' missing for '" + str(self.name) + "'")
Swoop.Swoop.SwoopError: DeviceSet 'regulators:+3V3' missing for 'P+1'

Instead, it needs to use the name plus the urn, but only if the urn exists. If we look at two parts:

<part name="P+1" library="regulators" deviceset="+3V3" device=""/>
...
<part name="U4" library="regulators" library_urn="urn:adsk.eagle:library:20878889" deviceset="XCL206" device="B" package3d_urn="urn:adsk.eagle:package:20878971/3" value="1.8V"/>

The former is in the "regular library" while the latter is in a "managed library".


How would you get into this mess, you ask? Well, the new integration with Fusion 360 for 3D modeling is really nice, especially if you're trying to fit a board into a case. However, you're only allowed to have 3D packages for parts that are in managed libraries. You would begin by uploading your existing libraries Autodesk's new library service to make them managed libraries (that's how you end up with libraries of the same name). You would then only update the parts that are bigger or near something possibly important, so your old board ends up with a mixture of parts from regular and managed libraries.


What to do? Ideally, Swoop would become aware of managed libraries and use urns as part of the identifier for a library. That's probably the most robust fix. Unfortunately, that's also a bit beyond the scope of what I have the time or energy to do at the moment.

Alternatively, Swoop could simply detect this and print an explanation. Board authors could then in some way fix this conflict -- e.g. perhaps by renaming one of the libraries or by updating all components to be in a managed (or not) library.

ppannuto commented 4 years ago

Example board with these mixed libraries: https://github.com/lab11/totternary/tree/74b43d4afc6b09c30031be64a5c1de60daeba944/hardware/tottag/rev_g