How should I create a library

So I am making a game editor and this software interacts with the game engine, So the game editor can create rust projects for you. Currently I am copying the code from the game editor to a project that uses the game engine in order to load up the saved contents from the game editor while you compile from the project.

I know there is a better way to "write once and run everywhere" which is to write a library to do this, So I was wondering where should this library be created? Should I copy the entire library during compile time and during runtime store it under ~/.config/game_editor/ and then that way the individual project can just look for ~/.config/game_editor/ to get hte structures, the functions etc?

Does the library stay the same, even as the game is edited, or does it contain dynamically generated Rust code that depends on what editing you do in the editor?

Well the library shouldn't be modified by the user.

Currently I am copying some *.rs files and modifying a little based on where hte project is and then rewriting it back to the project directory.

So would it be possible to create this library and push it to, and then just have it added to the project's dependencies?

Or does the library get generated differently based on the data in the editor?

1 Like

If you do end up copying the library please use the XDG Base Directory Specification. In this case that would mean using the XDG_DATA_HOME environment variable and falling back on $HOME/.local/share, as opposed to dropping it in .config.

Eventually the game editor itself would be pushed to so are you saying that I should have a separate library to, maybe as an extension?

Currently there is no library, it puts some of the files into its own binary and during runtime if creating a new project, it would copy those files to the project's dir.

Interesting mate, should I copy the entire library crate project folder to that specific directory or should i just copy the lib file(s) over?

Edit: Should I even consider having a lib crate or should I just have extra *.rs files and copy them over for the project as well?

Eventually I plan to make it compatible with Windows as well so does Windows have an equivilent directory? If not I could possible make that directory anyways?

I can't really say definitively what to put in $XDG_DATA_HOME/game_editor/, or whether copying files around like that is the right option. The XDG dirs might just be something to remember for next time.

Windows does indeed have an equivalent directory, its %LOCALAPPDATA%. This post has most of the commonly accepted equivalents between windows and XDG dirs.

But in my case, should create a lib crate project inside that directory, or should I have some *.rs files that gets shared between the game editor and any project that is using the game engine?

Ok thanks mate :slight_smile:

The directories crate makes it easy to get standardized directories for different things.

What I mean is does the *.rs file that gets shared between the game edit and any project get changed while you are editing the game scene?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.