| author | |
| committer | |
| log | 5c04c22bcc04fba8f84fa8e5ec57482c13d0a488 |
| tree | 6626d4d0865d4940904c74bc0f4e286e5fd27f35 |
| parent | f6937db7d610163f9dac6f69b76bc38e62580a0d |
2 files changed, 33 insertions(+), 1 deletions(-)
doc/docgen.zig+6-1| ... | ... | @@ -512,6 +512,10 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 512 | 512 | target_str = "x86_64-windows"; |
| 513 | 513 | } else if (mem.eql(u8, end_tag_name, "target_linux_x86_64")) { |
| 514 | 514 | target_str = "x86_64-linux"; |
| 515 | } else if (mem.eql(u8, end_tag_name, "target_wasm")) { | |
| 516 | target_str = "wasm32-freestanding"; | |
| 517 | } else if (mem.eql(u8, end_tag_name, "target_wasi")) { | |
| 518 | target_str = "wasm32-wasi"; | |
| 515 | 519 | } else if (mem.eql(u8, end_tag_name, "link_libc")) { |
| 516 | 520 | link_libc = true; |
| 517 | 521 | } else if (mem.eql(u8, end_tag_name, "code_end")) { |
| ... | ... | @@ -1101,7 +1105,8 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1101 | 1105 | _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile"); |
| 1102 | 1106 | |
| 1103 | 1107 | if (code.target_str) |triple| { |
| 1104 | if (mem.startsWith(u8, triple, "x86_64-linux") and | |
| 1108 | if (mem.startsWith(u8, triple, "wasm32") or | |
| 1109 | mem.startsWith(u8, triple, "x86_64-linux") and | |
| 1105 | 1110 | (builtin.os != builtin.Os.linux or builtin.arch != builtin.Arch.x86_64)) |
| 1106 | 1111 | { |
| 1107 | 1112 | // skip execution |
doc/langref.html.in+27| ... | ... | @@ -8958,6 +8958,33 @@ all your base are belong to us</code></pre> |
| 8958 | 8958 | {#see_also|Targets|Zig Build System#} |
| 8959 | 8959 | {#header_close#} |
| 8960 | 8960 | {#header_close#} |
| 8961 | {#header_open|WebAssembly#} | |
| 8962 | {#header_open|Freestanding#} | |
| 8963 | {#code_begin|exe|wasm#} | |
| 8964 | {#target_wasm#} | |
| 8965 | extern fn print(i32) void; | |
| 8966 | ||
| 8967 | export fn add(a: i32, b: i32) void { | |
| 8968 | print(a + b); | |
| 8969 | } | |
| 8970 | {#code_end#} | |
| 8971 | {#header_close#} | |
| 8972 | {#header_open|WASI#} | |
| 8973 | {#code_begin|exe|wasi#} | |
| 8974 | {#target_wasi#} | |
| 8975 | const std = @import("std"); | |
| 8976 | ||
| 8977 | pub fn main() !void { | |
| 8978 | const args = try std.os.argsAlloc(std.heap.wasm_allocator); | |
| 8979 | defer std.os.argsFree(std.heap.wasm_allocator, args); | |
| 8980 | ||
| 8981 | for (args) |arg, i| { | |
| 8982 | std.debug.warn("{}: {}\n", i, arg); | |
| 8983 | } | |
| 8984 | } | |
| 8985 | {#code_end#} | |
| 8986 | {#header_close#} | |
| 8987 | {#header_close#} | |
| 8961 | 8988 | {#header_open|Targets#} |
| 8962 | 8989 | <p> |
| 8963 | 8990 | Zig supports generating code for all targets that LLVM supports. Here is |