Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic implementation of hot-loading/mods #95

Closed
wants to merge 15 commits into from

Conversation

martinrlilja
Copy link
Contributor

@martinrlilja martinrlilja commented Jan 13, 2017

Addresses parts of #93.

What I've done:

  • Implemented package format. Skipped dependencies.
  • Loading of packages from disk.
  • Loading of dylibs, registered from packages.
  • Interfaces for mods to implement in order to be loaded.
  • A tiny proof of concept mod.

How to use:

  1. Run the game with cargo run.
  2. If everything went well, you should see the text my mod was loaded! in the terminal.

What's missing:

  • Only tested on Linux x86_64, and MacOS.
  • Loading of whole directories of mods.
  • Dependencies, and loads of other things.

This is just a first prototype though, but I wanted to put it up to get some feedback before I continue.

@Herbstein
Copy link
Collaborator

I'll test this on a Windows 10 64-bit laptop in the afternoon. Impressive work!

@aeplay
Copy link
Member

aeplay commented Jan 13, 2017

Great work!

FYI: on Mac, everything compiles, but I get this error on startup, which I don't really understand:

dyld: Library not loaded: @rpath/librustc_metadata-b03b26491b91b850.dylib
  Referenced from: /Users/anselm/Dropbox (Personal)/Data/Projekte/cb/rust/target/release/citybound
  Reason: image not found

I can't find this librustc_metadata-b03b26491b91b850.dylib in target/release/deps and don't know where else it could be.

@martinrlilja
Copy link
Contributor Author

martinrlilja commented Jan 13, 2017

@aeickhoff That's weird, could you try to remove extern crate rustc_metadata; from weaver/lib.rs?

Edit: I think that these objects come from ~/.rustup/toolchains/nightly.../lib/. Out of curiosity, what happens if you just import extern crate rustc_driver; and call rustc_driver::main(); somewhere and run that?

return Err(format!("module does not exist {:?}", path));
}
if !path.is_file() {
return Err(format!("module does not a file {:?}", path));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be, "module is not a file ..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fixed 😄

@aeplay
Copy link
Member

aeplay commented Jan 16, 2017

Out of curiosity, what happens if you just import extern crate rustc_driver; and call rustc_driver::main(); somewhere and run that?

Tried that, got the same error as above.

@martinrlilja
Copy link
Contributor Author

@aeickhoff Okay, I'm fairly certain that the error is because the library is not in your path. You should be able to verify it with otool on mac. So, try my latest version, run it with cargo run, it should correctly set the path to your rustup install. Otherwise you might have to set DYLD_LIBRARY_PATH.

@aeplay
Copy link
Member

aeplay commented Jan 16, 2017

By setting DYLD_LIBRARY_PATH to the lib folder in my dustup install, it works indeed! (but crashes when quitting the application)

also, FYI: Mac doesn't recognise the -enable-new-dtags ld option

@martinrlilja
Copy link
Contributor Author

martinrlilja commented Jan 16, 2017

That's great! I think I will make it so that the ld option only runs on *nix.

The crash on exit is a bit worrying, it might be either because of this: https://github.com/citybound/citybound/pull/95/files#diff-98e384c6f9803e1156e01ae31bb92c57R163 or because of this: nagisa/rust_libloading#5

@martinrlilja
Copy link
Contributor Author

martinrlilja commented Jan 30, 2017

@chances Just to make it more obvious that we are talking about the root of everything. Kind of like URLs. We could also make it so that a single forward slash refers to the root of the current source.

It's definitely something we should discuss more to find something that works the best.

@aeplay
Copy link
Member

aeplay commented Jul 2, 2019

Archiving this for now, I'll include you guys in discussion regarding the new mod-from-inside-the-game idea when it's time!

@aeplay aeplay closed this Jul 2, 2019
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.

None yet

4 participants