;;======================================================================
;; Copyright 2006-2016, Matthew Welland.
;; 
;; This file is part of Megatest.
;; 
;;     Megatest is free software: you can redistribute it and/or modify
;;     it under the terms of the GNU General Public License as published by
;;     the Free Software Foundation, either version 3 of the License, or
;;     (at your option) any later version.
;; 
;;     Megatest is distributed in the hope that it will be useful,
;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;     GNU General Public License for more details.
;; 
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.
;;
;;======================================================================

(declare (uses mtargs))
(declare (uses mtargs.import))
(declare (uses debugprint))
(declare (uses debugprint.import))
(declare (uses cookie))
(declare (uses cookie.import))
(declare (uses stml2))
(declare (uses stml2.import))
(declare (uses commonmod))
(declare (uses commonmod.import))
(declare (uses processmod))
(declare (uses processmod.import))
(declare (uses configfmod))
(declare (uses configfmod.import))
(declare (uses mtmod))
(declare (uses mtmod.import))
(declare (uses dbfile))
(declare (uses dbfile.import))
(declare (uses dbmod))
(declare (uses dbmod.import))
(declare (uses portlogger))
(declare (uses portlogger.import))
(declare (uses tcp-transportmod))
(declare (uses tcp-transportmod.import))
(declare (uses servermod))
(declare (uses servermod.import))
(declare (uses fsmod))
(declare (uses fsmod.import))
(declare (uses megatestmod))
(declare (uses megatestmod.import))
(declare (uses apimod))
(declare (uses apimod.import))
(declare (uses rmtmod))
(declare (uses rmtmod.import))
(declare (uses pgdb))
(declare (uses pgdb.import))
(declare (uses tasksmod))
(declare (uses tasksmod.import))
(declare (uses testsmod))
(declare (uses testsmod.import))
(declare (uses subrunmod))
(declare (uses subrunmod.import))
(declare (uses archivemod))
(declare (uses archivemod.import))
(declare (uses runsmod))
(declare (uses runsmod.import))
(declare (uses launchmod))
(declare (uses launchmod.import))

(declare (uses dcommon))
(declare (uses vgmod))

(use format)

(require-library iup)
(import (prefix iup iup:))

(use canvas-draw)
(import canvas-draw-iup
	(prefix sqlite3 sqlite3:))

(use ducttape-lib)
(use sqlite3 srfi-1 posix regex regex-case srfi-69 typed-records sparse-vectors) ;; defstruct

(import commonmod
	configfmod
	processmod
	(prefix mtargs args:)
	dbmod
	dbfile
	rmtmod
	debugprint
	stml2
	megatestmod
	tasksmod
	runsmod
	testsmod
	vgmod
	dcommon
	)

(include "common_records.scm")
(include "run_records.scm")
(include "megatest-fossil-hash.scm")

;; set some parameters here - these need to be put in something that can be loaded from other
;; executables such as dashboard and mtutil
;;
(include "dashboard-transport-mode.scm")
(dbfile:db-init-proc db:initialize-main-db)
(set! rmtmod:send-receive rmt:send-receive)

;; remove when configf fully modularized
(read-config-set! configf:read-file)

(debug:print-info 0 *default-log-port* "transport-mode="(rmt:transport-mode))

(dcommon-main)

(if (args:get-arg "-repl")
    (repl)
    (main))

