induktio / thinker

Improved game engine features for SMACX.
https://discord.gg/XdFuwWzzku
GNU General Public License v2.0
75 stars 11 forks source link

Makefiles for cross-compiling from linux #26

Closed hartmark closed 2 years ago

hartmark commented 2 years ago

I'm on arch linux and have created two Makefiles, one for the dll and one for the exe.

I used this tool: https://github.com/dmpas/cbp2make.git

And ran this command:

cbp2make -in thinker.cbp -out Makefile_dll
cbp2make -in thinkerlaunch.cbp -out Makefile_exe

Then I applied these fixes to the Makefiles:

Then to build just run:

make -j`nproc` -f Makefile_dll
make -j`nproc` -f Makefile_exe
induktio commented 2 years ago

Hmm, there's the issue that I'm currently officially only supporting CodeBlocks build configuration. So if I add those files in the repo, they might become stale when the files get shuffled around. Then we might get bug reports about breakage etc.

If those files got (almost) entirely produced by cbp2make tool, then a better approach might be to put a tutorial for those build commands for Makefiles in Technical.md along with cbp2make's link. It should be relatively easy to install that tool?

hartmark commented 2 years ago

Yeah, that would work. I can make a script that applies a patch of the manual changes I did.

induktio commented 2 years ago

Depending on which one is simpler, it could be some installer script in tools and/or instructions in Technical.md. The main point would be that it won't break after some settings in the CodeBlocks file get changed.

pianoslum commented 2 years ago

Couldn't CMake generate both?

hartmark commented 2 years ago

Couldn't CMake generate both? I have only consumed cmake projects so I have no idea how to do that properly. Quick googling showed that it's quite easy generating the code:blocks project files if the CMake is in place. https://stackoverflow.com/questions/37618040/how-to-create-a-codeblocks-project-from-the-cmake-file

hartmark commented 2 years ago

I have pushed a updated version now where the Makefiles is generated and patched and then compiled.

I have no access to any windows machine but I guess you could try it out yourself, I don't know what the binaries are named though so you might need to adjust this line in the patch-files: ++COMPILER_PREFIX = i686-w64-mingw32-

I guess having mingw-tooling installed gives you patch and make, but you need to build cbp2make yourself, on linux I had all needed prerequisites so I just had to do "make" and it got compiled. On Windows however your mileage may vary.

induktio commented 2 years ago

It seems to compile after you install the expected dependencies first. On Debian it is apt install build-essential g++-mingw-w64. The makefile seems to build all possible options by default, unless you provide the version, debug/release etc. There might be some minor differences, at least the launcher program is missing the icon, so maybe something was missing from build script.

Overall build tools tend to be fragile, so even with this there's a chance the build might break after new changes to code. I'm not sure how maintained cbp2make is. It would be preferable if the tool understood how to import all of these changes to the Makefile. So there's something to think about. You should at least push that commit to your forked repo so it's more easily visible.

Are you running the game on Wine currently? I suppose then the new launcher program works correctly also there?

hartmark commented 2 years ago

I didn't want to add the cbp2make binary in my branch as I think it's best if the required to is compiled on the host instead so it won't have any unresolvable symbols on other systems. The tool haven't had any active development since 2018 so it seems a bit abandoned. It still does the job though. I don't think you need to worry so much about it breaking as code:blocks haven't had any release since march 2020.

I did notice the icon is missing as I'm just calling it from command line, do code blocks embed it into the exe?

Yes, I'm running the game using wine and haven't had any issues.

induktio commented 2 years ago

Yeah definitely no binary blobs in the repo if possible. At one point I was thinking if I should maintain the makefile manually, but then looked at the autogenerated code again, and... nope.

I did some minor adjustments on the script so it worked better on my system. I think the icon is copied on the binary by windres utility but not sure really how it's configured to work with the makefile.