aboutsummaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-06-02 22:43:24 +0000
committerdos-reis <gdr@axiomatics.org>2011-06-02 22:43:24 +0000
commit761e0f5d002dc199db16b996aafa60d6df6afcd7 (patch)
tree93803c5c05f8b80a5b2c767f07d91a30d63f8f21 /src/driver
parent10634545f2faf10699a1a8214ded2da3a6ea3d52 (diff)
downloadopen-axiom-761e0f5d002dc199db16b996aafa60d6df6afcd7.tar.gz
consolidate utility codes
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/Makefile.in6
-rw-r--r--src/driver/main.cc2
-rw-r--r--src/driver/utils.cc21
-rw-r--r--src/driver/utils.h111
4 files changed, 22 insertions, 118 deletions
diff --git a/src/driver/Makefile.in b/src/driver/Makefile.in
index b590c513..5ad25526 100644
--- a/src/driver/Makefile.in
+++ b/src/driver/Makefile.in
@@ -38,6 +38,8 @@ open_axiom_objects = $(open_axiom_SOURCES:.cc=.lo)
open_axiom_LDADD = -L$(builddir)/../lib $(oa_c_libs)
+VPATH += $(top_srcdir)/src/include
+
.PHONY: all all-ax all-driver
all: all-ax
@@ -57,8 +59,8 @@ stamp: $(bin_PROGRAMS)
-DOPENAXIOM_ROOT_DIRECTORY="\"$(open_axiom_installdir)\"" \
$(axiom_includes) $<
-utils.lo: utils.h
-main.lo: utils.h
+utils.lo: open-axiom.h
+main.lo: open-axiom.h
open-axiom$(EXEEXT): $(open_axiom_objects)
$(CXXLINK) -o $@ $(open_axiom_objects) $(open_axiom_LDADD)
diff --git a/src/driver/main.cc b/src/driver/main.cc
index 1436d42c..2621e1be 100644
--- a/src/driver/main.cc
+++ b/src/driver/main.cc
@@ -44,7 +44,7 @@
#include <locale.h>
#include "cfuns.h"
-#include "utils.h"
+#include "open-axiom.h"
#define OPENAXIOM_GLOBAL_ENV "AXIOM"
diff --git a/src/driver/utils.cc b/src/driver/utils.cc
index 9bffe781..498e2f4e 100644
--- a/src/driver/utils.cc
+++ b/src/driver/utils.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2008-2010, Gabriel Dos Reis.
+ Copyright (C) 2008-2011, Gabriel Dos Reis.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
-#include "utils.h"
+#include "open-axiom.h"
namespace OpenAxiom {
@@ -53,6 +53,12 @@ namespace OpenAxiom {
#define OPENAXIOM_CORE_PATH \
"/bin/" OPENAXIOM_CORE_EXECUTABLE
+#define OPENAXIOM_GUI_SUBPATH \
+ "/bin/" OPENAXIOM_GUI_EXECUTABLE
+
+#define OPENAXIOM_GUI_EXECUTABLE \
+ "gui" OPENAXIOM_EXEEXT
+
/* Path to the session manager, relative to OPENAXIOM_ROOT_DIRECTORY,
or to the system root directory as specified on command line. */
#define OPENAXIOM_SMAN_PATH \
@@ -144,12 +150,15 @@ get_systemdir(int argc, char* argv[])
/* Return the path to `driver'. */
static const char*
-get_driver_name(Driver driver)
+get_driver_subpath(Driver driver)
{
switch (driver) {
case sman_driver:
return OPENAXIOM_SMAN_PATH;
+ case gui_driver:
+ return OPENAXIOM_GUI_SUBPATH;
+
case script_driver:
case compiler_driver:
case core_driver:
@@ -168,7 +177,7 @@ const char*
make_path_for(const char* prefix, Driver driver)
{
const int prefix_length = strlen(prefix);
- const char* prog = get_driver_name(driver);
+ const char* prog = get_driver_subpath(driver);
char* execpath = (char*) malloc(prefix_length + strlen(prog) + 1);
strcpy(execpath, prefix);
strcpy(execpath + prefix_length, prog);
@@ -183,6 +192,7 @@ build_rts_options(Command* command, Driver driver)
switch (driver) {
case config_driver:
case sman_driver:
+ case gui_driver:
case execute_driver:
case unknown_driver:
break;
@@ -241,6 +251,8 @@ build_rts_options(Command* command, Driver driver)
#if OPENAXIOM_USE_SMAN
# define OPENAXIOM_DEFAULT_DRIVER sman_driver
+#elif OPENAXIOM_USE_GUI
+# define OPENAXIOM_DEFAULT_DRIVER gui_driver
#else
# define OPENAXIOM_DEFAULT_DRIVER core_driver
#endif
@@ -389,6 +401,7 @@ preprocess_arguments(Command* command, int argc, char** argv)
switch (driver) {
case unknown_driver:
case sman_driver:
+ case gui_driver:
command->core.argc += 1;
command->core.argv =
(char**) malloc((other + 2) * sizeof(char*));
diff --git a/src/driver/utils.h b/src/driver/utils.h
deleted file mode 100644
index be31d208..00000000
--- a/src/driver/utils.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- Copyright (C) 2008-2010, Gabriel Dos Reis.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of The Numerical ALgorithms Group Ltd. nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef OPENAXIOM_UTILS_INCLUDED
-#define OPENAXIOM_UTILS_INCLUDED
-
-#include "open-axiom.h"
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef __WIN32__
-# include <windows.h>
-#endif
-
-#include <vector>
-
-namespace OpenAxiom {
- // A list of drivers for OpenAxiom.
- enum Driver {
- unknown_driver, // unknown driver
- null_driver, // do nothing
- config_driver, // print out configuration information
- sman_driver, // start Superman as master process
- core_driver, // start the core system as master process
- script_driver, // start the core system in script mode.
- compiler_driver, // start the core system in compiler mode.
- execute_driver, // Execute a command.
- translator_driver, // Start the core system in translator mode.
- linker_driver // start the core system in linking mode.
- };
-
- // A list of runtime support systems for OpenAxiom.
- enum Runtime {
- unknown_runtime,
- gcl_runtime, // GCL-based runtime
- sbcl_runtime, // SBCL-based runtime
- clisp_runtime, // CLISP-based runtime
- ecl_runtime, // ECL-based runtime
- clozure_runtime, // Clozure CL-based runtime
- bemol_runtime // Bemol-based runtime
- };
-
- // Command line arguments.
- // When non empty, this vector really is of length one more than
- // what size() reports, as it is always null-terminated, to comply
- // with POSIX-style operating system requirements.
- struct Arguments : std::vector<char*> {
- explicit Arguments(int n = 0);
- int size() const;
- void allocate(int);
- char* const* data() const;
- };
-
- // A description of external command to be executed.
- struct Command {
- Process core; // arguments for actual executable.
- Arguments rt_args; // arguments to the base RT, if any.
- const char* root_dir; // path to the OpenAxiom system.
- const char* exec_path; // path to the program to execute.
- Command();
- };
-
- const char* get_systemdir(int argc, char*[]);
- const char* make_path_for(const char*, Driver);
-
- // Return a pointer the string value associated with an option.
- const char* option_value(const Command*, const char*);
-
- int execute_core(const Command*, Driver);
- void build_rts_options(Command*, Driver);
-
- Driver preprocess_arguments(Command*, int, char**);
-
- // Return the length of an array literal.
- template<typename T, int N>
- inline int length(T(&)[N]) {
- return N;
- }
-}
-
-#endif /* OPENAXIOM_UTILS_INCLUDED */