rm8 icon indicating copy to clipboard operation
rm8 copied to clipboard

More CI builds

Open konsumer opened this issue 3 years ago • 2 comments

It would be handy to have a few Github action automatic release-builds for linux/arm (for use on pi and anbernic devices) and mac/win. It has so few system-deps (sdl2 is the only one one) it would make it very easy to install on just about everything (maybe just tell users to install SDL2.)

I'd be happy to PR for it. Generally, I set this up to happen on tag (I like semver, like v*.*.*) so to make a release you just tag & push. Alternately, non-tag/releases work too, if you set the "asset output" for the build, but it's a bit less convenient, since you have to dig through the builds to find the release.

I don't have a great deal of experience with rust cross-building, but I have a few C-based projects that do this kid of thing, and can try to figure it out. It seems much simpler with rust.

What targets should I set it up for? I am thinking these would be most useful:

  • linux arm32
  • linux arm64
  • linux amd64
  • windows amd64
  • mac amd64
  • mac arm64

For mac, normally I would suggest a "universal build" since it has good built-in support for "fat binaries", but I will need to research how to do it, a bit. Using cmake with C, I can do this on github action with a few env-vars, but I think it is different in rust. I found this which might be helpful. Basically, it seems like you build the 2 binaries separately, then use lipo to merge them into a fat-binary. Maybe a first step could be the basic targets that can be built with just cargo, then I can work on trying to get a universal binary.

konsumer avatar Dec 25 '22 21:12 konsumer

I got the first phase done I think, which builds windows, linux & mac amd64 targets.

I still need to figure out some things to make cross-builds work, but this is a start.

  • mac sdl2 is not installed for cross-build
  • linux sdl2 is not installed for cross-build

Here is what's working:

  • mac amd64
  • linux amd64
  • windows (amd64) - for this you will need to include SDL2.dll (which is in root of project, at build-time)

I have a Mac M1, so I could build for mac arm64 and linux amd64/arm64 (using docker) manually and attach it to the release, but really I'd prefer to automate all the builds, so I will keep playing with it. If nothing else, I could probly cross-build in docker on github-actions or something.

So next phase is maybe to create release for these or to get the cross-building stuff working.

konsumer avatar Dec 25 '22 23:12 konsumer

Ok, I have basic CI native build & release working Here is an example-release (in "Releases" tab.)

Files look like this:

├── rm8-linux-x86_64
│   ├── README.md
│   ├── rm8
│   ├── rm8-dvorak.json
│   ├── rm8-qwerty.json
│   └── rm8.json
├── rm8-mac-x86_64
│   ├── README.md
│   ├── rm8
│   ├── rm8-dvorak.json
│   ├── rm8-qwerty.json
│   └── rm8.json
└── rm8-windows-x86_64
    ├── README.md
    ├── SDL2.dll
    ├── rm8-dvorak.json
    ├── rm8-qwerty.json
    ├── rm8.exe
    └── rm8.json

This is similar to what we do at node-raylib but I did some cross-building in docker there, which I think I can do here, once I get the other stuff building right.

I tested the Mac x86_64 build on an M1, and it actually seems to run (via built-in x86-64 emulation) but I get this which I think means I need some other way (not brew) to install SDL2 on M1:

dyld[84977]: Library not loaded: /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib
  Referenced from: <18BCEEE3-08DA-353B-9921-947496913465> /Users/konsumer/Downloads/rm8-mac-x86_64/rm8
  Reason: tried: '/Users/konsumer/VulkanSDK/1.3.216.0/macOS//lib/libSDL2-2.0.0.dylib' (no such file), '/libSDL2-2.0.0.dylib' (no such file), '/usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/local/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/lib/libSDL2-2.0.0.dylib' (no such file, not in dyld cache)
[1]    84977 abort      ./rm8

So, we get some automated releases (windows, mac amd64, linux amd64) and we might be close to mac arm64.

Also, looks like we can bundle SDL2 on mac, like this.

We could maybe also bind to framework and tell mac users to install that, but I am not sure how to automate installing the framework in CI.

I wish there was a simpler way to get SDL2 on all these targets with only cargo.

konsumer avatar Dec 26 '22 02:12 konsumer