diff SConstruct @ 12:d60f1dab8469

Fixed resource path dependencies issue that caused PARPG to crash on start. * PARPG should now run without issue (system installation not tested). * Utilized FIFE's VFS module to remove path dependencies from most PARPG modules. * The new parpg.vfs module is a singleton with a single global variable, VFS, which is a reference to the global VFS instance. Although a singleton is not ideal it should be replaced once PARPG's core code is refactored. * The parpg.vfs singleton is initialized in the parpg.applicaiton.PARPGApplication class with the absolute path to the data directory via the parpg.settings module and corresponding configuration file. * A new DataPath entry was added to the default system configuration file template under the [parpg] section to support the new parpg.vfs module. * Updated the parpg-assets subrepo to revision 3 to fix some dialog file format issues (for details see commit message for parpg-assets). * Fixed a few bugs in the parpg.dialogueparsers.YAMLDialogueParser class related to exception handling.
author M. George Hansen <technopolitica@gmail.com>
date Mon, 06 Jun 2011 15:56:14 -1000
parents 4706e0194af3
children de378945b839
line wrap: on
line diff
--- a/SConstruct	Tue May 31 02:46:20 2011 -0700
+++ b/SConstruct	Mon Jun 06 15:56:14 2011 -1000
@@ -235,12 +235,6 @@
         is_abs_path,
     ),
     PathVariable(
-        'INCLUDE_DIR',
-        'directory where C/C++ header files should be installed',
-        INCLUDE_DIR_DEFAULT,
-        is_abs_path,
-    ),
-    PathVariable(
         'PY_HEADERS_DIR',
         'directory where Python.h can be found',
         PY_HEADERS_DIR_DEFAULT,
@@ -261,7 +255,7 @@
 python_version_tuple = platform.python_version_tuple()
 
 environment = Environment(
-    tools=['default', 'cpython', 'copyrecurse', 'textfile', 'packaging'],
+    tools=['default', 'cpython', 'textfile', 'packaging'],
     variables=variables,
     PROJECT_NAME='parpg',
     PROJECT_VERSION_MAJOR=0,
@@ -278,7 +272,7 @@
     PY_VERSION_LONG='${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.'
                     '${PY_VERSION_PATCH}',
     PY_LIB_NAME=PY_LIB_NAME,
-    BUILD_DIR='build',
+    BUILD_DIR=Dir('build'),
 )
 if environment['DEBUG']:
     if platform_name == 'Windows':
@@ -289,60 +283,79 @@
 
 Help(variables.GenerateHelpText(environment))
 
-config_dict = [('@{0}@'.format(key), environment.Dictionary()[key]) for key in
-               ('PREFIX', 'LIB_DIR', 'PY_PACKAGES_DIR', 'BIN_DIR',
-                'SYS_CONF_DIR', 'DATA_DIR', 'PYTHON')]
+local_config_dict = {
+    '@PREFIX@': '${BUILD_DIR.abspath}',
+    '@LIB_DIR@': '${BUILD_DIR.abspath}',
+    '@PY_PACKAGES_DIR@': '${BUILD_DIR.abspath}',
+    '@BIN_DIR@': '${BUILD_DIR.abspath}',
+    '@SYS_CONF_DIR@': '${BUILD_DIR.abspath}',
+    '@DATA_DIR@': '${BUILD_DIR.abspath}/data',
+    '@PYTHON@': '$PYTHON',
+}
+system_config_dict = [('@{0}@'.format(key), environment.Dictionary()[key]) for
+                      key in ('PREFIX', 'LIB_DIR', 'PY_PACKAGES_DIR',
+                              'BIN_DIR', 'SYS_CONF_DIR', 'DATA_DIR', 'PYTHON')]
 
-copy_py_packages = environment.Install(
+build_py_packages = environment.Install(
     '$BUILD_DIR',
     'src/parpg',
 )
-install_py_packages = environment.InstallPython(
+#build_py_packages = environment.InstallPython(
+#    '$BUILD_DIR/parpg',
+#    py_sources,
+#    PYTHON_COMPILE=GetOption('compile'),
+#)
+py_packages = environment.InstallPython(
     '$PY_PACKAGES_DIR',
-    copy_py_packages,
+    build_py_packages,
     PYTHON_COMPILE=GetOption('compile'),
 )
 
-copy_data = environment.CopyRecurse(
-    '$BUILD_DIR',
-    'data',
+data_subdirs = Glob('data/*')
+build_data = environment.Install(
+    '$BUILD_DIR/data',
+    data_subdirs,
 )
-
-subst_config_file = environment.Substfile(
+# FIXME M. George Hansen 2011-06-05: Chmod should make dirs 0755 and files
+#     0644.
+#environment.AddPostAction(build_data, Chmod(build_data, 0755))
+data = environment.Install(
+    '$DATA_DIR',
+    build_data,
+)
+build_config_file = environment.Substfile(
     '$BUILD_DIR/parpg.cfg',
     'parpg.cfg.in',
-    SUBST_DICT=config_dict,
+    SUBST_DICT=local_config_dict,
 )
-install_config_files = environment.InstallChmod(
-    '$SYS_CONF_DIR',
-    subst_config_file,
-    mode=0755,
+environment.AddPostAction(build_config_file, Chmod(build_config_file, 0644))
+config_file = environment.Substfile(
+    '$SYS_CONF_DIR/parpg.cfg',
+    'parpg.cfg.in',
+    SUBST_DICT=system_config_dict,
 )
-Requires(install_config_files, subst_config_file)
+environment.AddPostAction(config_file, Chmod(config_file, 0644))
 
 if platform_name == 'Windows':
+    launcher_source = 'parpg.bat'
     launcher_name = 'parpg.bat'
 else:
-    launcher_name = 'parpg.sh'
+    launcher_source = 'parpg.sh'
+    launcher_name = 'parpg'
 # FIXME M. George Hansen 2011-05-20: Do any other sequences need to be escaped?
-launcher = environment.SubstfileEscape(
-    'build/$LAUNCHER_NAME',
-    'bin/${LAUNCHER_NAME}.in',
+build_launcher = environment.SubstfileEscape(
+    '$BUILD_DIR/$LAUNCHER_SOURCE',
+    'bin/${LAUNCHER_SOURCE}.in',
+    LAUNCHER_SOURCE=launcher_source,
     LAUNCHER_NAME=launcher_name,
-    SUBST_DICT=config_dict,
+    SUBST_DICT=system_config_dict,
     ESCAPE_SEQUENCES={'\\': r'\\\\', '"': r'\\"'},
 )
-if platform_name == 'Windows':
-    install_launcher = environment.InstallExecutable(
-        '$BIN_DIR',
-        launcher,
-    )
-else:
-    # Remove the .sh suffix, since it isn't needed on unix platforms.
-    install_launcher = environment.InstallAs(
-        '$BIN_DIR/parpg',
-        launcher,
-    )
+environment.AddPostAction(build_launcher, Chmod(build_launcher, 0755))
+launcher = environment.InstallAs(
+    '$BIN_DIR/$LAUNCHER_NAME',
+    build_launcher,
+)
 
 # TODO M. George Hansen 2011-05-12: Implement package builder.
 #package = environment.Package(
@@ -355,9 +368,13 @@
 #    X_RPM_GROUP='Application/parpg',
 #)
 
-build = Alias('build', [launcher, subst_config_file, copy_py_packages,
-                        copy_data])
-install = Alias('install', [build, install_launcher, install_py_packages,
-                install_config_files])
+build = Alias(
+    'build',
+    [build_launcher, build_config_file, build_py_packages, build_data],
+)
+install = Alias(
+    'install',
+    [build, launcher, config_file, py_packages, data],
+)
 
 Default(build)