Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case-sensitivity sometimes causes include files not to be recognized on Linux #32

Open
squattingmonk opened this issue Apr 18, 2022 · 4 comments

Comments

@squattingmonk
Copy link
Contributor

squattingmonk commented Apr 18, 2022

Since filenames are case-sensitive on Linux, #include directives must be case sensitive unless the file is sourced from the game's data files. For example, given the following script:

#include "X3_INC_STRING"
void main()
{
  SpeakString(StringToRGBString("Hello World!", STRING_COLOR_BLUE));
}

Compilation succeeds using -l:

$ nwnsc -jl test.nss
Loading base game resources...

Home Path - ~/Documents/Neverwinter Nights/

Compiling: test.nss
ShowIncludes: Handled resource /home/squattingmonk/.local/share/Steam/steamapps/common/Neverwinter Nights//data/base_scripts.bif/X3_INC_STRING.nss

Total Execution time = 0.0620 seconds  

It fails using -i:

$ nwnsc -ji nwn-assets/nwscript test.nss
Compiling: test.nss
test.nss(1): Error: NSC1085: Unable to open the include file "X3_INC_STRING"


Compilation aborted with errors.

Processing aborted.

Total Execution time = 0.0100 seconds  

Changing the include file to x3_inc_string makes compilation work:

$ nwnsc -ji nwn-assets/nwscript test.nss
Compiling: test.nss
ShowIncludes: Handled resource nwn-assets/nwscript/x3_inc_string.nss

Total Execution time = 0.0100 seconds  

While you can just make sure your scripts always use lowercase versions of the filenames, a lot of the base game scripts use uppercase filenames in their include directives, and this can cause things to break. I think the file's basename ought to be compared case-insensitively to the include directive so that -i behavior matches -l behavior.

@jakkn
Copy link
Contributor

jakkn commented Apr 18, 2022

It looks like the examples you provided with -l and -i are clones, but I guess this is the effect of the -i flag

$ nwnsc -ji "/home/jkn/.local/share/Steam/steamapps/common/Neverwinter Nights/ovr" main.nss
Compiling: main.nss
main.nss(10): Error: NSC1085: Unable to open the include file "X3_INC_STRING"


Compilation aborted with errors.

Processing aborted.

Total Execution time = 0.0180 seconds

Changing from case sensitive to case insensitive looks like a breaking change, since you can #include test and #include Test distinctively as long as it's not done in the same file. Not that I'd recommend doing this, but since it's technically possible we have to consider the potential implications. Any input, @virusman?

@squattingmonk
Copy link
Contributor Author

It looks like the examples you provided with -l and -i are clones

Whoops! I've updated the initial post, but yeah the output you got is the same.

Changing from case sensitive to case insensitive looks like a breaking change, since you can #include test and #include Test distinctively as long as it's not done in the same file. Not that I'd recommend doing this, but since it's technically possible we have to consider the potential implications. Any input, @virusman?

I agree that it could technically be a breaking change, but this behavior is only present on Linux (and Mac, probably) with this flag. It doesn't match toolset behavior or Windows behavior. In case someone is using that "feature" for some reason, we could always check for a case-sensitive match first and fall back to a case insensitive match if it didn't exist.

@jakkn
Copy link
Contributor

jakkn commented Apr 20, 2022

Changing from case sensitive to case insensitive looks like a breaking change, since you can #include test and #include Test distinctively as long as it's not done in the same file. Not that I'd recommend doing this, but since it's technically possible we have to consider the potential implications. Any input, @virusman?

I agree that it could technically be a breaking change, but this behavior is only present on Linux (and Mac, probably) with this flag. It doesn't match toolset behavior or Windows behavior. In case someone is using that "feature" for some reason, we could always check for a case-sensitive match first and fall back to a case insensitive match if it didn't exist.

If the toolset compiler doesn't match this behavior then I agree with the change. No flag should be necessary.

@meaglyn
Copy link
Contributor

meaglyn commented Sep 15, 2022

Anyone using both "Test" and "test" deserves what he gets. I just ran into this too. I think it should be case insensitive when using the -i as well. Btw, I just noticed you guys switch back to using the right letter for the include directory option. Yay. Maybe I'll start using this instead of maintaining my own :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants