Skip to content

Entirely generated configfiles? #6449

Open
@nwf

Description

@nwf

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

I find myself wanting to generate some configfiles entirely in Lua. At the moment, I am doing this with a series of single-line configfiles each mentioning single variables (${thing1}, ${thing2}, and so on) and having the target use those:

target("foo")
	set_kind("phony")
	set_default(false)

	add_imports("core.base.json")

	on_load(function (target)
		import("core.project.config")
		-- compute some things from config and by reading some JSON files
		-- and store the results with target:set().
	end)

	add_configfiles("thing1.in", { filename = "thing1" })
	add_configfiles("thing2.in", { filename = "thing2" })

	on_config(function(target)
		-- compute some things from target:get("...") properties

		target:set("configvar", "thing1", --[[ ... --]])
		target:set("configvar", "thing2", --[[ ... --]])
	end)

All the state tracking in maybe_copyfiles is really nice, and later stages rerunning their build and link steps based on changes in config files just works.

Describe the solution you'd like

I'd prefer to use a callback with add_configfiles that didn't need a source file and had access to the target

add_configfiles(nil, { filename = "thing1",
  generator = function(target) return target:get(--[[ ... --]]) end
})

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions