Skip to content

Commit

Permalink
Manual merge (= file copying) sgopt into master. This revision also c…
Browse files Browse the repository at this point in the history
…ompiles on my laptop.
  • Loading branch information
valentjn committed Feb 12, 2016
1 parent 1ec8698 commit 9573573
Show file tree
Hide file tree
Showing 736 changed files with 15,643 additions and 20,817 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BasedOnStyle: Google
BasedOnStyle: Google
ColumnLimit: 100
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*.so
*.exe

#ignoring cpplint files
*.lint

#ignoring swig build files
*.jar
*doc.i
Expand Down
34 changes: 34 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import os
import SGppConfigure
from SCons.Script.SConscript import SConsEnvironment
import warnings
import subprocess

from Helper import *

Expand Down Expand Up @@ -81,6 +82,7 @@ vars.Add('BOOST_LIBRARY_PATH', 'Specifies the location of the boost library.', '
vars.Add(BoolVariable('COMPILE_BOOST_TESTS', 'Compile the test cases written using Boost Test.', True))
vars.Add(BoolVariable('COMPILE_BOOST_PERFORMANCE_TESTS', 'Compile the performance tests written using Boost Test. Currently only buildable with OpenCL enabled', False))
vars.Add(BoolVariable('RUN_BOOST_TESTS', 'Run the test cases written using Boost Test (only if COMPILE_BOOST_TESTS is true).', True))
vars.Add(BoolVariable('RUN_CPPLINT', 'Check compliance to Google\'s style guide using cpplint.', True))
vars.Add(BoolVariable('USE_DOUBLE_PRECISION', 'If disabled, SG++ will compile using single precision (floats).', True))

vars.Add(BoolVariable('USE_ARMADILLO', 'Sets if Armadillo should be used (only relevant for SGPP::optimization).', False))
Expand Down Expand Up @@ -250,6 +252,38 @@ else:
PYSGPP_PACKAGE_PATH.abspath])
# -------------------------------------------------------------------------

def lintAction(target, source, env):
p = subprocess.Popen(["python", "tools/cpplint.py", "--ignorecfg=yes",
"--extensions=cpp,hpp", "--linelength=100",
source[0].abspath],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# wait for termination and get output on stdout and stderr
stdout, stderr = p.communicate()
# cpplint prints on stderr
for line in stderr.splitlines():
# skip status lines, empty lines, and some warning types
if ("Done processing " in line) or \
("Total errors found: " in line) or \
("Is this a non-const reference? " +
"If so, make const or use a pointer:" in line) or \
("Consider using rand_r(...) instead of rand(...) for " +
"improved thread safety." in line) or \
("<chrono> is an unapproved C++11 header." in line) or \
(line == ""):
pass
else:
parts = line.split(": ")
location = parts[0]
message = ": ".join(parts[1:])
print location + ": warning: " + message
# touch file without writing anything
# (to indicate for the next run of SCons that we already checked this file)
with open(target[0].abspath, "w"): pass

env.Export('lintAction')

# -------------------------------------------------------------------------

# add custom builder to trigger the unittests after the build and to enable a special import test
if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']:
# do the actual thing
Expand Down
27 changes: 21 additions & 6 deletions base/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import fnmatch
import subprocess

Import('env')
Import('BUILD_DIR')
Expand All @@ -17,6 +16,7 @@ Import('installTargetList')
Import('exampleTargetList')
Import('headerSourceList')
Import('headerDestList')
Import('lintAction')

moduleDependencies = []
Export('moduleDependencies')
Expand All @@ -27,21 +27,31 @@ if env['USE_OCL']:

moduleDependencies = additionalDependencies + moduleDependencies

cpps = []
hpps = []
objs = []

for currentFolder, subdirNames, fileNames in os.walk("src", topdown=True):
if os.path.exists(os.path.join(currentFolder, "SConscript")):
objsSubmodule = env.SConscript(os.path.join(currentFolder, "SConscript"))
cppsSubmodule, hppsSubmodule, objsSubmodule = \
env.SConscript(os.path.join(currentFolder, "SConscript"))
objs += objsSubmodule
for hpp in hppsSubmodule:
headerSourceList.append(os.path.join(moduleName, hpp))
headerDestList.append(hpp.split(os.sep, 1)[1])
# remove subfolders from iteration, as they are already processed (this is why topdown=True is also required
subdirNames[:] = []
else:
for fileName in fnmatch.filter(fileNames, '*.cpp'):
sourceFile = os.path.join(currentFolder, fileName)
objs.append(env.SharedObject(sourceFile))
cpp = os.path.join(currentFolder, fileName)
cpps.append(cpp)
objs.append(env.SharedObject(cpp))
if currentFolder != 'src':
for fileName in fnmatch.filter(fileNames, '*.hpp'):
headerSourceList.append(os.path.join(moduleName, currentFolder, fileName))
headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1])
hpp = os.path.join(currentFolder, fileName)
hpps.append(hpp)
headerSourceList.append(os.path.join(moduleName, hpp))
headerDestList.append(hpp.split(os.sep, 1)[1])

libname = "sgpp%s" % moduleName
if env['USE_STATICLIB']:
Expand All @@ -62,6 +72,11 @@ else:

libInstall = env.Install(BUILD_DIR, lib)

if env['RUN_CPPLINT']:
for path in cpps + hpps:
lintCommand = env.Command(path + ".lint", path, lintAction)
env.Depends(lib, lintCommand)

if env["ARCH"] != "mic":
for fileName in os.listdir("examples"):
if fnmatch.fnmatch(fileName, "*.cpp"):
Expand Down
112 changes: 0 additions & 112 deletions base/doc/doxygen/code_examples_continued_learning.doxy

This file was deleted.

Loading

0 comments on commit 9573573

Please sign in to comment.