Skip to content

Commit

Permalink
Build: Zip base.jd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Jun 25, 2013
1 parent 949657c commit 0f763b5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakelists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ else ()
find_package(Lua52 REQUIRED)
endif()
add_subdirectory("src")
add_subdirectory("base.jd")
26 changes: 26 additions & 0 deletions base.jd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set (SRCS
lua/lib/compsys.lua
lua/lib/evt.lua
lua/lib/maploader.lua
lua/lib/oo.lua
lua/lib/persistence.lua
lua/lib/tabutil.lua
lua/lib/text.lua
lua/lib/util.lua
lua/lib/vecutil.lua)

set (basejdout "${CMAKE_CURRENT_BINARY_DIR}/base.jd")

add_custom_command(
OUTPUT ${basejdout}
COMMAND python "${CMAKE_CURRENT_LIST_DIR}/mkzip.py"
${basejdout}
${SRCS}
DEPENDS ${SRCS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Zipping base.jd."
VERBATIM)

add_custom_target(basejd ALL
DEPENDS ${basejdout}
SOURCES ${SRCS})
27 changes: 27 additions & 0 deletions base.jd/mkzip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from zipfile import ZipFile, ZIP_DEFLATED
from os import path
import os
import sys

def write_to_zip_file(zip_file, directory):
for dirpath, subdirs, files in os.walk(directory):
for objectt in (subdirs, files):
for opath in objectt:
opath = path.join(dirpath, opath)
zip_file.write(opath)

def main():
if len(sys.argv) < 3:
sys.exit("Usage: mkzip.py ZIP {INPUTS}")
with ZipFile(sys.argv[1], 'w', ZIP_DEFLATED) as zip_file:
for input in sys.argv[2:]:
if path.isdir(input):
write_to_zip_file(zip_file, input)
else:
zip_file.write(input)

if __name__ == '__main__':
main()

0 comments on commit 0f763b5

Please sign in to comment.