Lines Matching full:local
7 local libgen = require('posix.libgen')
8 local lfs = require('lfs')
9 local stdlib = require('posix.stdlib')
10 local unistd = require('posix.unistd')
11 local sys_wait = require('posix.sys.wait')
13 local curdate = os.date("%B %e, %Y")
15 local output_head <const> = ".\\\" DO NOT EDIT-- this file is @" .. [[generated by tools/build/opti…
117 local output_tail <const> = [[.El
139 local scriptdir <const> = libgen.dirname(stdlib.realpath(arg[0]))
140 local srcdir <const> = stdlib.realpath(scriptdir .. "/../../../")
141 local makesysdir <const> = srcdir .. "/share/mk"
143 local make_envvar = os.getenv("MAKE")
144 local make_cmd_override = {}
152 local function read_pipe(pipe)
153 local ret = ""
155 local buffer = assert(unistd.read(pipe, 1024))
160 local function run_make(args)
161 local cmd_args = {"env", "-i", "make", "-C", srcdir, "-m", makesysdir,
167 local val = make_cmd_override[k]
176 local r, w = assert(unistd.pipe())
177 local pid = assert(unistd.fork())
190 local output = read_pipe(r)
193 local _, exit_type, exit_code = assert(sys_wait.wait(pid))
202 local function native_target()
203 local output = run_make({"MK_AUTO_OBJ=NO", "-V", "MACHINE",
206 local arch, machine_arch
218 local function src_targets()
219 local targets = {}
222 local output = run_make({"MK_AUTO_OBJ=no", "targets"})
223 local curline = 0
228 local arch = line:match("[^%s]+/[^%s]+")
240 local function config_options(srcconf, env, take_dupes, linting)
244 local option_args = {".MAKE.MODE=normal", "showconfig",
251 local output = run_make(option_args)
253 local options = {}
254 local known_dupes = {}
256 local function warn_on_dupe(option, val)
270 local name = opt:match("MK_[%a%d_]+")
271 local val = opt:match("= .+"):sub(3)
285 local name = opt:match("OPT_[%a%d_]+")
286 local val = opt:match("= .+"):sub(3)
302 local function env_only_options()
303 local output = run_make({"MK_AUTO_OBJ=no", "-V", "__ENV_ONLY_OPTIONS"})
304 local options = {}
313 local function required_options()
314 local output = run_make({"-f", "share/mk/src.opts.mk", "-V",
316 local options = {}
325 local function config_description(option_name)
326 local fh = io.open(scriptdir .. "/" .. option_name)
327 local desc
343 local function config_descriptions(options)
344 local desc = {}
347 local basename = name:gsub("^MK_", "")
348 local with_name = "WITH_" .. basename
349 local without_name = "WITHOUT_" .. basename
354 local basename = name:gsub("^OPT_", "")
362 local function dependent_options(tmpdir, option_name, all_opts, omit_others)
363 local opt_sense = not not option_name:match("^WITH_")
364 local base_option_name = option_name:gsub("^[^_]+_", "")
365 local prefix = (opt_sense and "WITHOUT_") or "WITH_"
367 local srcconf = tmpdir .. "/src-" ..prefix .. "ALL_" ..
369 local fh = assert(io.open(srcconf, "w+"))
374 local base_opt = opt:gsub("^MK_", "")
377 local opt_prefix = (value and "WITH_") or "WITHOUT_"
384 local option_name_key = "MK_" .. base_option_name
385 local options = config_options(srcconf, nil, omit_others)
399 local function export_option_table(fd, name, options)
408 local function all_dependent_options(tmpdir, options, default_opts,
410 local all_enforced_options = {}
411 local all_effect_options = {}
412 local children = {}
415 local rfd, wfd = assert(unistd.pipe())
416 local pid = assert(unistd.fork())
421 local ret, errobj = pcall(function()
424 local compare_table
432 local enforced_options = dependent_options(tmpdir, name,
436 local effect_options = dependent_options(tmpdir, name,
461 local pid, status, exitcode = sys_wait.wait(-1)
467 local info = children[pid]
470 local name = info[1]
471 local rfd = info[2]
472 local buf = ''
473 local rbuf, sz
492 local child_env = {}
493 local res, err = pcall(load(buf, "child", "t", child_env))
503 local function get_defaults(target_archs, native_default_opts)
504 local target_defaults = {}
506 local different_defaults = {}
510 local native_copy = {}
518 local target = tgt:gsub("/.+$", "")
519 local target_arch = tgt:gsub("^.+/", "")
521 local target_opts = config_options(nil, {"TARGET=" .. target,
543 local val = opts["MK_ACPI"]
553 local function option_comparator(lhs, rhs)
557 local base_lhs = lhs:gsub("^[^_]+_", "")
558 local base_rhs = rhs:gsub("^[^_]+_", "")
567 local function main(tmpdir)
571 local env_only_opts <const> = env_only_options()
572 local default_opts = config_options(nil, nil, nil, true)
573 local opt_descriptions = config_descriptions(default_opts)
574 local srcconf_all <const> = tmpdir .. "/src-all-enabled.conf"
575 local fh = io.open(srcconf_all, "w+")
576 local all_targets = src_targets()
577 local target_defaults, different_defaults = get_defaults(all_targets,
579 local options = {}
580 local without_all_opts = {}
584 local base_name = name:gsub("^MK_", "")
585 local with_name = "WITH_" .. base_name
586 local without_name = "WITHOUT_" .. base_name
608 local with_all_opts = config_options(srcconf_all)
609 local all_enforced_options, all_effect_options
610 local all_required_options = required_options()
618 local value
624 local describe_option = name
640 local enforced_options = all_enforced_options[describe_option]
641 local effect_options = all_effect_options[describe_option]
647 local which_targets = {}
677 local sorted_dep_opt = {}
684 local dep_val = enforced_options[dep_opt]
685 local dep_prefix = (dep_val and "WITH_") or
687 local dep_name = dep_opt:gsub("^MK_",
719 local sorted_dep_opt = {}
726 local dep_val = effect_options[dep_opt]
727 local dep_prefix = (dep_val and "WITH_") or
729 local not_dep_prefix = ((not dep_val) and "WITH_") or
731 local dep_name = dep_opt:gsub("^MK_",
733 local not_dep_name = dep_opt:gsub("^MK_",
761 local desc = opt_descriptions[name]
775 local tmpdir = "/tmp/makeman." .. unistd.getpid()
782 local ret, errobj = pcall(main, tmpdir)