Skip to content

Commit

Permalink
Switch build system to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Jun 11, 2014
1 parent 36cf09c commit 4d21654
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 797 deletions.
18 changes: 2 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
*.vcproj.*.user
*.ncb
*.suo
*.swp
*.swo
*.gcno
*.gcda
/bin/pycdc*
/bin/pycdas*
/out/*.o
/out/*.obj
/out/*.manifest
/out/*.manifest.res
/out/*.dep
/out/*.idb
/out/*.pdb
/out/BuildLog.htm
/bytes/*.cpp
/tests/*.pyc.err
/tests/*.pyc.src
*.kdev4
/.kdev4
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
project(pycdc)
cmake_minimum_required(VERSION 2.8)

# For generating the bytes tables
find_package(PythonInterp REQUIRED)

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror ${CMAKE_CXX_FLAGS}")
endif()

set(PYTHON_VERSIONS
10 11 13 14 15 16 # Python 1.1 and 1.2 are marshall-identical
20 21 22 23 24 25 26 27
30 31 32 33 34
)

set(MAP_FILES "")
set(MAP_SOURCES "")
foreach(ver ${PYTHON_VERSIONS})
set(MAP_FILES ${MAP_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/bytes/python_${ver}.map)
set(MAP_SOURCES ${MAP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/bytes/python_${ver}.cpp)
endforeach()

add_custom_command(OUTPUT ${MAP_SOURCES}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/bytes/comp_map.py
${CMAKE_CURRENT_SOURCE_DIR}/bytes
${CMAKE_CURRENT_BINARY_DIR}/bytes
DEPENDS ${MAP_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/bytes/comp_map.py
)

set(COMMON_SOURCES
bytecode.cpp
data.cpp
pyc_code.cpp
pyc_module.cpp
pyc_numeric.cpp
pyc_object.cpp
pyc_sequence.cpp
pyc_string.cpp
${MAP_SOURCES}
)

set(pycdas_SOURCES
ASTree.cpp
ASTNode.cpp
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_library(pycxx STATIC ${COMMON_SOURCES})

add_executable(pycdas pycdas.cpp)
target_link_libraries(pycdas pycxx)

add_executable(pycdc pycdc.cpp ${pycdas_SOURCES})
target_link_libraries(pycdc pycxx)

# For tests
add_custom_target(test ${CMAKE_CURRENT_SOURCE_DIR}/pycdc_test.sh
${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_dependencies(test pycdc)
82 changes: 0 additions & 82 deletions Makefile

This file was deleted.

Empty file removed bin/.keep
Empty file.
16 changes: 13 additions & 3 deletions bytes/comp_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@
# You should have received a copy of the GNU General Public License
# along with pycdc. If not, see <http://www.gnu.org/licenses/>.

import sys
import os

if len(sys.argv) != 3:
sys.stderr.write('Usage: %s in_dir out_dir\n' % sys.argv[0])
sys.exit(1)

if not os.path.exists(sys.argv[2]):
os.mkdir(sys.argv[2])

maplist = [ 10, 11, 13, 14, 15, 16,
20, 21, 22, 23, 24, 25, 26, 27,
30, 31, 32, 33, 34 ]

for mapver in maplist:
infile = open('python_%d.map' % mapver, 'rt')
outfile = open('python_%d.cpp' % mapver, 'wt')
infile = open(os.path.join(sys.argv[1], 'python_%d.map' % mapver), 'rt')
outfile = open(os.path.join(sys.argv[2], 'python_%d.cpp' % mapver), 'wt')

idToOpcode = {}
opcodeToId = {}
Expand All @@ -31,7 +41,7 @@
opcodeToId[code] = int(fileid)

outfile.write('/* This file was auto-generated with comp_map.py. DO NOT EDIT! */\n\n')
outfile.write('#include "../bytecode.h"\n\n')
outfile.write('#include "bytecode.h"\n\n')
outfile.write('int python_%d_map(int id)\n' % mapver)
outfile.write('{\n')
outfile.write(' switch (id) {\n')
Expand Down
Empty file removed out/.keep
Empty file.
Loading

0 comments on commit 4d21654

Please sign in to comment.