cargo-n64 icon indicating copy to clipboard operation
cargo-n64 copied to clipboard

Save target.json and linker script to target directory

Open parasyte opened this issue 6 years ago • 5 comments

The target.json and linker script files are currently written to a temporary directory. These should be written to the target directory instead. It should use a sub-directory like ./target/cargo-n64 to keep the target directory clean. The directory tree will have to be created if it does not exist.

parasyte avatar Jun 23 '19 16:06 parasyte

In the gba crate we keep the target description json in the project root so that it's more visible to others that are just browsing the code. You might want to do that here too. Then you can copy it to wherever during the build or alter the command line argument appropriately.

Lokathor avatar Jun 23 '19 17:06 Lokathor

I wasn't happy with duplicating these build files in each bin crate. And there's a dependency issue with the runtime rrt0 requiring specific symbols defined by the linker script.

The best case is that these are built into the compiler, but I'm no where near ready to support that kind of effort. So I ended up with this cargo wrapper to manage compiling, linking, and the minimal runtime.

You can see from other tickets that rls needs paths to at least the sysroot and target.json so I guess cargo-n64 will handle that, too. 🤷‍♀

parasyte avatar Jun 23 '19 17:06 parasyte

you can still have the build.rs copy the data to the OUT_DIR, and then place an environment value in the build for where other crates can find that file.

This is all necessary because, by the rules of build.rs files, a build.rs that writes to anywhere in the project directory other than the OUT_DIR is a "failed" build when checking for a build pass during a cargo publish.

Lokathor avatar Jun 23 '19 17:06 Lokathor

I'm not planning to require a build.rs for the various bin crates (e.g. N64 games). For the same reason I don't want to require copying the target.json and linker script around.

... Unless you had another idea with build.rs that I don't quite grasp.

parasyte avatar Jun 23 '19 18:06 parasyte

Now that I've come back to this, it probably does make sense to include a "common" build script somewhere. I'm still not convinced that it should be copy-pasta into every N64 Rust project, but for sure in some common dependency. And it will dramatically improve many of the difficulties that we have now with building N64 ROMs. Things like, running an RSP assembler to build microcode, or build-time asset format conversions, etc.

parasyte avatar Oct 27 '19 19:10 parasyte