build: remove now-unneeded function from target_config_lib.lua
target_config.lua and target_config_check.lua don't pass a table of callbacks anymore, so target_config_lib.lua can by simplified by moving all the code that was in the returned function to the toplevel.
This commit is contained in:
		
							parent
							
								
									9e23534ec3
								
							
						
					
					
						commit
						3ce43329f5
					
				| @ -1,4 +1,4 @@ | ||||
| local lib = dofile('scripts/target_config_lib.lua')() | ||||
| local lib = dofile('scripts/target_config_lib.lua') | ||||
| 
 | ||||
| for _, config in pairs(lib.configs) do | ||||
| 	io.stdout:write(config:format(), '\n') | ||||
|  | ||||
| @ -24,7 +24,7 @@ local function check_config(config) | ||||
| end | ||||
| 
 | ||||
| 
 | ||||
| local lib = dofile('scripts/target_config_lib.lua')() | ||||
| local lib = dofile('scripts/target_config_lib.lua') | ||||
| 
 | ||||
| for _, config in pairs(lib.configs) do | ||||
| 	if config.required then | ||||
|  | ||||
| @ -1,3 +1,20 @@ | ||||
| local lib = dofile('scripts/target_lib.lua') | ||||
| local env = lib.env | ||||
| 
 | ||||
| local target = env.GLUON_TARGET | ||||
| 
 | ||||
| assert(target) | ||||
| assert(env.BOARD) | ||||
| assert(env.SUBTARGET) | ||||
| 
 | ||||
| local openwrt_config_target | ||||
| if env.SUBTARGET ~= '' then | ||||
| 	openwrt_config_target = env.BOARD .. '_' .. env.SUBTARGET | ||||
| else | ||||
| 	openwrt_config_target = env.BOARD | ||||
| end | ||||
| 
 | ||||
| 
 | ||||
| -- Split a string into words | ||||
| local function split(s) | ||||
| 	local ret = {} | ||||
| @ -40,154 +57,138 @@ local function compact_list(list, keep_neg) | ||||
| 	return ret | ||||
| end | ||||
| 
 | ||||
| return function() | ||||
| 	local lib = dofile('scripts/target_lib.lua') | ||||
| 	local env = lib.env | ||||
| 
 | ||||
| 	local target = env.GLUON_TARGET | ||||
| 
 | ||||
| 	assert(target) | ||||
| 	assert(env.BOARD) | ||||
| 	assert(env.SUBTARGET) | ||||
| 
 | ||||
| 	local openwrt_config_target | ||||
| 	if env.SUBTARGET ~= '' then | ||||
| 		openwrt_config_target = env.BOARD .. '_' .. env.SUBTARGET | ||||
| 	else | ||||
| 		openwrt_config_target = env.BOARD | ||||
| 	end | ||||
| 
 | ||||
| 
 | ||||
| 	local function site_vars(var) | ||||
| 		return lib.exec_capture_raw(string.format([[ | ||||
| 	MAKEFLAGS= make print _GLUON_SITE_VARS_=%s --no-print-directory -s -f - <<'END_MAKE' | ||||
| local function site_vars(var) | ||||
| 	return lib.exec_capture_raw(string.format( | ||||
| [[ | ||||
| MAKEFLAGS= make print _GLUON_SITE_VARS_=%s --no-print-directory -s -f - <<'END_MAKE' | ||||
| include $(GLUON_SITEDIR)/site.mk | ||||
| 
 | ||||
| print: | ||||
| 	echo -n '$(_GLUON_SITE_VARS_)' | ||||
| END_MAKE | ||||
| 		]], lib.escape(var))) | ||||
| ]], | ||||
| 	lib.escape(var))) | ||||
| end | ||||
| 
 | ||||
| local function site_packages(image) | ||||
| 	return split(site_vars(string.format('$(GLUON_%s_SITE_PACKAGES)', image))) | ||||
| end | ||||
| 
 | ||||
| -- TODO: Rewrite features.sh in Lua | ||||
| local function feature_packages(features) | ||||
| 	-- Ugly hack: Lua doesn't give us the return code of a popened | ||||
| 	-- command, so we match on a special __ERROR__ marker | ||||
| 	local pkgs = lib.exec_capture({'scripts/features.sh', features}, '|| echo __ERROR__') | ||||
| 	assert(string.find(pkgs, '__ERROR__') == nil, 'Error while evaluating features') | ||||
| 	return pkgs | ||||
| end | ||||
| 
 | ||||
