Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow target:on_config to be used for general configuration #5831

Closed
Raildex opened this issue Nov 15, 2024 · 5 comments
Closed

Allow target:on_config to be used for general configuration #5831

Raildex opened this issue Nov 15, 2024 · 5 comments

Comments

@Raildex
Copy link

Raildex commented Nov 15, 2024

Is your feature request related to a problem? Please describe.

We can use on_config("windows") and on_config("linux") to specify platform (and arch) specific configuration.

however, on_config() without a platform/arch is not called when one of the on_config matches

Describe the solution you'd like

I would like to have on_config without parameters to be used for general configuration:

target(foo)
	on_config(function(target) 
	-- general config here, gets executed for any plat/arch
	end)

	on_config("windows|x86",function(target) 

	-- win x86 here
	end)

	on_config("windows|x64",function(target) 

	-- win x64 here
	end)

	on_config("linux|x64",function(target) 
	-- linux x64 here
	end)

	on_config("linux|x86",function(target) 
	-- linux x86 here
	end)

target_end()

Describe alternatives you've considered

target(foo)

on_config(function(target) 

if(is_plat("windows")) then 
	if(is_arch("x64")) then
-- win x64 here
	elseif(is_arch("x86")) then
-- win x86 here
	end
elseif (is_plat("linux")) then
	if(is_arch("x64")) then
-- linux x64 here
	elseif(is_arch("x86")) then
-- linux x86 here
	end
end

-- general config here

end)

Additional context

No response

@waruqi
Copy link
Member

waruqi commented Nov 16, 2024

however, on_config() without a platform/arch is not called when one of the on_config matches

no, on_config is only for fallback, if no specific platform is matched, on_config without platform will be called.

for windows:

on_config("linux", ...)
on_config(...) -> called

for linux:

on_config("linux", ...) --> called
on_config(...) 

like this

if linux then
    -- on_config("linux")
elseif macosx then
    -- on_config("macosx")
else
    -- on_config
end

@Raildex
Copy link
Author

Raildex commented Nov 16, 2024

thats what i figured. would it be possible to add my desired behaviour or make an alternative ("before_config()") ?

I would like to avoid if-else chains

@waruqi
Copy link
Member

waruqi commented Nov 16, 2024

this? #5813

@Raildex
Copy link
Author

Raildex commented Nov 17, 2024

Can these functions be added for a target?

@waruqi
Copy link
Member

waruqi commented Nov 17, 2024

no, only for rule

@Raildex Raildex closed this as completed Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants