nitc :: MPackage :: gen_makefile
private fun gen_makefile(model: Model, mainmodule: MModule): nullable String do
var filter = new ModelFilter(accept_example = false, accept_test = false)
var pkg_path = package_path.as(not null)
var makefile_path = makefile_path.as(not null)
var bins = new Array[String]
var cmd_bin = new CmdMains(model, filter, mentity = self)
var res_bin = cmd_bin.init_command
if res_bin isa CmdSuccess then
for mmodule in cmd_bin.results.as(not null) do
if not mmodule isa MModule then continue
var mmodule_makefile = mmodule.makefile_path
if mmodule_makefile != null and mmodule_makefile != makefile_path then continue
var file = mmodule.location.file
if file == null then continue
# Remove package path prefix
var bin_path = file.filename
if pkg_path.has_suffix("/") then
bin_path = bin_path.replace(pkg_path, "")
else
bin_path = bin_path.replace("{pkg_path}/", "")
end
bins.add bin_path
end
end
if bins.is_empty then return null
var make = new NitMakefile(bins)
make.render.write_to_file(makefile_path)
return makefile_path
end
src/nitpackage.nit:346,2--379,4