code analysis tools

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

code analysis tools

kitwallace
I write a lot of OpenSCAD functions which I somewhat arbitarily organise into
multipe libraries.  When making the code available, for example this work on
generating polyhedra from Miller indices
 
https://kitwallace.tumblr.com/post/629139975142866944/miller-indices-to-polyhedra

I would like to be able to generate a script which extracts the functions
actually being used in the script to create a stand-alone version rather
than expect the user to download all the libraries.

Any pointers to existing analyis / parsing tools before I try to hack
sometihing myself?





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: code analysis tools

W. Craig Trader
Kit ...

I had a similar problem; here's my solution:


It's a Python 3 script that will create an all-in-one OpenSCAD model that includes the model plus all of the libraries that the model depends upon into a single file. It doesn't attempt to detect module or function dependencies within a library; it just grabs the entire library file, but ensures that any one library file will only be included once.

- Craig -

On Wed, Oct 7, 2020 at 3:24 AM kitwallace <[hidden email]> wrote:
I write a lot of OpenSCAD functions which I somewhat arbitarily organise into
multipe libraries.  When making the code available, for example this work on
generating polyhedra from Miller indices

https://kitwallace.tumblr.com/post/629139975142866944/miller-indices-to-polyhedra

I would like to be able to generate a script which extracts the functions
actually being used in the script to create a stand-alone version rather
than expect the user to download all the libraries.

Any pointers to existing analyis / parsing tools before I try to hack
sometihing myself?





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: code analysis tools

kitwallace
Thanks Craig for that python script - very useful.  I made a small change to
the include regexp because the syntax doesn't require a terminating ;

INCLUDE = re.compile( '^include <(.*)>;?$' )

I can see that expanding use statements does require more parsing.

Some of my libraries are quite big so I would like to include only the
functions and modules referenced but that needs a full parse.  I've just
found a new JS project  
https://www.npmjs.com/package/openscad-parser which looks like it could be
adapted to do the job and to support visualisation of the call network.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org