Haskell-Things / ImplicitCAD

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...
https://implicitcad.org/
GNU Affero General Public License v3.0
1.32k stars 140 forks source link

Fixing relative imports for extopenscad. #487

Closed lepsa closed 4 months ago

lepsa commented 4 months ago

Fix for issue: https://github.com/Haskell-Things/ImplicitCAD/issues/276

When exteopnscad is called with a source filepath outside of the current directory, relative filepaths such as "../config.scad" would fail to read if no such file relative to the programs directory, not the source file, existed.

This change uses the directory of the initial source file as the location for relative file lookups.

Testing

I couldn't find an example of automated tests for handwritten scad files, so I'm putting a test script here.

From the root directory of the project, invoke the following commands. This tests relative paths going up and down the filesystem, along with checking the same directory.

All of these calls should succeed in generating the same shape, cube(1,2,3).

cd into tests/imports and run the following command to check that relative paths from the invoking directory work.

This command should also succeed, producing the same shape.