| author | |
| committer | |
| log | d6a1a0803f6a9ecace8ff0c23d4ad54f65670bde |
| tree | 67bf454bec8ab9668743242692d63c2b578b39b2 |
| parent | 7514b71286a8659c2917b78acf7f36b5da7e9657 |
| signature | Commit is signed but in an unrecognized format. |
4 files changed, 32 insertions(+), 9 deletions(-)
CHANGELOG.md+2| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | ## 0.1.5 | |
| 2 | ||
| 1 | 3 | ## 0.1.4 |
| 2 | 4 | |
| 3 | 5 | - feat: implement basic struct types (#42) |
build.zig+18-4| ... | ... | @@ -3,7 +3,7 @@ const Build = std.Build; |
| 3 | 3 | const Target = std.Target; |
| 4 | 4 | const OsVersion = Target.Query.OsVersion; |
| 5 | 5 | |
| 6 | pub fn build(b: *std.Build) void { | |
| 6 | pub fn build(b: *std.Build) !void { | |
| 7 | 7 | b.reference_trace = 20; |
| 8 | 8 | |
| 9 | 9 | const native_target = b.resolveTargetQuery(.{}); |
| ... | ... | @@ -40,8 +40,20 @@ pub fn build(b: *std.Build) void { |
| 40 | 40 | "Experiment with the Zig self-hosted backends", |
| 41 | 41 | ) orelse false; |
| 42 | 42 | |
| 43 | const native_debug = buildWithTarget(b, native_target, .Debug, .none, no_llvm); | |
| 44 | const main = buildWithTarget(b, target, optimize, tracing, no_llvm); | |
| 43 | const version = version: { | |
| 44 | const text = try b.build_root.handle.readFileAlloc( | |
| 45 | b.graph.arena, | |
| 46 | "CHANGELOG.md", | |
| 47 | std.math.maxInt(usize), | |
| 48 | ); | |
| 49 | const first_header = std.mem.indexOf(u8, text, "## ") orelse unreachable; | |
| 50 | var tokenizer = std.mem.tokenizeAny(u8, text[first_header + 2 ..], " \t\n"); | |
| 51 | const version_text = tokenizer.next() orelse unreachable; | |
| 52 | break :version std.SemanticVersion.parse(version_text) catch unreachable; | |
| 53 | }; | |
| 54 | ||
| 55 | const native_debug = buildWithTarget(b, native_target, .Debug, .none, version, no_llvm); | |
| 56 | const main = buildWithTarget(b, target, optimize, tracing, version, no_llvm); | |
| 45 | 57 | |
| 46 | 58 | b.installArtifact(main.compiler); |
| 47 | 59 | |
| ... | ... | @@ -133,7 +145,7 @@ pub fn build(b: *std.Build) void { |
| 133 | 145 | }, |
| 134 | 146 | ) catch @panic("OOM"); |
| 135 | 147 | |
| 136 | const artifacts = buildWithTarget(b, cross_target, .ReleaseSafe, .none, no_llvm); | |
| 148 | const artifacts = buildWithTarget(b, cross_target, .ReleaseSafe, .none, version, no_llvm); | |
| 137 | 149 | |
| 138 | 150 | inline for (.{ |
| 139 | 151 | .{ artifacts.compiler, "compiler" }, |
| ... | ... | @@ -173,6 +185,7 @@ fn buildWithTarget( |
| 173 | 185 | target: Build.ResolvedTarget, |
| 174 | 186 | optimize: std.builtin.OptimizeMode, |
| 175 | 187 | tracing: TracingMode, |
| 188 | version: std.SemanticVersion, | |
| 176 | 189 | no_llvm: bool, |
| 177 | 190 | ) Artifacts { |
| 178 | 191 | const dep_opts = .{ .target = target, .optimize = optimize }; |
| ... | ... | @@ -185,6 +198,7 @@ fn buildWithTarget( |
| 185 | 198 | |
| 186 | 199 | // Options |
| 187 | 200 | const opts = b.addOptions(); |
| 201 | opts.addOption(std.SemanticVersion, "version", version); | |
| 188 | 202 | opts.addOption([]const u8, "tracing", @tagName(tracing)); |
| 189 | 203 | const opts_mod = opts.createModule(); |
| 190 | 204 |
src/core/js/Link.zig+9-5| ... | ... | @@ -70,7 +70,10 @@ pub fn linkJsCode(link: *Link, entry_decl: Decl.Index, writer: Writer) !void { |
| 70 | 70 | try link.decls.putNoClobber(link.comp.gpa, value, @enumFromInt(gop.index)); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | try writer.print("// Language Compiler v0.1.4. Alpha quality software.\n", .{}); | |
| 73 | try writer.writeAll(std.fmt.comptimePrint( | |
| 74 | "// Language Compiler v{}. Alpha quality software.\n", | |
| 75 | .{core.version}, | |
| 76 | )); | |
| 74 | 77 | |
| 75 | 78 | if (root_function.nodes.len > 1) { |
| 76 | 79 | // 2. Print every function decl |
| ... | ... | @@ -843,14 +846,15 @@ const Wyhash = std.hash.Wyhash; |
| 843 | 846 | const log = std.log.scoped(.js_link); |
| 844 | 847 | const Writer = std.io.AnyWriter; |
| 845 | 848 | |
| 846 | const Comp = @import("../Comp.zig"); | |
| 849 | const core = @import("../mod.zig"); | |
| 850 | const Comp = core.Comp; | |
| 847 | 851 | const Decl = Comp.Decl; |
| 848 | 852 | |
| 849 | const Js = @import("Js.zig"); | |
| 850 | const Tree = @import("Tree.zig"); | |
| 853 | const Js = core.Js; | |
| 854 | const Tree = Js.Tree; | |
| 851 | 855 | const Node = Tree.Node; |
| 852 | 856 | |
| 853 | const InternPool = @import("../InternPool.zig"); | |
| 857 | const InternPool = core.InternPool; | |
| 854 | 858 | const String = InternPool.String; |
| 855 | 859 | |
| 856 | 860 | const tracer = @import("tracer"); |
src/core/mod.zig+3| ... | ... | @@ -48,6 +48,9 @@ pub const unicode_props = @import("unicode_props.zig"); |
| 48 | 48 | // The rest of this file is utility functions, which are not specific to any of |
| 49 | 49 | // the above namespaces. Remember Zig discourages namespaces like `utils` |
| 50 | 50 | |
| 51 | /// Language SDK version according to the latest entry in `CHANGELOG.md` | |
| 52 | pub const version = @import("build_options").version; | |
| 53 | ||
| 51 | 54 | /// This is an alternative to `std.debug.assert`, where you want to print some |
| 52 | 55 | /// debug info instead of "reached unreachable code". Usage is as follows: |
| 53 | 56 | /// |