| -- This involves running lots of processes to evaluate site.mk, so we | ||||
| -- add a simple cache | ||||
| local class_cache = {} | ||||
| local function class_packages(class) | ||||
| 	if class_cache[class] then | ||||
| 		return class_cache[class] | ||||
| 	end | ||||
| 
 | ||||
| 	local function site_packages(image) | ||||
| 		return split(site_vars(string.format('$(GLUON_%s_SITE_PACKAGES)', image))) | ||||
| 	end | ||||
| 	local features = site_vars(string.format('$(GLUON_FEATURES) $(GLUON_FEATURES_%s)', class)) | ||||
| 	features = table.concat(compact_list(split(features), false), ' ') | ||||
| 
 | ||||
| 	-- TODO: Rewrite features.sh in Lua | ||||
| 	local function feature_packages(features) | ||||
| 		-- Ugly hack: Lua doesn't give us the return code of a popened | ||||
| 		-- command, so we match on a special __ERROR__ marker | ||||
| 		local pkgs = lib.exec_capture({'scripts/features.sh', features}, '|| echo __ERROR__') | ||||
| 		assert(string.find(pkgs, '__ERROR__') == nil, 'Error while evaluating features') | ||||
| 		return pkgs | ||||
| 	end | ||||
| 	local pkgs = feature_packages(features) | ||||
| 	pkgs = pkgs .. ' ' .. site_vars(string.format('$(GLUON_SITE_PACKAGES) $(GLUON_SITE_PACKAGES_%s)', class)) | ||||
| 
 | ||||
| 	-- This involves running lots of processes to evaluate site.mk, so we | ||||
| 	-- add a simple cache | ||||
| 	local class_cache = {} | ||||
| 	local function class_packages(class) | ||||
| 		if class_cache[class] then | ||||
| 			return class_cache[class] | ||||
| 	pkgs = compact_list(split(pkgs)) | ||||
| 
 | ||||
| 	class_cache[class] = pkgs | ||||
| 	return pkgs | ||||
| end | ||||
| 
 | ||||
| local enabled_packages = {} | ||||
| -- Arguments: package name and config value (true: y, nil: m, false: unset) | ||||
| -- Ensures precedence of y > m > unset | ||||
| local function config_package(pkg, v) | ||||
| 	if v == false then | ||||
| 		if not enabled_packages[pkg] then | ||||
| 			lib.try_config('PACKAGE_' .. pkg, false) | ||||
| 		end | ||||
| 
 | ||||
| 		local features = site_vars(string.format('$(GLUON_FEATURES) $(GLUON_FEATURES_%s)', class)) | ||||
| 		features = table.concat(compact_list(split(features), false), ' ') | ||||
| 
 | ||||
| 		local pkgs = feature_packages(features) | ||||
| 		pkgs = pkgs .. ' ' .. site_vars(string.format('$(GLUON_SITE_PACKAGES) $(GLUON_SITE_PACKAGES_%s)', class)) | ||||
| 
 | ||||
| 		pkgs = compact_list(split(pkgs)) | ||||
| 
 | ||||
| 		class_cache[class] = pkgs | ||||
| 		return pkgs | ||||
| 		return | ||||
| 	end | ||||
| 
 | ||||
| 	local enabled_packages = {} | ||||
| 	-- Arguments: package name and config value (true: y, nil: m, false: unset) | ||||
| 	-- Ensures precedence of y > m > unset | ||||
| 	local function config_package(pkg, v) | ||||
| 		if v == false then | ||||
| 			if not enabled_packages[pkg] then | ||||
| 				lib.try_config('CONFIG_PACKAGE_' .. pkg, false) | ||||
| 			end | ||||
| 			return | ||||
| 		end | ||||
| 	if v == true or not enabled_packages[pkg] then | ||||
| 		lib.config('PACKAGE_' .. pkg, v, string.format("unable to enable package '%s'", pkg)) | ||||
| 		enabled_packages[pkg] = true | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| 		if v == true or not enabled_packages[pkg] then | ||||
| 			lib.config('CONFIG_PACKAGE_' .. pkg, v, string.format("unable to enable package '%s'", pkg)) | ||||
| 			enabled_packages[pkg] = true | ||||
| local function handle_target_pkgs(pkgs) | ||||
| 	for _, pkg in ipairs(pkgs) do | ||||
| 		if string.sub(pkg, 1, 1) == '-' then | ||||
| 			config_package(string.sub(pkg, 2), false) | ||||
| 		else | ||||
| 			config_package(pkg, true) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| 	local function handle_target_pkgs(pkgs) | ||||
| 		for _, pkg in ipairs(pkgs) do | ||||
| 			if string.sub(pkg, 1, 1) == '-' then | ||||
| 				config_package(string.sub(pkg, 2), false) | ||||
| 			else | ||||
| 				config_package(pkg, true) | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| lib.include('generic') | ||||
| lib.include(target) | ||||
| 
 | ||||
