c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
2.98k stars 183 forks source link

wrong location of build artefact when building project #1464

Open BluBloos opened 1 month ago

BluBloos commented 1 month ago

I downloaded and unzipped to get a folder containing c3c.exe. I navigated cmd.exe to the folder. I ran: c3c init project. I ran: c3c compile project. main.exe was created in the same folder level as c3c.exe, whereas I expected main.exe to be created within the build folder belonging to the project.

lerno commented 1 month ago

Two things:

  1. If you use c3c compile project it is actually saying "compile all the source files in the 'project' folder'. Use c3c build instead.
  2. If you build a project, then the .exe will end up in the same directory as the project.json by default. This behaviour can be overridden.
  3. The build folder is intended for intermediate build artifacts.
BluBloos commented 1 month ago

Thanks for the response!

I misunderstood the purpose of the build folder because I skimmed https://c3-lang.org/guide/my-first-project/ and assumed the build folder is not only where intermediate build artifacts go but all artifacts.

As a first-time user, I think it's confusing that there are two commands compile and build. If I were to suggest a change, it would be to have just one command compile. The compile command would build all source files in a folder unless it recognizes that the folder is a project, in which case it builds the project. That being said, maybe this is another case of my lack of understanding for why there are two commands.

lerno commented 1 month ago

They act quite differently. build takes a single "target" argument, which is what target in the project.json file one wishes to compile for, e.g. c3c build mygame-testversion, whereas compile is to just straight go and compile individual files, without a project, e.g. c3c compile foo.c3 bar.c3 baz.c3

lerno commented 1 month ago

There is also compile-run (compile files and run them), and run (build the target and run it)

lerno commented 1 week ago

Can I close this?