Merge branch 'master' into keybind
This commit is contained in:
commit
0cb0f59de8
2 changed files with 31 additions and 16 deletions
14
build.zig
14
build.zig
|
@ -74,7 +74,9 @@ fn build_release(
|
|||
) void {
|
||||
const targets: []const std.Target.Query = &.{
|
||||
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
|
||||
.{ .cpu_arch = .x86, .os_tag = .linux, .abi = .musl },
|
||||
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl },
|
||||
.{ .cpu_arch = .arm, .os_tag = .linux, .abi = .musleabihf },
|
||||
.{ .cpu_arch = .x86_64, .os_tag = .macos },
|
||||
.{ .cpu_arch = .aarch64, .os_tag = .macos },
|
||||
.{ .cpu_arch = .x86_64, .os_tag = .windows },
|
||||
|
@ -147,7 +149,7 @@ pub fn build_exe(
|
|||
|
||||
var version_info = std.ArrayList(u8).init(b.allocator);
|
||||
defer version_info.deinit();
|
||||
gen_version_info(b, version_info.writer()) catch {
|
||||
gen_version_info(b, target, version_info.writer()) catch {
|
||||
version_info.clearAndFree();
|
||||
version_info.appendSlice("unknown") catch {};
|
||||
};
|
||||
|
@ -471,7 +473,11 @@ pub fn build_exe(
|
|||
// b.default_step.dependOn(lint_step);
|
||||
}
|
||||
|
||||
fn gen_version_info(b: *std.Build, writer: anytype) !void {
|
||||
fn gen_version_info(
|
||||
b: *std.Build,
|
||||
target: std.Build.ResolvedTarget,
|
||||
writer: anytype,
|
||||
) !void {
|
||||
var code: u8 = 0;
|
||||
|
||||
const describe = try b.runAllowFail(&[_][]const u8{ "git", "describe", "--always", "--tags" }, &code, .Ignore);
|
||||
|
@ -484,10 +490,12 @@ fn gen_version_info(b: *std.Build, writer: anytype) !void {
|
|||
const remote = std.mem.trimRight(u8, remote_, "\r\n ");
|
||||
const log = std.mem.trimRight(u8, log_, "\r\n ");
|
||||
const diff = std.mem.trimRight(u8, diff_, "\r\n ");
|
||||
const target_triple = try target.result.zigTriple(b.allocator);
|
||||
|
||||
try writer.print("Flow Control: a programmer's text editor\n\nversion: {s}{s}\n", .{
|
||||
try writer.print("Flow Control: a programmer's text editor\n\nversion: {s}{s}\ntarget: {s}\n", .{
|
||||
version,
|
||||
if (diff.len > 0) "-dirty" else "",
|
||||
target_triple,
|
||||
});
|
||||
|
||||
if (branch.len > 0)
|
||||
|
|
33
src/main.zig
33
src/main.zig
|
@ -64,6 +64,7 @@ pub fn main() anyerror!void {
|
|||
.no_syntax = "Disable syntax highlighting",
|
||||
.syntax_report_timing = "Report syntax highlighting time",
|
||||
.exec = "Execute a command on startup",
|
||||
.literal = "Disable :LINE and +LINE syntax",
|
||||
.version = "Show build version and exit",
|
||||
};
|
||||
|
||||
|
@ -74,6 +75,7 @@ pub fn main() anyerror!void {
|
|||
.trace_level = 't',
|
||||
.language = 'l',
|
||||
.exec = 'e',
|
||||
.literal = 'L',
|
||||
.version = 'v',
|
||||
};
|
||||
|
||||
|
@ -92,6 +94,7 @@ pub fn main() anyerror!void {
|
|||
no_syntax: bool,
|
||||
syntax_report_timing: bool,
|
||||
exec: ?[]const u8,
|
||||
literal: bool,
|
||||
version: bool,
|
||||
};
|
||||
|
||||
|
@ -211,7 +214,7 @@ pub fn main() anyerror!void {
|
|||
for (positional_args.items) |arg| {
|
||||
if (arg.len == 0) continue;
|
||||
|
||||
if (arg[0] == '+') {
|
||||
if (!args.literal and arg[0] == '+') {
|
||||
const line = try std.fmt.parseInt(usize, arg[1..], 10);
|
||||
if (prev) |p| {
|
||||
p.line = line;
|
||||
|
@ -228,18 +231,22 @@ pub fn main() anyerror!void {
|
|||
curr.line = line;
|
||||
line_next = null;
|
||||
}
|
||||
var it = std.mem.splitScalar(u8, arg, ':');
|
||||
curr.file = it.first();
|
||||
if (it.next()) |line_|
|
||||
curr.line = std.fmt.parseInt(usize, line_, 10) catch blk: {
|
||||
curr.file = arg;
|
||||
break :blk null;
|
||||
};
|
||||
if (curr.line) |_| {
|
||||
if (it.next()) |col_|
|
||||
curr.column = std.fmt.parseInt(usize, col_, 10) catch null;
|
||||
if (it.next()) |col_|
|
||||
curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null;
|
||||
if (!args.literal) {
|
||||
var it = std.mem.splitScalar(u8, arg, ':');
|
||||
curr.file = it.first();
|
||||
if (it.next()) |line_|
|
||||
curr.line = std.fmt.parseInt(usize, line_, 10) catch blk: {
|
||||
curr.file = arg;
|
||||
break :blk null;
|
||||
};
|
||||
if (curr.line) |_| {
|
||||
if (it.next()) |col_|
|
||||
curr.column = std.fmt.parseInt(usize, col_, 10) catch null;
|
||||
if (it.next()) |col_|
|
||||
curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null;
|
||||
}
|
||||
} else {
|
||||
curr.file = arg;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue