vhelin / wla-dx

WLA DX - Yet Another GB-Z80/Z80/Z80N/6502/65C02/65CE02/65816/68000/6800/6801/6809/8008/8080/HUC6280/SPC-700/SuperFX Multi Platform Cross Assembler Package
Other
549 stars 98 forks source link

Add ability to use environment-variables for file-includes #60

Closed bazz1tv closed 3 years ago

bazz1tv commented 9 years ago

'nuff said... For now I just write my projects in a way that I can get around this desire.. ie from a central Makefile and every file is referenced from the directory the makefile is in.

But making projects with many object files and a central Makefile is sometimes a hard habit for me to get in when starting a new project -- it's during these times I wish I could use an environment variable to escape directory dependency...

Anyways -- this flip-flop attitude I have makes me wonder if this feature should even be added (worth the effort to add?) Let's talk about it ---> For one, environment variables are used differently whether on Windows and *nix -- but let's say WLA DX suddenly had the ability to handle environment variables -- do we have a way as App Developer to check the host OS so that we can conditionally include files in a platform independent manner?

Food for thought...

Extra thought -- What platform independent manner can we include files to begin with using WLA DX (I remember learning this but I've since forgotten :X)

cr1901 commented 9 years ago

WLA requires a hosted ANSI C compiler, and any conforming C compiler will provide a getenv() that will either retrieve environment variables or return a NULL ptr IIRC. So platforms that support getenv() meaningfully get support.

Extra thought -- What platform independent manner can we include files to begin with using WLA DX > (I remember learning this but I've since forgotten :X)

You can't. C makes no guarantees re: the format of paths that fopen and friends accept. I don't personally care for the .INCDIR directive and would much rather see them moved to the command line as parameters, similar to POSIX (and NOT an environment variable either). But that would require rewriting the command line parsing. And if we want to get really pedantic, hosted C compilers are not required to meaningfully support argc/argv[] :P.

Let's worry about the bugs first before we start adding new features.

vhelin commented 9 years ago

pass_1.c hosts a function as follows:

int localize_path(char *path) {

int i;

if (path == NULL) return FAILED;

for (i = 0; path[i] != 0; i++) {

if defined(AMIGA) || defined(UNIX)

/\* '\' -> '/' _/
if (path[i] == '\')
  path[i] = '/';

else

/_ '/' -> '\' */
if (path[i] == '/')
  path[i] = '\';

endif

}

return SUCCEEDED; }

... and that is used with all the file include/incbin functions. So you can write the paths using ///'s or \'s, WLA will convert the path to the working format. Is this what you wanted?

bazz1tv commented 9 years ago

Since this was a 2-part question, yes ville you answered the second part, whereas part I, which focuses on environment variables, is left non-conclusive until we finish bug-fixing, as per recommendation of cr1901.

ghost commented 9 years ago

I think a better way of doing this is making WLA accept a root include/library directory through the command line. This way we can specify root files with and local files with "myfile.h" just like in ANSI C. If you guys approve of this idea, i'll see if I can add it to wla myself sometime :) Example:

==> Makefile <== AS = wla-65816 ASFLAGS = -o -d "../../include" LD = wlalink LDFLAGS = -vS -d "../../lib"

==> Main.s <== .INCLUDE "myfile.h" ; searches current working directory .INCLUDE ; searches directory specified in the command line ("../../include")

==> Linkfile <== [libraries] bank 0 slot 1 "speed.lib" ; searches current working directory bank 4 slot 2 ; searches "../../lib" as specified with parameter -d

EDIT: corrected syntax.

vhelin commented 9 years ago

A bit off topic:

Sorry guys, I have your (also latest) emails about WLA DX, but currently I'm busy with other things, and trying to get my life back on the track, and very exhausted. But I'll check these later...

On Tue, Nov 17, 2015 at 5:01 PM, galaxyhaxz notifications@github.com wrote:

I think a better way of doing this is making WLA accept a root include/library directory through the command line. This way we can specify root files with and local files with "myfile" just like in ANSI C. If you guys approve of this idea, i'll see if I can add it to wla myself sometime :) Example:

==> Makefile <== AS = wla-65816 ASFLAGS = -o -d "../../include" LD = wlalink LDFLAGS = -vS -d "../../lib"

==> Main.s <== .INCLUDE "myfile.h" ; searches current working directory .INCLUDE ; searches directory specified in the command line ("../../include")

==> Linkfile <== [libraries] bank 0 slot 1 "speed.lib" ; searches current working directory bank 4 slot 2 ; searches "../../lib" as specified with parameter -d

— Reply to this email directly or view it on GitHub https://github.com/vhelin/wla-dx/issues/60#issuecomment-157394703.