| 	lib.include('generic') | ||||
| 	lib.include(target) | ||||
| lib.check_devices() | ||||
| 
 | ||||
| 	lib.check_devices() | ||||
| if not lib.opkg then | ||||
| 	lib.config('SIGNED_PACKAGES', false) | ||||
| 	lib.config('CLEAN_IPKG', true) | ||||
| 	lib.packages {'-opkg'} | ||||
| end | ||||
| 
 | ||||
| 	if not lib.opkg then | ||||
| 		lib.config('CONFIG_SIGNED_PACKAGES', false) | ||||
| 		lib.config('CONFIG_CLEAN_IPKG', true) | ||||
| 		lib.packages {'-opkg'} | ||||
| 	end | ||||
| if #lib.devices > 0 then | ||||
| 	handle_target_pkgs(lib.target_packages) | ||||
| 
 | ||||
| 	if #lib.devices > 0 then | ||||
| 		handle_target_pkgs(lib.target_packages) | ||||
| 	for _, dev in ipairs(lib.devices) do | ||||
| 		local profile = dev.options.profile or dev.name | ||||
| 
 | ||||
| 		for _, dev in ipairs(lib.devices) do | ||||
| 			local profile = dev.options.profile or dev.name | ||||
| 
 | ||||
| 			local device_pkgs = {} | ||||
| 			local function handle_pkgs(pkgs) | ||||
| 				for _, pkg in ipairs(pkgs) do | ||||
| 					if string.sub(pkg, 1, 1) ~= '-' then | ||||
| 						config_package(pkg, nil) | ||||
| 					end | ||||
| 					device_pkgs = append_to_list(device_pkgs, pkg) | ||||
| 				end | ||||
| 			end | ||||
| 
 | ||||
| 			handle_pkgs(lib.target_packages) | ||||
| 			handle_pkgs(class_packages(dev.options.class)) | ||||
| 			handle_pkgs(dev.options.packages or {}) | ||||
| 			handle_pkgs(site_packages(dev.image)) | ||||
| 
 | ||||
| 			lib.config( | ||||
| 				string.format('CONFIG_TARGET_DEVICE_%s_DEVICE_%s', openwrt_config_target, profile), | ||||
| 				true, | ||||
| 				string.format("unable to enable device '%s'", profile) | ||||
| 			) | ||||
| 			lib.config( | ||||
| 				string.format('CONFIG_TARGET_DEVICE_PACKAGES_%s_DEVICE_%s', openwrt_config_target, profile), | ||||
| 				table.concat(device_pkgs, ' ') | ||||
| 			) | ||||
| 		end | ||||
| 	else | ||||
| 		-- x86 fallback: no devices | ||||
| 		local target_pkgs = {} | ||||
| 		local device_pkgs = {} | ||||
| 		local function handle_pkgs(pkgs) | ||||
| 			for _, pkg in ipairs(pkgs) do | ||||
| 				target_pkgs = append_to_list(target_pkgs, pkg) | ||||
| 				if string.sub(pkg, 1, 1) ~= '-' then | ||||
| 					config_package(pkg, nil) | ||||
| 				end | ||||
| 				device_pkgs = append_to_list(device_pkgs, pkg) | ||||
| 			end | ||||
| 		end | ||||
| 
 | ||||
| 		-- Just hardcode the class for device-less targets to 'standard' | ||||
| 		-- - this is x86 only at the moment, and it will have devices | ||||
| 		-- in OpenWrt 19.07 + 1 as well | ||||
| 		handle_pkgs(lib.target_packages) | ||||
| 		handle_pkgs(class_packages('standard')) | ||||
| 		handle_pkgs(class_packages(dev.options.class)) | ||||
| 		handle_pkgs(dev.options.packages or {}) | ||||
| 		handle_pkgs(site_packages(dev.image)) | ||||
| 
 | ||||
