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

Generate output differs between windows and linux #539

Closed
tekulvw opened this issue Feb 20, 2024 · 2 comments
Closed

Generate output differs between windows and linux #539

tekulvw opened this issue Feb 20, 2024 · 2 comments
Labels
bug Something isn't working NeedsInvestigation Issue needs some investigation before being fixed parser

Comments

@tekulvw
Copy link

tekulvw commented Feb 20, 2024

Seems mostly related to line endings and path separators in errors. I understand that this behavior could technically be considered correct but personally I think deterministic generation from a given input file would be preferred.

image
image

Both of these screenshots came from autogen diff with no source diff.

@joerdav joerdav added bug Something isn't working parser NeedsInvestigation Issue needs some investigation before being fixed labels Feb 21, 2024
@a-h
Copy link
Owner

a-h commented Feb 22, 2024

Thanks, I agree, it would be preferable to standardise on \n (fewer bytes) and Unix style relative paths (matches HTTP paths).

@a-h
Copy link
Owner

a-h commented Mar 1, 2024

The code that gets the relative filename for use in error messages is at:

relFilePath, err := filepath.Rel(h.dir, absFilePath)
if err != nil {
return false, false, nil, fmt.Errorf("failed to get relative path for %q: %w", fileName, err)
}
var b bytes.Buffer
sourceMap, literals, err := generator.Generate(t, &b, append(h.genOpts, generator.WithFileName(relFilePath))...)
if err != nil {
return false, false, nil, fmt.Errorf("%s generation error: %w", fileName, err)
}

It uses the Go stdlib to get the relative path, which uses the OS specific separator. I'm not sure if there's a package that converts Windows style paths to Unix style. I expect that a string replace of \ to / would break escaping of some sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working NeedsInvestigation Issue needs some investigation before being fixed parser
Projects
None yet
Development

No branches or pull requests

3 participants