Skip to content

Commit

Permalink
Scons update, python 3 support, OSX and Windows build fixes
Browse files Browse the repository at this point in the history
- Python 3 porting
  - Merged in pull request pr327 that updated scons to 3.1.2,
    changes all print calls to python 3 format and made the
    byte->string conversions needed for linux compilation
  - Added some more byte->string comparison (main and java
    scons scripts)
  - Conversion of python 3 filter objects to lists (main scons
    script)
  - Further updated to scons 4.0.1.  Removed all earlier versions
    of scons.
- Should now always build python 3 bindings, even on OSX.
- Windows fixes
  - Windows batch file no longer uses Windows registry to find
    python. The old method was finding python that was installed
    via Windows app installer instead of the one installed by
    Visual Studio that has the lib/includes it needs. New batch
    file now uses the first result returned from 'where python'.
    FYI, this code only runs first time batch script runs. Delete
    user-env.bat to force it to find python again.There seems to
    be a lot of different ways that python may be installed, so
    this could use some more testing.
	- Windows batch file should now be able to handle spaces in
	file names
	- Removed /nowarn:4503 flag on Windows
	- Tcl plugin now compiles again.  Changed it so that that
	  script looks for tcl86t.lib instead of tcl86.lib
- OSX fixes
	- No longer sets lib_path and include path using
	  DYLD_LIBRARY_PATH and CPATH because they are no longer
	  available due to SIP (System Integrity Protection)
	- Debugger will now compile again.  No longer links to JavaVM
	  framework. It wasn't able to find it before and seems to
	  compile fine without that option.
	- No longer builds SVS viewer.  OpenGL library that it uses
	  no longer compiles on OSX and needs to be updated.
  • Loading branch information
mazina committed Nov 18, 2020
1 parent 9bec6c9 commit 05a8474
Show file tree
Hide file tree
Showing 1,533 changed files with 417,199 additions and 8,384 deletions.
6 changes: 3 additions & 3 deletions Core/ClientSMLSWIG/CSharp/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_headers(d):

Import("env", "compiler")
if env.WhereIs('csc') == None:
print 'C# compiler not found, not building C# SML wrappers'
print('C# compiler not found, not building C# SML wrappers')
Return()

clone = env.Clone()
Expand All @@ -30,7 +30,7 @@ fake_target = '#fake-csharp-target'
# adapted from http://scons.org/wiki/DynamicSourceGenerator
def late_csharp_builder(target, source, env):
if not os.path.isdir(srcdir):
print 'source directory does not exist'
print('source directory does not exist')
sys.exit(1)

cs_srcs = [ os.path.join(srcdir, f) for f in os.listdir(srcdir) ]
Expand Down Expand Up @@ -61,4 +61,4 @@ shlib = clone.SharedLibrary(name, wrapper)[:1] # [:1] to throw away .exp and .l
env.Alias(sml_csharp_target, clone.Install(clone['OUT_DIR'], shlib))

env.Depends(shlib, clone.LateCSharpBuilder(fake_target, None))
clone.Clean(wrapper, [srcdir, assembly])
clone.Clean(wrapper, [srcdir, assembly])
15 changes: 9 additions & 6 deletions Core/ClientSMLSWIG/Java/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Project: Soar <http://soar.googlecode.com>
# Author: Jonathan Voigt <[email protected]>
#

from __future__ import print_function

import os
import sys
import itertools
Expand All @@ -17,10 +20,10 @@ def ConfigureJNI(env):
# /urs/libexec/java_home will give us
try:
p = subprocess.Popen(['/usr/libexec/java_home'], stdout = subprocess.PIPE)
base = p.stdout.readline().split()[-1]
base = p.stdout.readline().split()[-1].decode()
p.wait()
except OSError:
print >>sys.stderr, 'Error running /usr/libexec/java_home to get java home'
print('Error running /usr/libexec/java_home to get java home', file=sys.stderr)
Exit(1)
if (not os.path.exists(base)):
base = '/System/Library/Frameworks/JavaVM.framework'
Expand All @@ -35,7 +38,7 @@ def ConfigureJNI(env):
base = os.path.split(jcdir)[0]

if sys.platform == 'darwin':
print 'Looking for Mac headers at ', os.path.join(base, 'include')
print('Looking for Mac headers at ', os.path.join(base, 'include'))
if os.path.exists(os.path.join(base, 'include')):
# JDK 7+
headers = [os.path.join(base, 'include')]
Expand Down Expand Up @@ -64,9 +67,9 @@ def get_headers(d):
Import('env', 'compiler')
config = ConfigureJNI(env)
if config == None:
print "Could not configure Java. If you know where java is on your system,"
print "set environment variable JAVA_HOME to point to the directory containing"
print "the Java include, bin, and lib directories."
print("Could not configure Java. If you know where java is on your system,")
print("set environment variable JAVA_HOME to point to the directory containing")
print("the Java include, bin, and lib directories.")
Return()

clone = env.Clone()
Expand Down
2 changes: 1 addition & 1 deletion Core/ClientSMLSWIG/Python/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ print(tuple([{}]));
""".format(", ".join(commands))

lib_install_dir = clone['OUT_DIR']
inc_path, lib_path, pylib = literal_eval(check_output((python_exe, "-c", command)))
inc_path, lib_path, pylib = literal_eval(check_output((python_exe, "-c", command)).decode())

if isinstance(lib_path, list):
lib_path = lib_path[0]
Expand Down
10 changes: 5 additions & 5 deletions Core/ClientSMLSWIG/Tcl/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ if sys.platform == 'win32':
tcl_libs = clone.Dir(os.path.join(tcl_platform_dir, 'lib'))
tcl_headers = clone.Dir(os.path.join(tcl_platform_dir, 'include'))
tcl_bins = clone.Dir(os.path.join(tcl_platform_dir, 'bin'))
tcl_libname = 'tcl86.lib'
tcl_lib = 'tcl86'
tcl_libname = 'tcl86t.lib'
tcl_lib = 'tcl86t'
tcl_shname = 'tclsh86'
tcl_pkgindex_name = 'pkgIndex_win.tcl'
elif sys.platform == 'darwin':
Expand Down Expand Up @@ -65,10 +65,10 @@ else:
if ((not tcl_libs.exists()) or (not tcl_headers.exists()) or
(not File(os.path.join(tcl_headers.abspath, 'tcl.h')).exists()) or
(not File(os.path.join(tcl_libs.abspath, tcl_libname)).exists())) :
print 'Tcl headers and libraries not found at ' + tcl_platform_dir + ', not building Tcl SML wrappers.'
print('Tcl headers and libraries not found at ' + tcl_platform_dir + ', not building Tcl SML wrappers.')
Return()
else:
print 'Tcl SML wrappers are buildable.'
print('Tcl SML wrappers are buildable.')

# dirs
lib_install_dir = clone.Dir('$OUT_DIR')
Expand Down Expand Up @@ -122,7 +122,7 @@ if sys.platform == 'darwin':
# including the -bundle flag with -flat_namespace now gives an error, so we removed it
clone.Append(SHLINKFLAGS=Split('$LINKFLAGS -flat_namespace -undefined suppress'))
clone.Append(LINKFLAGS=['-framework', tcl_lib])
elif sys.platform == 'linux2':
elif sys.platform.startswith('linux'):
clone.Append(CPPFLAGS = ['-fPIC'])
clone.Append(LIBS = [tcl_lib])
else:
Expand Down
20 changes: 10 additions & 10 deletions Core/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def CheckSWIG(env):
return False

p = sub.Popen('swig -version'.split(), stdout=sub.PIPE)
out = p.communicate()[0].split()
out = p.communicate()[0].decode().split()
p.wait()

version = tuple(int(x) for x in out[2].split('.'))
if version >= (1, 3, 31):
return True

print 'swig version 1.3.31 or higher is required'
print('swig version 1.3.31 or higher is required')
return False

kernel_env = env.Clone()
Expand Down Expand Up @@ -71,13 +71,13 @@ else:
srcs.append(['CLI/CommandLineInterface.cxx', Glob('CLI/src/*.cpp')])


# print 'Soar compiler settings'
# print 'CXXFlags ', kernel_env.Dump('CXXFLAGS')
# print 'CPPFLAGS ', kernel_env.Dump('CPPFLAGS')
# print 'LINKFLAGS ', kernel_env.Dump('LINKFLAGS')
# print 'LIBS ', kernel_env.Dump('LIBS')
# print 'LIBPATH ', kernel_env.Dump('LIBPATH')
# print 'CPPPATH ', kernel_env.Dump('CPPPATH')
# print('Soar compiler settings')
# print('CXXFlags ', kernel_env.Dump('CXXFLAGS'))
# print('CPPFLAGS ', kernel_env.Dump('CPPFLAGS'))
# print('LINKFLAGS ', kernel_env.Dump('LINKFLAGS'))
# print('LIBS ', kernel_env.Dump('LIBS'))
# print('LIBPATH ', kernel_env.Dump('LIBPATH'))
# print('CPPPATH ', kernel_env.Dump('CPPPATH'))

svs_objs = []
if not GetOption('nosvs'):
Expand Down Expand Up @@ -108,7 +108,7 @@ for d in ['ElementXML/src', 'ConnectionSML/src', 'ClientSML/src', 'shared']:
env.Alias('headers', headers)

if not CheckSWIG(env):
print 'SWIG not found, will not attempt to build wrappers for other programming languages.'
print('SWIG not found, will not attempt to build wrappers for other programming languages.')
else:
for x in 'Python Java Tcl PHP CSharp'.split():
SConscript(os.path.join('ClientSMLSWIG', x, 'SConscript'))
Expand Down
9 changes: 4 additions & 5 deletions Core/SVS/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ conf.Finish()

if not platform.system() == 'Darwin':
if not missing_libs:
viewer_prog = viewer_env.Program('svs_viewer', viewer_src)
viewer_install = viewer_env.Alias('svs_viewer', viewer_env.Install('$OUT_DIR', viewer_prog))
viewer_prog = viewer_env.Program('svs_viewer', viewer_src)
viewer_install = viewer_env.Alias('svs_viewer', viewer_env.Install('$OUT_DIR', viewer_prog))
else:
print 'Cannot find %s, not building svs_viewer' % ', '.join(missing_libs)
print('Cannot find %s, not building svs_viewer' % ', '.join(missing_libs))
else:
print 'Not building svs_viewer for OSX'
print('Not building svs_viewer for OSX')

# svs library objects
svs_env = env.Clone()
Expand Down Expand Up @@ -140,5 +140,4 @@ else:
svs_objs = svs_env.SharedObject(src) + ccd_env.SharedObject(ccd_src)

svs_inc = ['SVS/src']

Return('svs_objs', 'svs_inc')
2 changes: 2 additions & 0 deletions Java/Debugger/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ depjars = [
]

swt_jars = {
('linux', 32) : 'gtk32',
('linux', 64) : 'gtk64',
('linux2', 32) : 'gtk32',
('linux2', 64) : 'gtk64',
('darwin', 32) : 'osx32',
Expand Down
3 changes: 2 additions & 1 deletion Java/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ if not java_env.WhereIs('java') or not java_env.WhereIs('swig'):

try:
p = sub.Popen(['java', '-version'], stderr = sub.PIPE)
ver_str = p.stderr.readline().split()[-1].strip('"')
line = p.stderr.readline().decode()
ver_str = line.split()[-1].strip('"')
p.wait()
except OSError:
print >>sys.stderr, 'Error running java'
Expand Down
Loading

0 comments on commit 05a8474

Please sign in to comment.