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…
114 local output_tail <const> = [[.El
136 local scriptdir <const> = libgen.dirname(stdlib.realpath(arg[0]))
137 local srcdir <const> = stdlib.realpath(scriptdir .. "/../../../")
138 local makesysdir <const> = srcdir .. "/share/mk"
140 local make_envvar = os.getenv("MAKE")
141 local make_cmd_override = {}
149 local function read_pipe(pipe)
150 local ret = ""
152 local buffer = assert(unistd.read(pipe, 1024))
157 local function run_make(args)
158 local cmd_args = {"env", "-i", "make", "-C", srcdir, "-m", makesysdir,
164 local val = make_cmd_override[k]
173 local r, w = assert(unistd.pipe())
174 local pid = assert(unistd.fork())
187 local output = read_pipe(r)
190 local _, exit_type, exit_code = assert(sys_wait.wait(pid))
196 local function native_target()
197 local output = run_make({"MK_AUTO_OBJ=NO", "-V", "MACHINE",
200 local arch, machine_arch
212 local function src_targets()
213 local targets = {}
216 local output = run_make({"MK_AUTO_OBJ=no", "targets"})
217 local curline = 0
222 local arch = line:match("[^%s]+/[^%s]+")
234 local function config_options(srcconf, env, take_dupes, linting)
238 local option_args = {".MAKE.MODE=normal", "showconfig",
245 local output = run_make(option_args)
247 local options = {}
248 local known_dupes = {}
250 local function warn_on_dupe(option, val)
264 local name = opt:match("MK_[%a%d_]+")
265 local val = opt:match("= .+"):sub(3)
279 local name = opt:match("OPT_[%a%d_]+")
280 local val = opt:match("= .+"):sub(3)
296 local function env_only_options()
297 local output = run_make({"MK_AUTO_OBJ=no", "-V", "__ENV_ONLY_OPTIONS"})
298 local options = {}
307 local function required_options()
308 local output = run_make({"-f", "share/mk/src.opts.mk", "-V",
310 local options = {}
319 local function config_description(option_name)
320 local fh = io.open(scriptdir .. "/" .. option_name)
321 local desc
337 local function config_descriptions(options)
338 local desc = {}
341 local basename = name:gsub("^MK_", "")
342 local with_name = "WITH_" .. basename
343 local without_name = "WITHOUT_" .. basename
348 local basename = name:gsub("^OPT_", "")
356 local function dependent_options(tmpdir, option_name, all_opts, omit_others)
357 local opt_sense = not not option_name:match("^WITH_")
358 local base_option_name = option_name:gsub("^[^_]+_", "")
359 local prefix = (opt_sense and "WITHOUT_") or "WITH_"
361 local srcconf = tmpdir .. "/src-" ..prefix .. "ALL_" ..
363 local fh = assert(io.open(srcconf, "w+"))
368 local base_opt = opt:gsub("^MK_", "")
371 local opt_prefix = (value and "WITH_") or "WITHOUT_"
378 local option_name_key = "MK_" .. base_option_name
379 local options = config_options(srcconf, nil, omit_others)
393 local function export_option_table(fd, name, options)
402 local function all_dependent_options(tmpdir, options, default_opts,
404 local all_enforced_options = {}
405 local all_effect_options = {}
406 local children = {}
409 local rfd, wfd = assert(unistd.pipe())
410 local pid = assert(unistd.fork())
415 local ret, errobj = pcall(function()
418 local compare_table
426 local enforced_options = dependent_options(tmpdir, name,
430 local effect_options = dependent_options(tmpdir, name,
455 local pid, status, exitcode = sys_wait.wait(-1)
461 local info = children[pid]
464 local name = info[1]
465 local rfd = info[2]
466 local buf = ''
467 local rbuf, sz
486 local child_env = {}
487 local res, err = pcall(load(buf, "child", "t", child_env))
497 local function get_defaults(target_archs, native_default_opts)
498 local target_defaults = {}
500 local different_defaults = {}
504 local native_copy = {}
512 local target = tgt:gsub("/.+$", "")
513 local target_arch = tgt:gsub("^.+/", "")
515 local target_opts = config_options(nil, {"TARGET=" .. target,
537 local val = opts["MK_ACPI"]
547 local function option_comparator(lhs, rhs)
551 local base_lhs = lhs:gsub("^[^_]+_", "")
552 local base_rhs = rhs:gsub("^[^_]+_", "")
561 local function main(tmpdir)
565 local env_only_opts <const> = env_only_options()
566 local default_opts = config_options(nil, nil, nil, true)
567 local opt_descriptions = config_descriptions(default_opts)
568 local srcconf_all <const> = tmpdir .. "/src-all-enabled.conf"
569 local fh = io.open(srcconf_all, "w+")
570 local all_targets = src_targets()
571 local target_defaults, different_defaults = get_defaults(all_targets,
573 local options = {}
574 local without_all_opts = {}
578 local base_name = name:gsub("^MK_", "")
579 local with_name = "WITH_" .. base_name
580 local without_name = "WITHOUT_" .. base_name
602 local with_all_opts = config_options(srcconf_all)
603 local all_enforced_options, all_effect_options
604 local all_required_options = required_options()
612 local value
618 local describe_option = name
634 local enforced_options = all_enforced_options[describe_option]
635 local effect_options = all_effect_options[describe_option]
641 local which_targets = {}
671 local sorted_dep_opt = {}
678 local dep_val = enforced_options[dep_opt]
679 local dep_prefix = (dep_val and "WITH_") or
681 local dep_name = dep_opt:gsub("^MK_",
713 local sorted_dep_opt = {}
720 local dep_val = effect_options[dep_opt]
721 local dep_prefix = (dep_val and "WITH_") or
723 local not_dep_prefix = ((not dep_val) and "WITH_") or
725 local dep_name = dep_opt:gsub("^MK_",
727 local not_dep_name = dep_opt:gsub("^MK_",
755 local desc = opt_descriptions[name]
769 local tmpdir = "/tmp/makeman." .. unistd.getpid()
776 local ret, errobj = pcall(main, tmpdir)