English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 22 July 2022, 11:40   #1
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Compile directory, work directory and relative paths

In the past I made multiple changes in vasm concerning locating files via compile- and work-directory. Still I have the impression that it's not quite right.

I think we agree on the following definition:
  • Work directory: The system's (usually the shell's) current work directory, when starting the assembler. Not the directory where the assembler binary is located.
  • Compile directory: The directory where the main input source is located.
When using relative paths to include files, would you expect that path to be appended to the work directory first, then to the compile directory, if it didn't exist? Or the other way around?
phx is offline  
Old 22 July 2022, 16:56   #2
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
GCC's (implementation defined) way of handling quoted include paths matches my (perhaps learned) intuition.
I.e. if the work directory is "PROJECT:", I run "vasm -Iinc src/foo/bar.S" and "bar.S" includes "lib/lib.i", I would expect it to try PROJECT:src/foo/lib/lib.i first, then PROJECT:inc/lib/lib.i, and give up if neither file exist.
That's without considering anything else though. If say VBCC's preprocessor or a prominent legacy assembler does something noticeably different then that should certainly be considered.
paraj is offline  
Old 23 July 2022, 05:17   #3
Auscoder
Registered User
 
Join Date: Jan 2019
Location: Brisbane
Posts: 99
I would prefer compile then work directory, nothing else considered ??
Auscoder is offline  
Old 23 July 2022, 09:12   #4
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
I would also prefer compile directory first.
alkis is offline  
Old 23 July 2022, 12:29   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Thanks for the input!

It's interesting that most suggest compile-dir first, and paraj even wants to ignore the work-dir. For a comparison I just checked Devpac, BAsm and PhxAss, and all of them ignore the compile-dir!

Seems that the concept of a compile directory doesn't exist for assemblers (68k-assemblers, Amiga-assemblers)? Although my personal preference would also be to use the compile-dir with high priority.

Quote:
Originally Posted by paraj View Post
GCC's (implementation defined) way of handling quoted include paths matches my (perhaps learned) intuition.
Indeed, most likely I had the usual compiler behaviour in mind, when implementing compile-dir paths. But does it make sense for an assembler?

Quote:
I.e. if the work directory is "PROJECT:", I run "vasm -Iinc src/foo/bar.S" and "bar.S" includes "lib/lib.i", I would expect it to try PROJECT:src/foo/lib/lib.i first, then PROJECT:inc/lib/lib.i, and give up if neither file exist.
Hmm. So PROJECT:lib/lib.i would be ignored. Could make sense, when the main source is not located in the work directory. But I'm not sure.

Quote:
That's without considering anything else though. If say VBCC's preprocessor or a prominent legacy assembler does something noticeably different then that should certainly be considered.
Again, compilers have nothing to do with it. Important is only what you would expect from an assembler.

The most prominent legacy assembler would be Devpac, and it ignores the compile-dir. But as most of us (including myself) like compile-dirs, it may be a compromise to search the work-dir first, to avoid bad surprises with legacy source texts?

Anyway, currently vasm's search strategy seems broken, because it locates a file without a path in the compile-dir first, but looks for relative include-paths in the work-dir first...
phx is offline  
Old 23 July 2022, 13:01   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
Let's say you have file foo.s including bar.i and now you want to create a temporary copy of bar.i to perform some tests.
So you put that copy somewhere, assemble your source from this new place (= new work-dir)... and discover your changes are ignored because compile-dir, which contains original version, is used first. Argh.
It's not hard to fix - just rename the original file or duplicate the whole tree - but nevertheless.

As current 68k assemblers seem to ignore compile-dir and because of the above example, i'd choose work-dir first.
meynaf is offline  
Old 23 July 2022, 13:07   #7
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Well, in c/c++ you can include as "" or <>, giving you a choice (and on top of that you can use -I on cmd line).
In asms, the ones I've been using more or less for the last 30 years (from seka to asm-one derivatives), base dir is the source dir (or an optionally configurable dir), and if you want to look elsewhere you can use INCDIR.
Now on the other hand, devpac style asms (non-interactive)... They could benefit from a -I parameter, so you could keep your sources independent that way.
And finally, when it comes to conflicts I'd prefer source dir first so I could overrider whichever file is or potentially could cause problems.
a/b is offline  
Old 23 July 2022, 13:09   #8
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Quote:
Originally Posted by meynaf View Post
So you put that copy somewhere, assemble your source from this new place (= new work-dir)... and discover your changes are ignored because compile-dir, which contains original version, is used first. Argh.
Yep...
a/b is offline  
Old 23 July 2022, 14:52   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
I tend to agree with Meynaf, and work-dir-first could solve most of the problems and keeps compatibility, while still finding files in the compile-dir with lower priority.

Although a current work directory, which accidently has the same include file name as in your compile directory, may also be the reason for puzzling bugs.

Quote:
Originally Posted by a/b View Post
And finally, when it comes to conflicts I'd prefer source dir first so I could overrider whichever file is or potentially could cause problems.
With "source dir first" you mean compile directory?

Another question would be if relative include paths should actually be searched in the compile-dir at all, or just in the work-dir. Now I think this is also what paraj wanted to indicate in his example.
phx is offline  
Old 23 July 2022, 15:06   #10
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
At worse you can always make the behaviour user-configurable.
meynaf is offline  
Old 23 July 2022, 15:16   #11
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Quote:
Originally Posted by phx View Post
With "source dir first" you mean compile directory?
Yes.
a/b is offline  
Old 23 July 2022, 20:48   #12
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
FWIW I don't have a strong opinion and was just offering my 2 cents. The reason I mentioned VBCC, even though you only asked about VASM, is precisely because of the scenario brought up by meynaf. If you're working a on mixed ASM/C project and it behaves differently for assembly and C include files that could be confusing.

Also don't know if you're just considering m68k or other supported archs (which I don't care much about ). Either way it probably I'd probably prefer whatever is most compatible with existing code, as I can always adapt new code (which when written in ASM, isn't going to rely on these things).
paraj is offline  
Old 24 July 2022, 16:47   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Thanks for the input! I understand it is important to look into the work-dir first. I also added the new option
-nocompdir
to ignore the compile-dir completely.

Doing further tests, I noticed that Devpac is one of the few classic assemblers which supports a compile-dir, but after work-dir and not for relative include paths, which are always work-dir based.

Some assemblers (e.g. basm) will search in
incdir
paths before the work-dir. I chose to search work-dir, then compile-dir, first, following Devpac as reference.
phx is offline  
Old 25 July 2022, 15:31   #14
Auscoder
Registered User
 
Join Date: Jan 2019
Location: Brisbane
Posts: 99
I have compile dir and work dir as the same as I deploy a custom vasm build to my work dir. I also have any dependencies within a subdir here. I like to keep all my project deps together per project. If I were not doing that ie with seperate dirs I would expect work dir first when an include path has not been set.
Auscoder is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
vasm Get Current Work Directory (Windows expert needed) phx Coders. General 13 15 October 2018 20:57
Config file directory paths hexaae support.WinUAE 6 24 June 2018 17:28
Trying to have portable configuration, relative paths relative to C:\Public\... ? Turrican support.WinUAE 3 24 June 2011 16:33
Relative paths (WAS: Has anybody ever gotten Shiftrix to work?) rsn8887 support.WinUAE 9 27 August 2010 06:56
Relative paths Toni Wilen request.UAE Wishlist 0 16 August 2009 16:06

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:08.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.26280 seconds with 13 queries