Skip to content

Commit

Permalink
reorganize NES C++ code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kautenja committed Jan 9, 2019
1 parent 9fffbee commit 1abddd9
Show file tree
Hide file tree
Showing 33 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
graft nes_py/cpp
graft nes_py/nes
4 changes: 3 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ all: test deployment

# build the LaiNES CPP code
lib_nes_env:
scons
cd nes_py/nes && scons
mv nes_py/nes/lib_nes_env*.so nes_py

# run the Python test suite
test: lib_nes_env
Expand All @@ -28,6 +29,7 @@ clean:
rm nes_py/lib_nes_env.so || true
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete
find . -name ".sconsign.dblite" -delete

# build the deployment package
deployment: clean
Expand Down
32 changes: 32 additions & 0 deletions nes_py/nes/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""The compilation script for this project using SCons."""
from os import environ


# create a separate build directory
VariantDir('build', 'src', duplicate=0)


# the compiler and linker flags for the C++ environment
FLAGS = [
'-std=c++1y',
'-O2',
'-march=native',
'-pipe',
]


# Create the C++ environment
ENV = Environment(
ENV=environ,
CXX='clang++',
CPPFLAGS=['-Wno-unused-value'],
CXXFLAGS=FLAGS,
LINKFLAGS=FLAGS,
CPPPATH=['#include'],
)


# Locate all the C++ source files
SRC = Glob('build/*.cpp') + Glob('build/*/*.cpp')
# Create a shared library (it will add "lib" to the front automatically)
ENV.SharedLibrary('_nes_env.so', SRC)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# The source files for building the extension. Globs locate all the cpp files
# used by the LaiNES subproject. MANIFEST.in has to include the blanket
# "cpp" directory to ensure that the .inc file gets included too
SOURCES = glob('nes_py/cpp/*.cpp') + glob('nes_py/cpp/mappers/*.cpp')
SOURCES = glob('nes_py/nes/src/*.cpp') + glob('nes_py/nes/src/mappers/*.cpp')
# The directory pointing to header files used by the LaiNES cpp files.
# This directory has to be included using MANIFEST.in too to include the
# headers with sdist
INCLUDE_DIRS = ['nes_py/cpp/include']
INCLUDE_DIRS = ['nes_py/nes/include']
# Build arguments to pass to the compiler
EXTRA_COMPILE_ARGS = [
'-std=c++1y',
Expand Down

0 comments on commit 1abddd9

Please sign in to comment.