Skip to content

Commit

Permalink
add option to specify Utility output path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanggeon Park authored and Sanggeon Park committed Aug 5, 2015
1 parent eff2f6e commit 9d46521
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ObjectiveCCodeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,14 +1017,14 @@ def writeAPIParser(self) :
finally :
implDstFile.close()

def writeTemplates(self) :
def writeTemplates(self, templatePath) :

if self.dirPath.endswith("/") :
self.dirPath = self.dirPath[:-1]
baseDirPath = self.dirPath
self.dirPath = baseDirPath + "/Utilities/NSString"
if templatePath.endswith("/") :
templatePath = templatePath[:-1]

self.dirPath = templatePath + "/NSString"
self.writeNSStringCategory()
self.dirPath = baseDirPath + "/Utilities/APIParser"
self.dirPath = templatePath + "/APIParser"
self.writeAPIParser()


Expand Down
20 changes: 18 additions & 2 deletions readJSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
projectPrefix = ''
target = 'iOS'
dirPathToSaveCodes = './src'
dirPathToSaveUtility = ''
objectSuffix = "JSONObject"

usageString = '\nreadJSON.py [ -p | -t | -o | -s ] [-i]\n'
Expand All @@ -49,11 +50,12 @@
usageString += ' -t, --target= target platform iOS or Android (default: iOS)\n'
usageString += ' -i, --input= meta-JSON file to read\n'
usageString += ' -o, --output= ouput path of generated source codes\n'
usageString += ' -u, --utility= ouput path of generated Utility codes. Use "-u false" for no utility\n'

if __name__ == "__main__":
argv = sys.argv[1:]
try:
opts, args = getopt.getopt(argv,"ho:p:s:t:i:",["prefix=","suffix=","target=","input=","output="])
opts, args = getopt.getopt(argv,"ho:p:s:t:i:u:",["prefix=","suffix=","target=","input=","output=","utility="])
except getopt.GetoptError:
print usageString
sys.exit(2)
Expand All @@ -74,7 +76,20 @@
objectSuffix = arg
if objectSuffix == "false":
objectSuffix = ""
elif opt in ("-u", "--utility"):
dirPathToSaveUtility = arg



if dirPathToSaveUtility == "":
tmpSourcePath = dirPathToSaveCodes
if tmpSourcePath.endswith("/") :
tmpSourcePath = tmpSourcePath[:-1]
dirPathToSaveUtility = tmpSourcePath + "/Utility"

elif dirPathToSaveUtility == "false":
dirPathToSaveUtility = "";

addFiles = False
for arg in argv :
if arg.endswith(inputfile) :
Expand Down Expand Up @@ -142,7 +157,8 @@ def openFileAndParseJSON(filePath):
templateCodeGen.templatePath = templatePath
templateCodeGen.projectPrefix = projectPrefix
templateCodeGen.dirPath = dirPathToSaveCodes
templateCodeGen.writeTemplates()
if len(dirPathToSaveUtility) != 0 :
templateCodeGen.writeTemplates(dirPathToSaveUtility)

JSONScheme.projectPrefix = projectPrefix
JSONScheme.objectSuffix = objectSuffix
Expand Down

0 comments on commit 9d46521

Please sign in to comment.