Property definitions

nitc $ NitPackagePhase :: defaultinit
private class NitPackagePhase
	super Phase

	redef fun process_mainmodule(mainmodule, mmodules) do
		var mpackages = extract_mpackages(mmodules)
		for mpackage in mpackages do

			# Fictive and buggy packages are ignored
			if not mpackage.has_source then
				toolcontext.warning(mpackage.location, "no-source",
					"Warning: `{mpackage}` has no source file")
				continue
			end

			# Check package INI files
			if toolcontext.opt_check_ini.value then
				mpackage.check_ini(toolcontext)
				continue
			end

			# Check package Makefiles
			if toolcontext.opt_check_makefile.value then
				mpackage.check_makefile(toolcontext, mainmodule)
				continue
			end

			# Check manpages
			if toolcontext.opt_check_man.value then
				mpackage.check_man(toolcontext, mainmodule)
				continue
			end

			# Check README.md
			if toolcontext.opt_check_readme.value then
				mpackage.check_readme(toolcontext)
				continue
			end

			# Expand packages
			if toolcontext.opt_expand.value and not mpackage.is_expanded then
				var path = mpackage.expand
				toolcontext.info("{mpackage} moved to {path}", 0)
			end
			if not mpackage.is_expanded then
				toolcontext.warning(mpackage.location, "no-dir",
					"Warning: `{mpackage}` has no package directory")
				continue
			end

			# Create INI file
			if toolcontext.opt_gen_ini.value then
				if not mpackage.has_ini or toolcontext.opt_force.value then
					var path = mpackage.gen_ini
					toolcontext.info("generated INI file `{path}`", 0)
				end
			end

			# Create Makefile
			if toolcontext.opt_gen_makefile.value then
				if not mpackage.has_makefile or toolcontext.opt_force.value then
					var path = mpackage.gen_makefile(toolcontext.modelbuilder.model, mainmodule)
					if path != null then
						toolcontext.info("generated Makefile `{path}`", 0)
					end
				end
			end

			# Create manpages
			if toolcontext.opt_gen_man.value then
				mpackage.gen_man(toolcontext, mainmodule)
			end
		end
	end

	# Extract the list of packages from the mmodules passed as arguments
	fun extract_mpackages(mmodules: Collection[MModule]): Collection[MPackage] do
		var mpackages = new ArraySet[MPackage]
		for mmodule in mmodules do
			var mpackage = mmodule.mpackage
			if mpackage == null then continue
			mpackages.add mpackage
		end
		return mpackages.to_a
	end
end
src/nitpackage.nit:63,1--147,3