version.ha (1081B)
1 // SPDX-License-Identifier: GPL-3.0-only 2 // (c) Hare authors <https://harelang.org> 3 4 use ascii; 5 use bufio; 6 use fmt; 7 use getopt; 8 use os; 9 use strings; 10 11 fn version(name: str, cmd: *getopt::command) (void | error) = { 12 let verbose = false; 13 for (let opt .. cmd.opts) { 14 switch (opt.0) { 15 case 'v' => 16 verbose = true; 17 case => abort(); 18 }; 19 }; 20 21 fmt::printfln("hare {}", VERSION)!; 22 if (!verbose) { 23 return; 24 }; 25 26 let build_arch = os::arch_name(os::architecture()); 27 let build_arch = get_arch(build_arch)!; 28 let build_platform = ascii::strlower(os::sysname()); 29 30 fmt::printfln("build tags:\n\t+{}\n\t+{}\nHAREPATH{}:", 31 build_arch.name, build_platform, 32 if (os::getenv("HAREPATH") is str) " (from environment)" else "")?; 33 34 let tok = strings::tokenize(harepath(), ":"); 35 for (let s => strings::next_token(&tok)) { 36 fmt::printfln("\t{}", s)?; 37 }; 38 39 fmt::println("toolchains:")?; 40 for (let arch .. arches) { 41 fmt::printfln(" {}:", arch.name)?; 42 fmt::printfln("\tAS={}", arch.as_cmd)?; 43 fmt::printfln("\tCC={}", arch.cc_cmd)?; 44 fmt::printfln("\tLD={}", arch.ld_cmd)?; 45 }; 46 };