vlang/c2v

doom specific hacks should be removed from c2v

trollkarlen opened this issue · 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)

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

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

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

Info about:

c2v/src/c2v.v

Line 2106 in 811a8b7

if path.contains('/src/') {

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.