gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 439be21919579d0e76b1bd9b1175f5ecc6e2b927 parent 0bc85eec3beba0efe394437efdb9ff8b83388f3d Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Mon, 9 Nov 2020 14:22:10 +0300 Merge pull request #67 from bbbbbr/develop_lcc-sflag_compile_to_asm_only Lcc: -S flag as per lcc help output - Compile only; do not assemble or link Diffstat:
| M | gbdk-support/lcc/gb.c | 10 | ++++++++-- |
| M | gbdk-support/lcc/lcc.c | 15 | +++++++++++---- |
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/gbdk-support/lcc/gb.c b/gbdk-support/lcc/gb.c @@ -46,6 +46,7 @@ static struct { { "comopt", "--noinvariant --noinduction" }, { "commodel", "small" }, { "com", "%sdccdir%sdcc" }, + { "comflag", "-c"}, { "comdefault", "-mgbz80 --no-std-crt0 --fsigned-char --use-stdout" }, { "as", "%sdccdir%sdasgb" }, { "ld", "%sdccdir%sdldgb" }, @@ -91,7 +92,7 @@ static CLASS classes[] = { "gb", "%cpp% %cppdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 $2 $3", "%includedefault%", - "%com% %comdefault% -Wa-pog -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 -c $2 -o $3", + "%com% %comdefault% -Wa-pog -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 %comflag% $2 -o $3", "%as% -pog $1 $3 $2", "%ld% -n -i $1 -k %libdir%%port%/ -l %port%.lib " "-k %libdir%%plat%/ -l %plat%.lib $3 %libdir%%plat%/crt0.o $2", @@ -251,7 +252,12 @@ int option(char *arg) { setTokenVal("includedir", tail); return 1; } - else if ((tail = starts_with(arg, "-m"))) { + else if ((tail = starts_with(arg, "-S"))) { + // -S is compile to ASM only + // When composing the compile stage, swap in of -S instead of default -c + setTokenVal("comflag", "-S"); + } + else if ((tail = starts_with(arg, "-m"))) { /* Split it up into a asm/port pair */ char *slash = strchr(tail, '/'); if (slash) { diff --git a/gbdk-support/lcc/lcc.c b/gbdk-support/lcc/lcc.c @@ -175,7 +175,8 @@ int main(int argc, char *argv[]) { error("can't find `%s'", argv[i]); } - if (errcnt == 0 && !Eflag && !Sflag && !cflag && llist[1]) { + // Perform Link stage unless some conditions prevent it + if (errcnt == 0 && !Eflag && !cflag && !Sflag && llist[1]) { if(!outfile) outfile = concat("a", first(suffixes[4])); @@ -542,11 +543,16 @@ static int filename(char *name, char *base) { char *ofile; if ((cflag || Sflag) && outfile) ofile = outfile; - else if (cflag || Sflag) + else if (cflag) ofile = concat(base, first(suffixes[3])); + else if (Sflag) { + // When compiling to asm only, set outfile as .asm + ofile = concat(base, ".asm"); + } else { - ofile = tempname(first(suffixes[3])); + ofile = tempname(first(suffixes[3])); + char* ofileBase = basepath(ofile); rmlist = append(stringf("%s/%s%s", tempdir, ofileBase, ".asm"), rmlist); rmlist = append(stringf("%s/%s%s", tempdir, ofileBase, ".lst"), rmlist); @@ -815,8 +821,9 @@ static void opt(char *arg) { } if (arg[2] == 0) switch (arg[1]) { /* single-character options */ - case 'S': + case 'S': // Requested compile to assembly only Sflag++; + option(arg); // Update composing the compile stage, use of -S instead of -c return; case 'O': fprintf(stderr, "%s: %s ignored\n", progname, arg);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.