mirror of https://github.com/axmolengine/axmol.git
rename and add commandline argument to cccopy.py
This commit is contained in:
parent
3c89bf1d83
commit
94471a06b6
|
@ -1,27 +0,0 @@
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
sourcePath = '../../../../samples/Cpp/TestCpp/Resources/'
|
|
||||||
destPath = '../../../../samples/Lua/TestLua/Resources/'
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(sourcePath):
|
|
||||||
#figure out where we're going
|
|
||||||
dest = destPath + root.replace(sourcePath, '')
|
|
||||||
destAbsPath = os.path.abspath(destPath)
|
|
||||||
#if we're in a directory that doesn't exist in the destination folder then create a new folder
|
|
||||||
if not os.path.isdir(dest):
|
|
||||||
os.mkdir(dest)
|
|
||||||
print os.path.abspath(dest).replace(destAbsPath, '') + ' created'
|
|
||||||
|
|
||||||
#loop through all files in the directory
|
|
||||||
for f in files:
|
|
||||||
#compute current (old) & new file locations
|
|
||||||
oldLoc = root + "/" + f
|
|
||||||
newLoc = dest + "/" + f
|
|
||||||
|
|
||||||
if not os.path.isfile(newLoc):
|
|
||||||
try:
|
|
||||||
shutil.copy2(oldLoc, newLoc)
|
|
||||||
print os.path.abspath(newLoc).replace(destAbsPath,'') + ' copied.'
|
|
||||||
except IOError:
|
|
||||||
print os.path.abspath(newLoc).replace(destAbsPath,'') + ' already exists'
|
|
|
@ -43,6 +43,5 @@ files
|
||||||
AppDelegate.cpp
|
AppDelegate.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
postbuild "${MARMALADE_ROOT}/s3e/python/python ./CopyResources.py"
|
postbuild "${MARMALADE_ROOT}/s3e/python/python ./cccopy.py -s ../../../../samples/Cpp/TestCpp/Resources/ -d ../../../../samples/Lua/TestLua/Resources/"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
def cccopy(sourcePath, destPath):
|
||||||
|
for root, dirs, files in os.walk(sourcePath):
|
||||||
|
#figure out where we're going
|
||||||
|
dest = destPath + root.replace(sourcePath, '')
|
||||||
|
destAbsPath = os.path.abspath(destPath)
|
||||||
|
#if we're in a directory that doesn't exist in the destination folder then create a new folder
|
||||||
|
if not os.path.isdir(dest):
|
||||||
|
os.mkdir(dest)
|
||||||
|
print os.path.abspath(dest).replace(destAbsPath, '')[1:] + ' directory created.'
|
||||||
|
|
||||||
|
#loop through all files in the directory
|
||||||
|
for f in files:
|
||||||
|
#compute current (old) & new file locations
|
||||||
|
oldLoc = root + "/" + f
|
||||||
|
newLoc = dest + "/" + f
|
||||||
|
|
||||||
|
if not os.path.isfile(newLoc):
|
||||||
|
try:
|
||||||
|
shutil.copy2(oldLoc, newLoc)
|
||||||
|
print os.path.abspath(newLoc).replace(destAbsPath,'')[1:] + ' copied.'
|
||||||
|
except IOError:
|
||||||
|
print os.path.abspath(newLoc).replace(destAbsPath,'')[1:] + ' already exists.'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# main
|
||||||
|
def main():
|
||||||
|
# parse options
|
||||||
|
parser = OptionParser(usage="%prog [options]")
|
||||||
|
parser.add_option("-s", "--sourcePath", action="store", help="Source path", dest="sourcePath")
|
||||||
|
parser.add_option("-d", "--destPath", action="store", help="Destination path", dest="destPath")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
if options.sourcePath and options.destPath:
|
||||||
|
cccopy(options.sourcePath, options.destPath)
|
||||||
|
else:
|
||||||
|
parser.error("")
|
||||||
|
|
||||||
|
## entry
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue