aboutsummaryrefslogtreecommitdiff
path: root/src/Package.zig
AgeCommit message (Collapse)Author
2023-09-15package manager: write deps in a flat format, eliminating the FQN conceptmlugg
The new `@depedencies` module contains generated code like the following (where strings like "abc123" represent hashes): ```zig pub const root_deps = [_]struct { []const u8, []const u8 }{ .{ "foo", "abc123" }, }; pub const packages = struct { pub const abc123 = struct { pub const build_root = "/home/mlugg/.cache/zig/blah/abc123"; pub const build_zig = @import("abc123"); pub const deps = [_]struct { []const u8, []const u8 }{ .{ "bar", "abc123" }, .{ "name", "ghi789" }, }; }; }; ``` Each package contains a build root string, the build.zig import, and a mapping from dependency names to package hashes. There is also such a mapping for the root package dependencies. In theory, we could now remove the `dep_prefix` field from `std.Build`, since its main purpose is now handled differently. I believe this is a desirable goal, as it doesn't really make sense to assign a single FQN to any package (because it may appear in many different places in the package hierarchy). This commit does not remove that field, as it's used non-trivially in a few places in the build runner and compiler tests: this will be a future enhancement. Resolves: #16354 Resolves: #17135
2023-08-27std: Rename `TailQueue` to `DoublyLinkedList`Jay Petacat
`TailQueue` was implemented as a doubly-linked list, but named after an abstract data type. This was inconsistent with `SinglyLinkedList`, which can be used to implement an abstract data type, but is still named after the implementation. Renaming `TailQueue` to `DoublyLinkedList` improves consistency between the two type names, and should help discoverability. `TailQueue` is now a deprecated alias of `DoublyLinkedList`. Related to issues #1629 and #8233.
2023-07-25Package: add progress indicator for package fetchingmlugg
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-03fix missing insertion of module to all_modules on first downloadDraagrenKirneh
2023-05-25std.fs.file: Rename File.Kind enum values to snake caseLinus Groh
2023-05-24Improve Content-Disposition filename detection (#15844)DraagrenKirneh
2023-05-23std.sort: add pdqsort and heapsortAli Chraghi
2023-05-18Only add build.zig module dependencies oncemlugg
2023-05-18Deduplicate uses of the same package across dependenciesmlugg
2023-05-15Package: support gitlab tarball urlsTravis Staloch
Allows the package manager to download gitlab tarballs from urls such as https://gitlab.com/<namespace>/<project>/-/archive/<sha>/<project>-<sha>.tar.gz Such http requests have headers Content-Type=application/octet-stream and Content-Disposition='attachment; filename="<project>-<sha>.tar.gz"'. The package manager doesn't yet support these headers. This patch doesn't attempt to properly parse the content-disposition header. Instead it checks that it starts with 'attachment;' and ends with '.tar.gz"'.
2023-05-13Improve error handling on dependency download (#15661)DraagrenKirneh
verify ok status on response. improve error messages
2023-05-13add application/tar+gzip unblocking sr.ht packagesSimon A. Nielsen Knights
2023-05-03Change compression detection to use content-type instead of the url endingDraagrenKirneh
2023-04-26std.http: do -> wait, fix redirectsNameless
2023-04-18std.http: pass Method to request directly, parse trailing headersNameless
2023-04-17std.http: curate some Server errors, fix reading chunked bodiesNameless
2023-04-17std.http: add HeadersNameless
2023-04-08update package manager to use req.do(), fix chunked trailer readingNameless
2023-03-15std.zig.ErrorBundle: rework binary encodingAndrew Kelley
* Separate into a "WIP" struct and a "finished" struct. * Use a bit of indirection for error notes to simplify ergonomics of this data structure.
2023-03-15progress towards semantic error serializationAndrew Kelley
Introduces std.zig.ErrorBundle which is a trivially serializeable set of compilation errors. This is in the standard library so that both the compiler and the build runner can use it. The idea is they will use it to communicate compilation errors over a binary protocol. The binary encoding of ErrorBundle is a bit problematic - I got a little too aggressive with compaction. I need to change it in a follow-up commit to use some indirection in the error message list, otherwise iteration is too unergonomic. In fact it's so problematic right now that the logic getAllErrorsAlloc() actually fails to produce a viable ErrorBundle because it puts SourceLocation data in between the root level ErrorMessage data. This commit has a simplification - redundant logic for rendering AST errors to stderr has been removed in favor of moving the logic for lowering AST errors into AstGen. So even if we get parse errors, the errors will get lowered into ZIR before being reported. I believe this will be useful when working on --autofix. Either way, some redundant brittle logic was happily deleted. In Compilation, updateSubCompilation() is improved to properly perform error reporting when a sub-compilation object fails. It no longer dumps directly to stderr; instead it populates an ErrorBundle object, which gets added to the parent one during getAllErrorsAlloc(). In package fetching code, instead of dumping directly to stderr, it now populates an ErrorBundle object, and gets properly reported at the CLI layer of abstraction.
2023-03-15extract ThreadPool and WaitGroup from compiler to std libAndrew Kelley
2023-03-09Add ability to import dependencies from build.zigantlilja
2023-03-05fix package redeclaration when cache is not foundjiacai2050
2023-03-01packages: avoid creating multiple modules with same build.zigAndrew Kelley
When there is a diamond dependency, reuse a *Module instead of creating a redundant one using the same build.zig file. Otherwise, the compile error "file exists in multiple modules" would occur.
2023-02-25fix package hashes on WindowsAndrew Kelley
closes #14602
2023-02-22Close files in hashFileFallibleKen Kochis
2023-02-21Implement new module CLImlugg
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-02-13move the cache system from compiler to std libAndrew Kelley
2023-02-03use build.zig.zon instead of build.zig.ini for the manifest fileAndrew Kelley
* improve error message when build manifest file is missing * update std.zig.Ast to support ZON * Compilation.AllErrors.Message: make the notes field a const slice * move build manifest parsing logic into src/Manifest.zig and add more checks, and make the checks integrate into the standard error reporting code so that reported errors look sexy closes #14290
2023-02-01zig build: use multihash for the hash fieldAndrew Kelley
https://multiformats.io/multihash/ Still, only SHA2-256 is supported. This is only intended to future-proof the hash field of the manifest. closes #14284
2023-02-01zig build: add executable bit and file path to package hashAndrew Kelley
Unfortunately, due to the Windows equivalent of executable permissions being a bit tricky, there is follow-up work to be done. What is done in this commit is the hash modifications. At the fetch layer, executable bits inside packages are ignored. In the hash computation layer, executable bit is implemented for POSIX but not yet for Windows. This means that the hash will not break again in the future for packages that do not have any executable files, but it will break for packages that do. This is a hash-breaking change. Closes #14308
2023-01-24support xz compressed tarballs in the package managerAndrew Kelley
This includes a breaking change: std.compress.gzip.GzipStream renamed to std.compress.gzip.Decompress This follows the same naming convention as std.compress.xz so that the stream type can be passed as a comptime parameter.
2023-01-22Package: store package name directlymlugg
By @Vexu's suggestion, since fetching the name from the parent package is error-prone and complex, and optimising Package for size isn't really a priority.
2023-01-11Package: handle Windows PathAlreadyExists error codeAndrew Kelley
Unfortunately, error.AccessDenied is ambiguous on Windows when it is returned from fs.rename.
2023-01-11use local cache dir for dependencies-listing packageAndrew Kelley
2023-01-11zig build: support dependenciesAndrew Kelley
The `zig build` command now makes `@import("@dependencies")` available to the build runner package. It contains all the dependencies in a generated file that looks something like this: ```zig pub const imports = struct { pub const foo = @import("foo"); pub const @"bar.baz" = @import("bar.baz"); }; pub const build_root = struct { pub const foo = "<path>"; pub const @"bar.baz" = "<path>"; }; ``` The build runner exports this import so that `std.build.Builder` can access it. `std.build.Builder` uses it to implement the new `dependency` function which can be used like so: ```zig const libz_dep = b.dependency("libz", .{}); const libmp3lame_dep = b.dependency("libmp3lame", .{}); // ... lib.linkLibrary(libz_dep.artifact("z")); lib.linkLibrary(libmp3lame_dep.artifact("mp3lame")); ``` The `dependency` function calls the build.zig file of the dependency as a child Builder, and then can be ransacked for its build steps via the `artifact` function. This commit also renames `dependency.id` to `dependency.name` in the `build.zig.ini` file.
2023-01-11Package: complete the package-fetching logicAndrew Kelley
2023-01-11package manager: compute hash, move tmp dir into global cacheAndrew Kelley
2023-01-11compiler: add package manager skeletonAndrew Kelley
see #943
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811
2021-09-29stage2: enable building compiler_rt when using LLVM backendAndrew Kelley
* AstGen: fix emitting `store_to_inferred_ptr` when it should be emitting `store` for a variable that has an explicit alignment. * Compilation: fix a couple memory leaks * Sema: implement support for locals that have specified alignment. * Sema: implement `@intCast` when it needs to emit an AIR instruction. * Sema: implement `@alignOf` * Implement debug printing for extended alloc ZIR instructions.
2021-09-19Update all ensureCapacity calls to the relevant non-deprecated versionRyan Liptak
2021-06-03Breaking hash map changes for 0.8.0Martin Wickham
- hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig
2021-05-17stage2: get rid of NameHashAndrew Kelley
Previously, stage2 used a global decl_table for all Decl objects, keyed by a 16-byte name hash that was hopefully unique. Now, there is a tree of Namespace objects that own their named Decl objects.
2021-04-08stage2: blaze the trail for std lib integrationAndrew Kelley
This branch adds "builtin" and "std" to the import table when using the self-hosted backend. "builtin" gains one additional item: ``` pub const zig_is_stage2 = true; // false when using stage1 backend ``` This allows the std lib to do conditional compilation based on detecting which backend is being used. This will be removed from builtin as soon as self-hosted catches up to feature parity with stage1. Keep a sharp eye out - people are going to be tempted to abuse this. The general rule of thumb is do not use `builtin.zig_is_stage2`. However this commit breaks the rule so that we can gain limited start.zig support as we incrementally improve the self-hosted compiler. This commit also implements `fullyQualifiedNameHash` and related functionality, which effectively puts all Decls in their proper namespaces. `fullyQualifiedName` is not yet implemented. Stop printing "todo" log messages for test decls unless we are in test mode. Add "previous definition here" error notes for Decl name collisions. This commit does not bring us yet to a newly passing test case. Here's what I'm working towards: ```zig const std = @import("std"); export fn main() c_int { const a = std.fs.base64_alphabet[0]; return a - 'A'; } ``` Current output: ``` $ ./zig-cache/bin/zig build-exe test.zig test.zig:3:1: error: TODO implement more analyze elemptr zig-cache/lib/zig/std/start.zig:38:46: error: TODO implement structInitExpr ty ``` So the next steps are clear: * Sema: improve elemptr * AstGen: implement structInitExpr
2021-04-08stage2: revert to only has_decl and export ZIR supportAndrew Kelley
Reverting most of the code from the previous commits in this branch. Will pull in the code with modifications bit by bit.