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))
199 local function native_target()
200 local output = run_make({"MK_AUTO_OBJ=NO", "-V", "MACHINE",
203 local arch, machine_arch
215 local function src_targets()
216 local targets = {}
219 local output = run_make({"MK_AUTO_OBJ=no", "targets"})
220 local curline = 0
225 local arch = line:match("[^%s]+/[^%s]+")
237 local function config_options(srcconf, env, take_dupes, linting)
241 local option_args = {".MAKE.MODE=normal", "showconfig",
248 local output = run_make(option_args)
250 local options = {}
251 local known_dupes = {}
253 local function warn_on_dupe(option, val)
267 local name = opt:match("MK_[%a%d_]+")
268 local val = opt:match("= .+"):sub(3)
282 local name = opt:match("OPT_[%a%d_]+")
283 local val = opt:match("= .+"):sub(3)
299 local function env_only_options()
300 local output = run_make({"MK_AUTO_OBJ=no", "-V", "__ENV_ONLY_OPTIONS"})
301 local options = {}
310 local function required_options()
311 local output = run_make({"-f", "share/mk/src.opts.mk", "-V",
313 local options = {}
322 local function config_description(option_name)
323 local fh = io.open(scriptdir .. "/" .. option_name)
324 local desc
340 local function config_descriptions(options)
341 local desc = {}
344 local basename = name:gsub("^MK_", "")
345 local with_name = "WITH_" .. basename
346 local without_name = "WITHOUT_" .. basename
351 local basename = name:gsub("^OPT_", "")
359 local function dependent_options(tmpdir, option_name, all_opts, omit_others)
360 local opt_sense = not not option_name:match("^WITH_")
361 local base_option_name = option_name:gsub("^[^_]+_", "")
362 local prefix = (opt_sense and "WITHOUT_") or "WITH_"
364 local srcconf = tmpdir .. "/src-" ..prefix .. "ALL_" ..
366 local fh = assert(io.open(srcconf, "w+"))
371 local base_opt = opt:gsub("^MK_", "")
374 local opt_prefix = (value and "WITH_") or "WITHOUT_"
381 local option_name_key = "MK_" .. base_option_name
382 local options = config_options(srcconf, nil, omit_others)
396 local function export_option_table(fd, name, options)
405 local function all_dependent_options(tmpdir, options, default_opts,
407 local all_enforced_options = {}
408 local all_effect_options = {}
409 local children = {}
412 local rfd, wfd = assert(unistd.pipe())
413 local pid = assert(unistd.fork())
418 local ret, errobj = pcall(function()
421 local compare_table
429 local enforced_options = dependent_options(tmpdir, name,
433 local effect_options = dependent_options(tmpdir, name,
458 local pid, status, exitcode = sys_wait.wait(-1)
464 local info = children[pid]
467 local name = info[1]
468 local rfd = info[2]
469 local buf = ''
470 local rbuf, sz
489 local child_env = {}
490 local res, err = pcall(load(buf, "child", "t", child_env))
500 local function get_defaults(target_archs, native_default_opts)
501 local target_defaults = {}
503 local different_defaults = {}
507 local native_copy = {}
515 local target = tgt:gsub("/.+$", "")
516 local target_arch = tgt:gsub("^.+/", "")
518 local target_opts = config_options(nil, {"TARGET=" .. target,
540 local val = opts["MK_ACPI"]
550 local function option_comparator(lhs, rhs)
554 local base_lhs = lhs:gsub("^[^_]+_", "")
555 local base_rhs = rhs:gsub("^[^_]+_", "")
564 local function main(tmpdir)
568 local env_only_opts <const> = env_only_options()
569 local default_opts = config_options(nil, nil, nil, true)
570 local opt_descriptions = config_descriptions(default_opts)
571 local srcconf_all <const> = tmpdir .. "/src-all-enabled.conf"
572 local fh = io.open(srcconf_all, "w+")
573 local all_targets = src_targets()
574 local target_defaults, different_defaults = get_defaults(all_targets,
576 local options = {}
577 local without_all_opts = {}
581 local base_name = name:gsub("^MK_", "")
582 local with_name = "WITH_" .. base_name
583 local without_name = "WITHOUT_" .. base_name
605 local with_all_opts = config_options(srcconf_all)
606 local all_enforced_options, all_effect_options
607 local all_required_options = required_options()
615 local value
621 local describe_option = name
637 local enforced_options = all_enforced_options[describe_option]
638 local effect_options = all_effect_options[describe_option]
644 local which_targets = {}
674 local sorted_dep_opt = {}
681 local dep_val = enforced_options[dep_opt]
682 local dep_prefix = (dep_val and "WITH_") or
684 local dep_name = dep_opt:gsub("^MK_",
716 local sorted_dep_opt = {}
723 local dep_val = effect_options[dep_opt]
724 local dep_prefix = (dep_val and "WITH_") or
726 local not_dep_prefix = ((not dep_val) and "WITH_") or
728 local dep_name = dep_opt:gsub("^MK_",
730 local not_dep_name = dep_opt:gsub("^MK_",
758 local desc = opt_descriptions[name]
772 local tmpdir = "/tmp/makeman." .. unistd.getpid()
779 local ret, errobj = pcall(main, tmpdir)