#!/usr/bin/env ascript

doBuild(dirNamePre:string, dirName:string):map = {
	dirOrg = fs.getcwd()
	if (dirNamePre != '') {
		dirName = path.join(dirNamePre, dirName)
	}
	argvOrg = sys.argv
	sys.argv = argvOrg.replace('install', 'install-root'):list
	fs.chdir(dirName)
	eval(parsestream('build.az'))
	sys.argv = argvOrg
	fs.chdir(dirOrg)
}
dirInfos = struct(dirName:string, builds[]:symbol) * [
	['Module_sample',		[`msc, `bcc, `gnuc]]
	['Module_csv',			[`msc, `bcc, `gnuc]]
	['Module_re',			[`msc, `bcc, `gnuc]]
	['Module_sqlite3',		[`msc, `bcc, `gnuc]]
	['Module_xml',			[`msc, `bcc, `gnuc]]
	['Module_yaml',			[`msc, `bcc, `gnuc]]
//	['Module_mysql',		[`msc, `bcc, `gnuc]]
//	['Module_postgresql',	[`msc, `bcc, `gnuc]]
	['Module_sdl',			[`msc, `bcc, `gnuc]]
	['Module_cairo',		[`msc, `bcc, `gnuc]]
	['Module_opengl',		[`msc, `bcc, `gnuc]]
	['Module_glu',			[`msc, `bcc, `gnuc]]
	['Module_bmp',			[`msc, `bcc, `gnuc]]
	['Module_ppm',			[`msc, `bcc, `gnuc]]
	['Module_msicon',		[`msc, `bcc, `gnuc]]
	['Module_jpeg',			[`msc, `bcc, `gnuc]]
	['Module_png',			[`msc, `bcc, `gnuc]]
	['Module_gif',			[`msc, `bcc, `gnuc]]
	['Module_tiff',			[`msc, `bcc, `gnuc]]
	['Module_freetype',		[`msc, `bcc, `gnuc]]
	['Module_tcl',			[`msc, `bcc, `gnuc]]
	['Module_hash',			[`msc, `bcc, `gnuc]]
	['Module_gzip',			[`msc, `bcc, `gnuc]]
	['Module_bzip2',		[`msc, `bcc, `gnuc]]
	['Module_zipfile',		[`msc, `bcc, `gnuc]]
	['Module_tar',			[`msc, `bcc, `gnuc]]
	['Module_net_http',		[`msc, `bcc, `gnuc]]
	['Module_uuid',			[`msc, `bcc, `gnuc]]
	['Module_canvas',		[`msc, `bcc]]
	['Module_win32ole',		[`msc, `bcc]]
]
dirNames = dirInfos.filter(dirInfos:*builds:*iscontain(sys.build))::dirName
doBuild(path.dirname(sys.argv[0]), dirNames)
