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

zig build --init should create a working hello world, and it should be in the test suite #1035

Closed
andrewrk opened this issue Jun 2, 2018 · 7 comments
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jun 2, 2018

Right now the zig build --init template is bitrotted again. Fix it, and then let's update it so that it creates a working hello world example, and add that to the test suite.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Jun 2, 2018
@andrewrk andrewrk added this to the 0.3.0 milestone Jun 2, 2018
andrewrk added a commit that referenced this issue Jun 2, 2018
@ghost
Copy link

ghost commented Jun 3, 2018

@andrewrk Maybe also rename zig build --init to zig init. IMO zig init makes more sense, and other package managers (cargo, npm, nimble etc) use it.
zig init to create build.zig in the current dir.
zig init packagename to create a new dir packagename and place the build.zig inside it.

@andrewrk
Copy link
Member Author

zig init sounds good. What about the fact that you should have to decide between a library or an executable?

  • Option 1

zig init-lib
zig init-exe

  • Option 2

zig build --init-lib
zig build --init-exe

@kristate
Copy link
Contributor

I like option 1 because it forces the programer to think which init procedure they would like.

@viluon
Copy link

viluon commented Sep 17, 2018

zig init — executable by default
zig init --lib — library

@kristate
Copy link
Contributor

@viluon this is too much like rust and there are times that you can forget if lib or bin is the default. Option 1 is better because it forces the programer to think/choose.

@kyle-github
Copy link

When I am building a library, I find it useful to also create examples of using the library, so I tend to create single projects that build both library and executable artifacts. At least with CMake, this is possible, if clearly not the most easily supported option. Would this be allowed with this notation?

zig build --init-lib --init-exe

zig build --init=lib,exe

zig build --init=lib-shared,lib-static,exe-shared,exe-static

Personally I like the idea of separating the idea of initializing the project from the type of project it will be. That allows for future additions without quite as much additional syntax (though this is minor).

The built in test parts of zig make the utility of additional executables a bit less interesting, but I find that for any reasonably sized library, having a working example to start from is very handy.

@andrewrk
Copy link
Member Author

andrewrk commented Sep 17, 2018

I went ahead with init-lib and init-exe.

@kyle-github Indeed zig build does support building any combination of executables and libraries, but I'm not sure how deep we want to get into providing code templates.

I think that "hello world" for executables and libraries goes a long way, perhaps as far as we need to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

4 participants