c2v icon indicating copy to clipboard operation
c2v copied to clipboard

doom specific hacks should be removed from c2v

Open trollkarlen opened this issue 1 year ago • 4 comments

Also Test files for ci should be maintained in this project and not in doom project(https://github.com/vlang/doom/blob/master/build_whole_project.sh)

trollkarlen avatar May 09 '23 14:05 trollkarlen

we run it everywhere

here (https://github.com/vlang/c2v/blob/master/.github/workflows/doom_gfx_regressions.yml), vlang/v, vlang/doom

all hacks will be unnecessary of course, it's just not there yet

medvednikov avatar May 09 '23 22:05 medvednikov

So lets keep this to track when all special cases for doom removed from this repo.

trollkarlen avatar May 10 '23 07:05 trollkarlen

Maybe not not all of "fixes" are bugs but its definitely not an enhancement.

trollkarlen avatar May 10 '23 08:05 trollkarlen

Info about: https://github.com/vlang/c2v/blob/811a8b7c320d1fda9a23d4a95ed5f84ccc1f2537/src/c2v.v#L2106

When it does the conversion if it finds '/src/' somewhere on the path it chdir to that location to i guess find a headerfile that in the wrong location. So if the path was relative from the start then the new relative path will be wrong.

Example:

v translate banana/src/test.c

it will fail because it will chdir to banana/src and then try to convert the file banana/src/test.c but that file does not exist. But if you have the abs path it works even thou it chdir to banana/src because you started it with an absolute path.

Full test and example:

$ mkdir tests/src
$ cp -a tests/test.c tests/src/
$ v run . tests/src/test.c/1.hello.c
C to V translator 0.3.1
  translating tests/src/test.c/1.hello.c ... sh: line 1: tests/src/test.c/1.hello.json: No such file or directory

The file tests/src/test.c/1.hello.c could not be parsed as a C source file.
$ v run . $(pwd)/tests/src/test.c/1.hello.c
C to V translator 0.3.1
  translating $HOME/c2v/tests/src/test.c/1.hello.c ... Reformatted file: $HOME/c2v/tests/src/test.c/1.hello.v
 took    94 ms ; output .v file: test.c/1.hello.v
Translated   1 files in    94 ms.

trollkarlen avatar May 10 '23 08:05 trollkarlen