-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
build system terminology update: package, project, module, dependency #14307
Comments
Just to clarify, would |
Yes, |
Ok. I think this is a good naming, but this leads to one question. As If I understand it correctly, a package like |
Ok, so this in the app // "clap" here is the string used when calling b.addModule (see code snippet below)
const clap_module = clap_dep.module("clap");
// "clap" here is the name used for `@import` within src/main.zig
exe.addModule("clap", clap_module); would be in my example: const png_compress_mod = png_dep.module("compress");
exe.addModule("png:compress", png_compress_mod); And then in my const png_compress = @import("png:compress"); // name defined in `build.zig` and specific to the app Here I use |
Oops, I got the comments backwards (and therefore so did you from copy-pasting). It should be: // "clap" here is the string used when calling b.addModule (see code snippet below)
const clap_module = clap_dep.module("clap");
// "clap" here is the name used for `@import` within src/main.zig
exe.addModule("clap", clap_module); But then you got it right with your png example 👍 |
Yeah I was confused by the comment, but your former explanation was clear enough for me to get it right. I have updated my post to reflect the fixed code. Now that I get a full circle understanding of the concepts, I fully agree with your terminology. Btw, I am happy you are not introducing a special name like |
What would the thing currently called |
Maybe the term "file" is good enough? I notice some ambiguity with regards to "root source file". The term root could mean what Definitely going to need to retrain my brain on the terms module/package for Zig :) P.S. if we pick a good term it could be used to standardize on a filename, i.e. |
No, that's not what the term means - the compiler has a type |
|
It's possible the term "module" (current terminology) is currently used to represent a single compilation of Zig code I haven't seen it used that way. Is this from looking at the codebase or from a comment somewhere? Every instance of the term "module" I've seen is that it's referring to a file. i.e. "importing a module", the "builtin" module, the "root" module, these are all single files that get combined into a single compilation. The term module also appears in the Zig docs in 2 places that refer to it being a file, i.e. ModuleScope which is "file scope". |
mlugg is talking about an internal datastructure used in the compiler, that's not related to the informal usages of the word "module" you're mentioning (edit: it's also not related to the documentation's usage of "module scope", which should probably be reworded for clarity) |
Oh I see |
Oh yeah, |
With this naming convention, technically "the zig standard library" should instead be called "the zig standard module". |
New API introduced: std.Build.addModule This function exposes a zig module with the given name, which can be used by packages that depend on this one via std.Build.Dependency.module. std.Build.Pkg and related functionality is deleted. Every use case has a straightforward upgrade path using the new Module struct. std.Build.OptionsStep.getPackage is replaced by std.Build.OptionsStep.createModule. std.Build.CompileStep.addPackagePath is replaced by std.Build.CompileStep.addAnonymousModule. This partially addresses #14307 by renaming some of the instances of "package" to "module". Closes #14278
New API introduced: std.Build.addModule This function exposes a zig module with the given name, which can be used by packages that depend on this one via std.Build.Dependency.module. std.Build.Pkg and related functionality is deleted. Every use case has a straightforward upgrade path using the new Module struct. std.Build.OptionsStep.getPackage is replaced by std.Build.OptionsStep.createModule. std.Build.CompileStep.addPackagePath is replaced by std.Build.CompileStep.addAnonymousModule. This partially addresses #14307 by renaming some of the instances of "package" to "module". Closes #14278
EDIT: I realized since the issue is labeled "build system terminology", and this is more of a general naming question, it's probably off-topic, Question about the new For example, the Zig standard (library) module has, besides the root source file
If it's more of an organizational term, would it be incorrect to keep referring to non-exported source files as |
Please allow me to complete the |
Currently the has only been tested on Linux (wsl2). The purpose to use version 0.11 because of initial support for zig pkg manager. TODO: add libzmq module to build all deps, on single build (ref.: ziglang/zig#14307)
In this model, what would be the name/treatment of files that are neither Zig source files (covered by modules), headers (tbh, I forgot how these are currently handled too, I'm trying to compile some stuff for a RISC-V32 platform that requires a custom linker script and I wasn't sure how I could advertise that from the dependency's side. |
Instead of a manually specify "root source file", it is possible we use a convention-over-configuration strategy to pin the filename as |
Could somebody add the const some_module = b.createModule(.{
.source_file = .{ .path = "deps/zig-module/src/main.zig" },
});
exe.addModule("zig-module", some_module); Also explain when or why to use And also add an example of the const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step); |
* start renaming "package" to "module" (see #14307) - build system gains `main_mod_path` and `main_pkg_path` is still there but it is deprecated. * eliminate the object-oriented memory management style of what was previously `*Package`. Now it is `*Package.Module` and all pointers point to externally managed memory. * fixes to get the new Fetch.zig code working. The previous commit was work-in-progress. There are still two commented out code paths, the one that leads to `Compilation.create` and the one for `zig build` that fetches the entire dependency tree and creates the required modules for the build runner.
* start renaming "package" to "module" (see #14307) - build system gains `main_mod_path` and `main_pkg_path` is still there but it is deprecated. * eliminate the object-oriented memory management style of what was previously `*Package`. Now it is `*Package.Module` and all pointers point to externally managed memory. * fixes to get the new Fetch.zig code working. The previous commit was work-in-progress. There are still two commented out code paths, the one that leads to `Compilation.create` and the one for `zig build` that fetches the entire dependency tree and creates the required modules for the build runner.
Adding as a comment here for clarity/tracking: it has been decided to rename the compiler's internal The transition to these new names began in fe87bae. New code should follow these naming schemes where possible (importing |
Would this cause confusion with the concept of a compilation unit in C? |
The use of the term "compilation unit" is intentional because it's referring to exactly the same concept: a |
Sorry to nitpick, but C pre-processor |
The isomorphism that exists within Python is one of the more outstanding and adoption-friendly features. Specifically, |
Not quite. In Python, package is a directory with |
Status Quo
@import
.std.build.LibExeObjStep
.The Problem
We have been using the word "package" already, including in build system APIs:
zig/lib/std/build.zig
Lines 1479 to 1483 in d813cef
zig/lib/std/build/LibExeObjStep.zig
Lines 977 to 980 in d813cef
However, people are 100% going to say "package" when they mean "project". This is unavoidable, inescapable, and we should not fight against it, but rather embrace it. That leaves us with the following lingo:
@import
.Ambiguity strikes ruthlessly.
The Solution
Our hero is the word "module". The word "project" is no longer needed.
@import
.std.build.LibExeObjStep
.I would also like to rename
LibExeObjStep
toCompilationArtifact
while we're at it.This issue is to do the following things:
The text was updated successfully, but these errors were encountered: