Skip to content

Make import keyword change working directory during external compilation#325

Open
WoodchuckXL wants to merge 1 commit into
Morpho-lang:devfrom
WoodchuckXL:iss277
Open

Make import keyword change working directory during external compilation#325
WoodchuckXL wants to merge 1 commit into
Morpho-lang:devfrom
WoodchuckXL:iss277

Conversation

@WoodchuckXL

Copy link
Copy Markdown

Fix for #277.
Changes the global CWD to the current file path during compilation of imported files to allow for them to import files with local paths. The CWD is restored after compilation of the imported file is finished.
Added test for this behavior.

@softmattertheory

Copy link
Copy Markdown
Contributor

This is a very useful fix; thanks for the great contribution! Here are a few suggestions to better integrate with existing morpho functionality:

  1. There's a macro MORPHO_DIRSEPARATOR that gives the folder separator that might be better to use than hard coding '/'.

  2. Changing the current directory is platform dependent, so it may be useful to use the existing functions in platform.c to help:

bool platform_setcurrentdirectory(const char *path);
bool platform_getcurrentdirectory(char *buffer, size_t size);

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