conker64/libdragon

Add build scripts for MIPS toolchain

Closed this issue · 17 comments

The build scripts should be able to build a complete toolchain for different hosts (Cygwin, mingw32, Linux, Mac OS X, etc..).

Building make(1) for Windows, coupled with the MIPS toolchain won't be enough, especially if the Makefiles are to be revamped. More complex/robust Makefiles may require a Unix shell (sh) as well as awk and other tools. This would mean that Windows users have to rely on Mingw32 or Cygwin.

The important bit is that providing prebuilt toolchain for Windows and other hosts is not a problem, however they all have to supply the rest (sh, awk, etc.) in order to build libdragon (later down the line when I revamp the Makefiles).

@fraser125 What's your take on this?

Minimum requirement for compiling libdragon: Win10 with Linux subsystem w/ Ubuntu is fine with me.

I would really like to avoid this dependency for compiling ROM's on Windows. It's another "barrier to entry".
Maybe I can do a Windows specific implementation of the desired functionality. Whether it's a batch file or stub program.

That's fine with me. I can implement/maintain the non-Windows Makefiles. I'm unfamiliar with writing Windows specific Makefiles, but I've seen projects that have: Makefile.W32 files. I think that's a good approach. What about Visual Studio project files? There is msbuild.

I'm not 100% sure on a batch file, unless it's the de facto way to go about compiling on Windows. Could you clarify on what the stub program is?

Then I'll keep going and have Windows toolchain build include make(1).

Cygwin and mingw32 should be nearly the same as new Subsystem stuff. Honestly they should all have any extra programs you want to include in the build scripts for libdragon.

Absolutely include make in the build tools and use what ever other programs you feel are appropriate. I'll test and see if anything doesn't work, then make sure I understand your intentions and create any Windows specific pieces.

Most simple shell scripts can be recreated using a batch file, more advanced ones may require PowerShell. Those type of things will be my responsibility.

I really expect 90%+ of your build scripts to run identical on Windows.
I want to avoid little programs like gbafix and n64tool if we/I can figure out how to do it in the linker. (ideally no stub programs)

Got it. The goal would be to have the Makefiles be portable, that is, use only what is known to available across all platforms by default (sh, awk, sed, find, etc.).

I'll keep in mind in order to make things easier.

not sure if you guys are aware but I have implemented a similar build system for my fork of Alt64 (os for everdrive). maybe it could be of help... https://github.com/networkfusion/altra64

Build Tools request, is it easy to add xxd or similar to convert binary files to C array's?
Any thoughts?

Thanks @networkfusion, I'll take a look.

@fraser125, from a portable standpoint, xxd is part of Vim, so not all distributions have it. I think the go to is to write a quick bin2c tool. Is that what you're asking?

It can certainly be done using standard (portable) Unix tools.

Here it is. I'll clean it up a bit more, but it's possible to do it.

#!/bin/sh

prefix="test"
w=8
file="${HOME}/path/to/file"
size=`stat -c %s "${file}"`

cat "${file}" | od -An -vtx1 | sed -E 's/^\s+//g;s/[ \n]/\n/g' | awk '
FNR == 1 {
  print "#include <stdint.h>";
  print "";
  print "const size_t '"${prefix}"'_size = '"${size}"';";
  print "";
  print "const uint8_t '"${prefix}"'_data['"${prefix}"'_size] = {";

  w = '"${w}"';
  n = 0;
  b = 1; # Blank
  do {
    p = "0x" toupper($0);
    c = getline;
    if (c == 1) {
       if ((n % w) == 0) printf "        ";
       if ((n % w) != 0) printf " ";
       printf p ",";
       b = 0;
    } else {
       print ((b == 0) ? " " : "        ") p;
       break;
    }
    if (((n + 1) % w) == 0) {
       print "";
       b = 1;
    }
    n++;
  } while (c == 1);

  print "};";
}'

@fraser125 I have built the toolchain if you want to try it out on your Windows machine. Here is a tarball of it.

Just wondered if it is worth you setting up a travis CI job for building the toolchain which would save time for many and be ready out the box for different environments... Also, is there any value in using CMake for libdragon as it would improve cross platform compatibility and from experience, if used with Ninja can seriously improve compilation speed?!

also, why is c++ not included as a supported language (e.g. creation of mips64-elf-g++ does not occur)

I believe that I disabled it for now.

As for some kind of CI, a one time buikd should be enough.

@conker64 @fraser Have the build scripts been deprecated? Is the one from n64chain being used? If so, I'll close the bug.

The Build scripts for n64chain seem to meet most needs and have been updated approx 3 months ago in the following repositories Github and Cen64 with binary downloads available on Cen64 Homepage I think this can be closed.