Open kawaii-Code opened 1 month ago
You definately came to this question from a weird place, but an attempt to build a filesystem root should be a compiler error. That aside, though:
We already have the package name and, unlike go, the package doesn't have to be main. I usually call the package the same as the project. Is there any reason for using parent directory name?
I actually agree with this somewhat, because it also causes naming conflicts on linux, because if you have a directory called src
inside your project directory, and build it, it will try to make an executable with the same name, which causes a name conflict (I don't remember how it's resolved currently) between the executable and the directory. If this is a game project, the package name would be something like game
, which would make more sense as a default.
I am not sure what to do in this case.
Firstly: why the heck are you doing what you are doing?!?!?!
Secondly: maybe we should just ban this from being a thing.
As I've mentioned in the notes, it's not that I want to do that, it's more of "why even use the parent directory"? I also relate to flysand's point about src
. In my opinion, using the package name for the output file is a better default.
Steps to Reproduce
Windows
Make an odin file at
C:\
Run cmd as administrator at
C:\
odin build .
This will output a peculiar empty file
C
without any extensions(Which is kinda hilarious)
Interestingly,
odin run .
works fine, as well as-file
variants.Linux
Here, the crash is more straightforward:
Note: this also works without any odin files, just launching
odin build .
orodin run .
at/
is enough.Context
Notes
The bug obviously occurs because while building a package, odin tries to use the parent directory name as the name for the executable. At the root, there is no parent. So, here is the bug.
My issue isn't really about wanting to make a package at filesystem root, that's weird. It's more about using the parent directory name for the executable name. Why do this? We already have the package name and, unlike go, the package doesn't have to be
main
. I usually call the package the same as the project. Is there any reason for using parent directory name?