| 		handle_target_pkgs(target_pkgs) | ||||
| 		local profile_config = string.format('%s_DEVICE_%s', openwrt_config_target, profile) | ||||
| 		lib.config( | ||||
| 			'TARGET_DEVICE_' .. profile_config, true, | ||||
| 			string.format("unable to enable device '%s'", profile) | ||||
| 		) | ||||
| 		lib.config( | ||||
| 			'TARGET_DEVICE_PACKAGES_' .. profile_config, | ||||
| 			table.concat(device_pkgs, ' ') | ||||
| 		) | ||||
| 	end | ||||
| else | ||||
| 	-- x86 fallback: no devices | ||||
| 	local target_pkgs = {} | ||||
| 	local function handle_pkgs(pkgs) | ||||
| 		for _, pkg in ipairs(pkgs) do | ||||
| 			target_pkgs = append_to_list(target_pkgs, pkg) | ||||
| 		end | ||||
| 	end | ||||
| 
 | ||||
| 	return lib | ||||
| 	-- Just hardcode the class for device-less targets to 'standard' | ||||
| 	-- - this is x86 only at the moment, and it will have devices | ||||
| 	-- in OpenWrt 19.07 + 1 as well | ||||
| 	handle_pkgs(lib.target_packages) | ||||
| 	handle_pkgs(class_packages('standard')) | ||||
| 
 | ||||
| 	handle_target_pkgs(target_pkgs) | ||||
| end | ||||
| 
 | ||||
| return lib | ||||
|  | ||||
| @ -164,7 +164,7 @@ local function format_config(k, v) | ||||
| 	else | ||||
| 		format = '%s=%d' | ||||
| 	end | ||||
| 	return string.format(format, k, v) | ||||
| 	return string.format(format, 'CONFIG_' .. k, v) | ||||
| end | ||||
| 
 | ||||
