[z88dk-dev] z80asm include search path

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] z80asm include search path

Post by alvin »

An issue was brought up in the forums about how z80asm locates included files:

http://www.z88dk.org/forum/viewtopic.ph ... 071#p14071

In an asm file with an include like this one:

FILE: main.asm

Code: Select all

include "myfile.asm"

main:

ld hl,100
ret
the file "myfile.asm" is sought relative to z80asm's include paths which might include the current working directory and the target's base directory in any compile.

The question is should z80asm also be searching for "myfile.asm" in a directory relative to where the asm file is located? So in this case, should z80asm also be looking for "myfile.asm" in the same directory where "main.asm" is sitting?



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
pscust
Well known member
Posts: 194
Joined: Thu Jun 23, 2011 3:34 pm

Post by pscust »

The current search path is:
- directory from where z80asm was called
- directory pointed by the Z80_OZFILES environment variable
- list of -I directories, relative to the directory from where z80asm was
called

Does Z80_OZFILES still make sense?

Adding the directory of the asm file being assembled is easy, but in my
opinion is confusing.

For example:
z80asm -Iinc libsrc/main.asm

In the current implementation, myfile.asm is searched in ./myfile.asm and
./inc/myfile.asm

In the requested change, should it search all of ./myfile.asm,
./inc/myfile.asm, libsrc/myfile.asm, libsrc/inc/myfile.asm? In which order?


On Sun, Jul 3, 2016 at 9:56 PM, alvin (alvin_albrecht@...) <
lists@...> wrote:
An issue was brought up in the forums about how z80asm locates included
files:

http://www.z88dk.org/forum/viewtopic.ph ... 071#p14071

In an asm file with an include like this one:

FILE: main.asm

Code: Select all

include "myfile.asm"

main:

ld hl,100
ret
the file "myfile.asm" is sought relative to z80asm's include paths which
might include the current working directory and the target's base directory
in any compile.

The question is should z80asm also be searching for "myfile.asm" in a
directory relative to where the asm file is located? So in this case,
should z80asm also be looking for "myfile.asm" in the same directory where
"main.asm" is sitting?




------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

On Mon, 4 Jul 2016, Paulo Custodio wrote:
The current search path is:
- directory from where z80asm was called
- directory pointed by the Z80_OZFILES environment variable
- list of -I directories, relative to the directory from where z80asm was
called

Does Z80_OZFILES still make sense?
Not really, I've removed it from the documentation - using an explicit
include directory is much clearer. So I'm happy for that to be removed.

I'd prefer for the include path not to be changed to include the directory
of the asm file being assembled - getting that behaviour with z80asm at
present is easy (add an include directory).



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
pscust
Well known member
Posts: 194
Joined: Thu Jun 23, 2011 3:34 pm

Post by pscust »

OK. I'll remove Z80_OZFILES search from the include search path and will
not insert the directory of the asm file being assembled.

The other environment variable used by z80asm is Z80_STDLIB, which may be
defined as a default library to make (-x) or use (-i) if the corresponding
command line option has no file argument.

I would prefer to remove this dependency and force the library name to be
supplied with -x and -i. Any comments?


On Wed, Jul 6, 2016 at 2:43 PM, Dom Morris <dom@...> wrote:
On Mon, 4 Jul 2016, Paulo Custodio wrote:
The current search path is:
- directory from where z80asm was called
- directory pointed by the Z80_OZFILES environment variable
- list of -I directories, relative to the directory from where z80asm was
called

Does Z80_OZFILES still make sense?
Not really, I've removed it from the documentation - using an explicit
include directory is much clearer. So I'm happy for that to be removed.

I'd prefer for the include path not to be changed to include the directory
of the asm file being assembled - getting that behaviour with z80asm at
present is easy (add an include directory).




------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

The other environment variable used by z80asm is Z80_STDLIB, which may be
defined as a default library to make (-x) or use (-i) if the corresponding
command line option has no file argument.

I would prefer to remove this dependency and force the library name to be
supplied with -x and -i. Any comments?
I think it should probably be removed as well but the classic compile is currently depending on this behaviour. The cfg files would have to be changed to add the correct paths to the "CLIB default" settings. The new c lib already does this to redirect the search path to the new includes and libraries.



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

On Wed, 6 Jul 2016, alvin (alvin_albrecht@...) wrote:
The other environment variable used by z80asm is Z80_STDLIB, which may be
defined as a default library to make (-x) or use (-i) if the corresponding
command line option has no file argument.

I would prefer to remove this dependency and force the library name to be
supplied with -x and -i. Any comments?
I think it should probably be removed as well but the classic compile is
currently depending on this behaviour. The cfg files would have to be
changed to add the correct paths to the "CLIB default" settings. The
new c lib already does this to redirect the search path to the new
includes and libraries.
Z80_STDLIB isn't used by anything. zcc already adds on explicit search
paths for librariues.




------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I'd prefer for the include path not to be changed to include the directory
of the asm file being assembled - getting that behaviour with z80asm at
present is easy (add an include directory).
It's not quite the same thing.

For example, if you provide source code and someone copies it to his own machine, the person doing the copying will have to manually add include paths for the source to assemble. You could say that the person can assemble from the copied code's root directory if the copied code uses includes rooted at its root dir only but then if the copied code gets placed in some subdir of a larger tree, that subdir still has to be manually added to the include path by the person doing the copying. If many source packages are copied, there could be a lot of additional include paths that have to be manually specified.

For the person that came up with the issue, I think it has to do with how source code organization is envisioned. The way it is now is similar to how C organizes is its includes with <> used to indicate a search path from the standard include dir and "" used to indicate a search path from the current working dir. This (and z80asm's emulations of this) works well for the c library and its implementation. However the user may very well have a different view of source code organization where he expects a source file's includes to be relative to the dir the source file is located in. It's not always a simple matter to add a new include path to search a new dir to solve this as the user's source files may be distributed in a tree with desired include paths relative to source file placement such that one would have to add a whole bunch of include paths to make sure all the source directories were searched. IYSWIM :)



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
pscust
Well known member
Posts: 194
Joined: Thu Jun 23, 2011 3:34 pm

Post by pscust »

I've settled to add the directory of each asm file to the end of the
include path temporarily during its compilation.

Please let me know if this solves the issue.


On Wed, Jul 6, 2016 at 5:47 PM, alvin (alvin_albrecht@...) <
lists@...> wrote:
I'd prefer for the include path not to be changed to include the directory
of the asm file being assembled - getting that behaviour with z80asm at
present is easy (add an include directory).
It's not quite the same thing.

For example, if you provide source code and someone copies it to his own
machine, the person doing the copying will have to manually add include
paths for the source to assemble. You could say that the person can
assemble from the copied code's root directory if the copied code uses
includes rooted at its root dir only but then if the copied code gets
placed in some subdir of a larger tree, that subdir still has to be
manually added to the include path by the person doing the copying. If
many source packages are copied, there could be a lot of additional include
paths that have to be manually specified.

For the person that came up with the issue, I think it has to do with how
source code organization is envisioned. The way it is now is similar to
how C organizes is its includes with <> used to indicate a search path from
the standard include dir and "" used to indicate a search path from the
current working dir. This (and z80asm's emulations of this) works well for
the c library and its implementation. However the user may very well have
a different view of source code organization where he expects a source
file's includes to be relative to the dir the source file is located in.
It's not always a simple matter to add a new include path to search a new
dir to solve this as the user's source files may be distributed in a tree
with desired include paths relative to source file placement such that one
would have to add a whole bunch of include paths to make sure all the
source directories were searched. IYSWIM :)




------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
pscust
Well known member
Posts: 194
Joined: Thu Jun 23, 2011 3:34 pm

Post by pscust »

I've settled to add the directory of each asm file to the end of the
include path temporarily during its compilation.

Please let me know if this solves the issue.


On Wed, Jul 6, 2016 at 5:47 PM, alvin (alvin_albrecht@...) <
lists@...> wrote:
I'd prefer for the include path not to be changed to include the directory
of the asm file being assembled - getting that behaviour with z80asm at
present is easy (add an include directory).
It's not quite the same thing.

For example, if you provide source code and someone copies it to his own
machine, the person doing the copying will have to manually add include
paths for the source to assemble. You could say that the person can
assemble from the copied code's root directory if the copied code uses
includes rooted at its root dir only but then if the copied code gets
placed in some subdir of a larger tree, that subdir still has to be
manually added to the include path by the person doing the copying. If
many source packages are copied, there could be a lot of additional include
paths that have to be manually specified.

For the person that came up with the issue, I think it has to do with how
source code organization is envisioned. The way it is now is similar to
how C organizes is its includes with <> used to indicate a search path from
the standard include dir and "" used to indicate a search path from the
current working dir. This (and z80asm's emulations of this) works well for
the c library and its implementation. However the user may very well have
a different view of source code organization where he expects a source
file's includes to be relative to the dir the source file is located in.
It's not always a simple matter to add a new include path to search a new
dir to solve this as the user's source files may be distributed in a tree
with desired include paths relative to source file placement such that one
would have to add a whole bunch of include paths to make sure all the
source directories were searched. IYSWIM :)




------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
Post Reply