config: enable passwd isn't compiled for wasm

This commit is contained in:
Mitchell Hashimoto
2022-12-30 16:32:49 -08:00
parent 7c291a2c4c
commit 1093cf5254
3 changed files with 42 additions and 22 deletions

View File

@ -26,6 +26,10 @@ fetch(url.href).then(response =>
const {
malloc,
free,
config_new,
config_free,
config_load_string,
config_finalize,
face_new,
face_free,
face_render_glyph,
@ -68,6 +72,12 @@ fetch(url.href).then(response =>
return { ptr: ptr, len: utf8.byteLength };
};
// Create our config
const config = config_new();
const config_str = makeStr("font-family = monospace");
config_load_string(config, config_str.ptr, config_str.len);
config_finalize(config);
// Create our atlas
// const atlas = atlas_new(512, 0 /* greyscale */);

View File

@ -314,8 +314,10 @@ pub const Config = struct {
};
// If we are missing either a command or home directory, we need
// to look up defaults which is kind of expensive.
// to look up defaults which is kind of expensive. We only do this
// on desktop.
const wd_home = std.mem.eql(u8, "home", wd);
if (comptime !builtin.target.isWasm()) {
if (self.command == null or wd_home) command: {
const alloc = self._arena.?.allocator();
@ -344,6 +346,7 @@ pub const Config = struct {
}
}
}
}
// If we have the special value "inherit" then set it to null which
// does the same. In the future we should change to a tagged union.
@ -528,7 +531,7 @@ pub const Keybinds = struct {
};
// Wasm API.
pub const Wasm = struct {
pub const Wasm = if (!builtin.target.isWasm()) struct {} else struct {
const wasm = @import("os/wasm.zig");
const alloc = wasm.alloc;
const cli_args = @import("cli_args.zig");

View File

@ -5,6 +5,13 @@ const ArenaAllocator = std.heap.ArenaAllocator;
const log = std.log.scoped(.passwd);
// We want to be extra sure since this will force bad symbols into our import table
comptime {
if (builtin.target.isWasm()) {
@compileError("passwd is not available for wasm");
}
}
/// Used to determine the default shell and directory on Unixes.
const c = @cImport({
@cInclude("sys/types.h");