| local config_mt = { | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| config('CONFIG_GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('CONFIG_TARGET_SQUASHFS_BLOCK_SIZE', 64) | ||||
| config('GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('TARGET_SQUASHFS_BLOCK_SIZE', 64) | ||||
| 
 | ||||
| local ATH10K_PACKAGES = { | ||||
| 	'kmod-ath10k', | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| config('CONFIG_GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('GLUON_SPECIALIZE_KERNEL', true) | ||||
| 
 | ||||
| defaults { | ||||
| 	factory = false, | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| config('CONFIG_GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('GLUON_SPECIALIZE_KERNEL', true) | ||||
| 
 | ||||
| local ATH10K_PACKAGES = {'kmod-ath10k', '-kmod-ath10k-ct', 'ath10k-firmware-qca988x', '-ath10k-firmware-qca988x-ct'} | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| config('CONFIG_GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('GLUON_SPECIALIZE_KERNEL', true) | ||||
| 
 | ||||
| no_opkg() | ||||
| 
 | ||||
|  | ||||
| @ -1,21 +1,21 @@ | ||||
| assert(env.GLUON_LANGS) | ||||
| 
 | ||||
| 
 | ||||
| config('CONFIG_GLUON_SITEDIR', env.GLUON_SITEDIR) | ||||
| config('CONFIG_GLUON_RELEASE', env.GLUON_RELEASE) | ||||
| try_config('CONFIG_GLUON_BRANCH', env.GLUON_BRANCH or '') | ||||
| config('GLUON_SITEDIR', env.GLUON_SITEDIR) | ||||
| config('GLUON_RELEASE', env.GLUON_RELEASE) | ||||
| try_config('GLUON_BRANCH', env.GLUON_BRANCH or '') | ||||
| 
 | ||||
| for lang in string.gmatch(env.GLUON_LANGS, '%S+') do | ||||
| 	try_config('CONFIG_GLUON_WEB_LANG_' .. lang, true) | ||||
| 	try_config('GLUON_WEB_LANG_' .. lang, true) | ||||
| end | ||||
| 
 | ||||
| config('CONFIG_TARGET_' .. env.BOARD, true) | ||||
| config('TARGET_' .. env.BOARD, true) | ||||
| if env.SUBTARGET ~= '' then | ||||
| 	config(string.format('CONFIG_TARGET_%s_%s', env.BOARD, env.SUBTARGET), true) | ||||
| 	config(string.format('TARGET_%s_%s', env.BOARD, env.SUBTARGET), true) | ||||
| end | ||||
| 
 | ||||
| -- Disable non-default feeds in distfeeds.conf | ||||
| config('CONFIG_FEED_gluon_base', false) | ||||
| config('FEED_gluon_base', false) | ||||
| 
 | ||||
| local default_feeds = {} | ||||
| for feed in string.gmatch(exec_capture_raw('. scripts/default_feeds.sh && echo "$DEFAULT_FEEDS"'), '%S+') do | ||||
| @ -24,46 +24,46 @@ end | ||||
| 
 | ||||
| for feed in string.gmatch(exec_capture_raw('. scripts/modules.sh && echo -n "$FEEDS"'), '%S+') do | ||||
| 	if not default_feeds[feed] then | ||||
| 		config('CONFIG_FEED_' .. feed, false) | ||||
| 		config('FEED_' .. feed, false) | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| 
 | ||||
| config('CONFIG_TARGET_ROOTFS_INITRAMFS', false) | ||||
| config('TARGET_ROOTFS_INITRAMFS', false) | ||||
| 
 | ||||
| config('CONFIG_DEVEL', true) | ||||
| config('CONFIG_ALL_NONSHARED', true) | ||||
| config('DEVEL', true) | ||||
| config('ALL_NONSHARED', true) | ||||
| 
 | ||||
| config('CONFIG_PACKAGE_usbip', false) -- fails to build | ||||
| config('CONFIG_PACKAGE_kmod-jool', false) -- fails to build | ||||
| config('PACKAGE_usbip', false) -- fails to build | ||||
| config('PACKAGE_kmod-jool', false) -- fails to build | ||||
| 
 | ||||
| config('CONFIG_BUSYBOX_CUSTOM', true) | ||||
| config('CONFIG_BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS', false) | ||||
| config('BUSYBOX_CUSTOM', true) | ||||
| config('BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS', false) | ||||
| 
 | ||||
| config('CONFIG_PACKAGE_ATH_DEBUG', true) | ||||
| config('PACKAGE_ATH_DEBUG', true) | ||||
| 
 | ||||
| try_config('CONFIG_TARGET_SQUASHFS_BLOCK_SIZE', 256) | ||||
| try_config('TARGET_SQUASHFS_BLOCK_SIZE', 256) | ||||
| 
 | ||||
| config('CONFIG_KERNEL_IP_MROUTE', false) | ||||
| config('CONFIG_KERNEL_IPV6_MROUTE', false) | ||||
| config('KERNEL_IP_MROUTE', false) | ||||
| config('KERNEL_IPV6_MROUTE', false) | ||||
| 
 | ||||
| try_config('CONFIG_TARGET_MULTI_PROFILE', true) | ||||
| try_config('CONFIG_TARGET_PER_DEVICE_ROOTFS', true) | ||||
| try_config('TARGET_MULTI_PROFILE', true) | ||||
| try_config('TARGET_PER_DEVICE_ROOTFS', true) | ||||
| 
 | ||||
| config('CONFIG_GLUON_MULTIDOMAIN', istrue(env.GLUON_MULTIDOMAIN)) | ||||
| config('GLUON_MULTIDOMAIN', istrue(env.GLUON_MULTIDOMAIN)) | ||||
| 
 | ||||
| config('CONFIG_AUTOREMOVE', istrue(env.GLUON_AUTOREMOVE)) | ||||
| config('AUTOREMOVE', istrue(env.GLUON_AUTOREMOVE)) | ||||
| 
 | ||||
| if istrue(env.GLUON_DEBUG) then | ||||
| 	config('CONFIG_DEBUG', true) | ||||
| 	config('CONFIG_NO_STRIP', true) | ||||
| 	config('CONFIG_USE_STRIP', false) | ||||
| 	config('CONFIG_USE_SSTRIP', false) | ||||
| 	config('DEBUG', true) | ||||
| 	config('NO_STRIP', true) | ||||
| 	config('USE_STRIP', false) | ||||
| 	config('USE_SSTRIP', false) | ||||
| 
 | ||||
| 	try_config('CONFIG_TARGET_ROOTFS_PARTSIZE', 500) | ||||
| 	try_config('TARGET_ROOTFS_PARTSIZE', 500) | ||||
| end | ||||
| 
 | ||||
| config('CONFIG_GLUON_MINIFY', istrue(env.GLUON_MINIFY)) | ||||
| config('GLUON_MINIFY', istrue(env.GLUON_MINIFY)) | ||||
| 
 | ||||
| packages { | ||||
| 	'-kmod-ipt-offload', | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| config('CONFIG_KERNEL_KALLSYMS', false) | ||||
| config('CONFIG_GLUON_SPECIALIZE_KERNEL', true) | ||||
| config('KERNEL_KALLSYMS', false) | ||||
| config('GLUON_SPECIALIZE_KERNEL', true) | ||||
| 
 | ||||
| no_opkg() | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| config('CONFIG_VDI_IMAGES', true) | ||||
| config('CONFIG_VMDK_IMAGES', true) | ||||
| config('VDI_IMAGES', true) | ||||
| config('VMDK_IMAGES', true) | ||||
| 
 | ||||
| packages { | ||||
| 	'kmod-3c59x', | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user