04 July 2020, 16:00 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Include file path priorities for assemblers
Let's assume your shell is in the current work directory, called "cwd". When I assemble a source text in "cwd/pathto/source.asm", from where would you expect that an include-file referenced by
include "incfile.i" is taken? From "cwd/incfile.i" or from "cwd/pathto/incfile.i"? Remember, the assembler is called from "cwd" and there is no include-path specified. There was a bug in vasm's last release and I'm trying to do it correctly now. |
04 July 2020, 16:12 | #2 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I would like it to be fetched from both positions : if first one is not found, try the other.
The order does not seem important. |
04 July 2020, 16:13 | #3 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
|
04 July 2020, 16:30 | #4 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Yes, order may be important. That was also the bug in the last release. Then I fixed it by reading from the "compile-directory" only, which means "cwd/pathto" in this case. But today I noticed that I have sources which expect include files in "cwd" to be found.
So there are the following possibilities: 1. Read from cwd/pathto only. 2. Read from cwd only. 3. Read first from cwd/pathto, then from cwd when missing. 4. Read first from cwd, then from cwd/pathto when missing. Of course, there may also be further include paths, specified by -I option or "incdir" directive, which have to be searched before or after the path from above. This is also still undecided. EDIT: Usually I would check some other Amiga assemblers for comparison, but I'm currently on holiday and my selection of assemblers is quite limited... Last edited by phx; 04 July 2020 at 16:32. Reason: Addition |
04 July 2020, 17:14 | #5 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Usually, I use "incdir" directives in PhxAssGUI, and never had that problem yet. But I would prefer to try "pathto/" first and "cwd" only as second.
Btw, is there a rule that "pathto" has to be a subdir or relative to "cwd"? Would an absolute path cause a failure? |
04 July 2020, 17:22 | #6 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Anyway, thinking about it i'd prefer current directory first, then path to the source itself. This way it becomes possible to put default files in source dir, then override them with other files from current dir (you can have as many dirs as you want, each one with a different version). |
|
04 July 2020, 18:46 | #7 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Usually you don't want absolute paths in your source, because you might want to assemble it on a different machine at some point. Quote:
Devpac seems to confirm that. I just found Devpac on an E-UAE file system. Devpac checks cwd/pathto first, then cwd. PhxAss, on the other hand, only looks in cwd. |
||
04 July 2020, 19:41 | #8 | |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Quote:
I think that PhxAssGUI loads my "source.asm" from an absolute project path, but without a ChangeDir (couldn't see that in SnoopDos) and so "CWD" stays in the PhxAss program directory. I must admit, I've never written my own include files, but if I had a file "source.i" at the same location where "source.asm" was loaded from would an "include source.i" try to load it from the project drawer or from the program directory (CWD)? Tested it: PhxAss looks into its program dir (CWD) and the /include subdir and then into INCLUDE:, but never into the project drawer where "source.asm" was loaded from. That's where I would like to see it searching first. Last edited by PeterK; 04 July 2020 at 19:59. |
|
04 July 2020, 20:00 | #9 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
Regarding vasm: I hope I fixed everything for the next release. Here the search priority is now:
|
|||
04 July 2020, 20:11 | #10 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
On the other hand, if you have a mysource.s using myinclude.i and both are in source dir, good luck to try another version of that include without copying files if source dir prevails. Quote:
It does not need to do otherwise. PhxAss has PHXOPTIONS config file which can contain incpath. This does the job nicely. |
||
05 July 2020, 00:45 | #11 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
As you said yourself you will always find situations where one or another order seems better. So the best I can do is to follow the behaviour of other assemblers. And Devpac is often a good choice. |
|
05 July 2020, 14:06 | #12 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
As I understand meynaf's comment, he wants to be able to replace some sort of "sourceproperties.i" of a ported source code, which may depend on the original environment, target system or being compiler specific, by his own local preferences without editing "sourceproperties.i".
That could be a reason to look into "CWD" first, but if there is such an include file coming together with the source, will it still compile correctly if you ignore it silently and use your own substitute? |
05 July 2020, 21:21 | #13 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
True. But you can find these reasons for both variants.
Quote:
Unfortunately there is still no option to define an include path which has higher priority than the CWD or the source-directory. This can be a problem. I just checked Devpac again, and an include path specified with INCDIR on the command line has lower priority, just like in vasm. And also in PhxAss an INCPATH option will not take priority over CWD. So... I won't change that. |
|
05 July 2020, 21:35 | #14 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
I'm sure you will make the right decision, although I'm still not a vasm user.
|
06 July 2020, 08:42 | #15 | ||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
In addition, it is usually a good practice to avoid having files with exact same name in a project. Anyway, if we have a naming conflict we can't resolve, source in the subdir could include subdir/inc.i instead of just inc.i if there is another inc.i in the root dir. Quote:
I'd say that if the two options are valid, the answer is : make it configurable. You already know how to behave in Devpac compatibility mode. Same in Phxass mode, probably. Quote:
Quote:
But there are probably other cases... |
||||
06 July 2020, 11:20 | #16 | |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Quote:
Yes, an option for the priority of the includes could be a solution. |
|
06 July 2020, 11:54 | #17 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
But Vasm does not have INCPATH so the choice of priorities is perhaps more important for it - having it as an option would address all cases. |
|
06 July 2020, 21:30 | #18 | |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
Quote:
It gets more confusing when including a file within a file because then the nested included file only looks in the first include local folder. For example I included your pro tracker player from another file in a different folder and it couldn’t find the custom.i include. I think my assumptions are this way due to working in C in visual studio where it works like this. But of course it could just be that that environment is changing shell folder before compiling each file. |
|
07 July 2020, 13:28 | #19 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
The only difference between PhxAss and vasm is PhxAss' inability to search for include files relative to the source directory, when it doesn't match CWD. Quote:
Quote:
Quote:
Quote:
|
|||||
07 July 2020, 15:01 | #20 | ||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Quote:
In most cases work dir and source dir are the same. I don't have a single project that needs to specify a subdir in the command. I could, however, have some sources included in main one, that are in a subdir. Quote:
INCPATHtaken from ENV:PhxAss/PHXOPTIONS. Quote:
phxass source.s, work done. Or i just double-click the .s and type phxassbefore it... Makefiles are for C. I have written many small tools (50+) that are single source over the years (for decode, extract, test, things like that) ; a makefile for each would be overkill. Quote:
Quote:
include somedir/othersource.sand that this second source includes something, the asm won't look in this second file's dir ? And now the situation becomes more complicated because you can have a whole tree of directories : a.s includes b/c.s, c.s includes d/e.s, and e.s includes f.s so where could f.s possibly fetch its files ? Could be current dir (command line), dir of a.s, b/ (dir of c.s), b/d/ (dir of e.s), etc. It looks to me as if considering the source's dir is like opening a can of worms... |
||||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
C Include file with hardware registers | sparhawk | Coders. General | 4 | 20 November 2019 20:59 |
Picasso iV ROM file path | PeterK | support.WinUAE | 11 | 01 April 2018 02:00 |
Use file requester to specify path in Shell? | Foebane | support.Apps | 5 | 01 January 2017 15:32 |
Macro68k compatible cross assemblers | kamelito | Coders. Asm / Hardware | 3 | 28 October 2015 10:38 |
NDK 3.1 Include file problem. | Thorham | Coders. General | 4 | 04 February 2011 20:58 |
|
|