forked from organicmaps/organicmaps
[android] Fix indentation in set_up_android.py (no other changes)
This commit is contained in:
parent
e36b6f7f57
commit
ef2f26e5f0
1 changed files with 64 additions and 64 deletions
|
@ -7,87 +7,87 @@ import sys
|
|||
|
||||
|
||||
def locate_sdk(sdkPath):
|
||||
if (not sdkPath):
|
||||
sdkPath = raw_input('Enter Android SDK path: ').strip()
|
||||
# check if directory is correct
|
||||
androidPath = os.path.join(sdkPath, 'tools', 'android')
|
||||
if os.path.exists(androidPath):
|
||||
print 'ANDROID SDK path assigned: %s' % sdkPath
|
||||
return sdkPath
|
||||
else:
|
||||
print 'Incorrect SDK path.'
|
||||
exit(1)
|
||||
if (not sdkPath):
|
||||
sdkPath = raw_input('Enter Android SDK path: ').strip()
|
||||
# check if directory is correct
|
||||
androidPath = os.path.join(sdkPath, 'tools', 'android')
|
||||
if os.path.exists(androidPath):
|
||||
print 'ANDROID SDK path assigned: %s' % sdkPath
|
||||
return sdkPath
|
||||
else:
|
||||
print 'Incorrect SDK path.'
|
||||
exit(1)
|
||||
|
||||
|
||||
def locate_ndk(ndkPath):
|
||||
if (not ndkPath):
|
||||
ndkPath = raw_input('Enter Anroid NDK path: ').strip()
|
||||
# check if directory is correct
|
||||
ndkBuildPath = os.path.join(ndkPath, 'ndk-build')
|
||||
if os.path.exists(ndkBuildPath):
|
||||
print 'ANDROID NDK path assigned: %s' % ndkPath
|
||||
return ndkPath
|
||||
else:
|
||||
print 'Incorrect NDK path.'
|
||||
exit(1)
|
||||
if (not ndkPath):
|
||||
ndkPath = raw_input('Enter Anroid NDK path: ').strip()
|
||||
# check if directory is correct
|
||||
ndkBuildPath = os.path.join(ndkPath, 'ndk-build')
|
||||
if os.path.exists(ndkBuildPath):
|
||||
print 'ANDROID NDK path assigned: %s' % ndkPath
|
||||
return ndkPath
|
||||
else:
|
||||
print 'Incorrect NDK path.'
|
||||
exit(1)
|
||||
|
||||
|
||||
def write_local_properties(sdkDir, ndkDir):
|
||||
locPropsContent = ('# Autogenerated file\n' +
|
||||
'# Do not add it to version control\n' +
|
||||
'sdk.dir=%s\n' % sdkDir +
|
||||
'ndk.dir=%s\n' % ndkDir)
|
||||
locPropsContent = ('# Autogenerated file\n' +
|
||||
'# Do not add it to version control\n' +
|
||||
'sdk.dir=%s\n' % sdkDir +
|
||||
'ndk.dir=%s\n' % ndkDir)
|
||||
|
||||
curDir = os.getcwd()
|
||||
omimRoot = os.path.dirname(os.path.dirname(curDir))
|
||||
androidRoot = os.path.join(omimRoot, 'android')
|
||||
locPropsOrigin = os.path.join(androidRoot, 'local.properties')
|
||||
curDir = os.getcwd()
|
||||
omimRoot = os.path.dirname(os.path.dirname(curDir))
|
||||
androidRoot = os.path.join(omimRoot, 'android')
|
||||
locPropsOrigin = os.path.join(androidRoot, 'local.properties')
|
||||
|
||||
file = open(locPropsOrigin, 'w')
|
||||
file.write(locPropsContent)
|
||||
file.close()
|
||||
file = open(locPropsOrigin, 'w')
|
||||
file.write(locPropsContent)
|
||||
file.close()
|
||||
|
||||
# copy files to folders
|
||||
subfolders = ['YoPme',
|
||||
'YoPme2',
|
||||
'UnitTests']
|
||||
# copy files to folders
|
||||
subfolders = ['YoPme',
|
||||
'YoPme2',
|
||||
'UnitTests']
|
||||
|
||||
for folder in subfolders:
|
||||
dstFold = os.path.join(androidRoot, folder)
|
||||
if not os.path.exists(dstFold):
|
||||
os.makedirs(dstFold)
|
||||
dst = os.path.join(dstFold, 'local.properties')
|
||||
shutil.copy(locPropsOrigin, dst)
|
||||
print 'File created:', dst
|
||||
for folder in subfolders:
|
||||
dstFold = os.path.join(androidRoot, folder)
|
||||
if not os.path.exists(dstFold):
|
||||
os.makedirs(dstFold)
|
||||
dst = os.path.join(dstFold, 'local.properties')
|
||||
shutil.copy(locPropsOrigin, dst)
|
||||
print 'File created:', dst
|
||||
|
||||
|
||||
def usage():
|
||||
print "Usage: " + sys.argv[0] + " --sdk <SDK path> --ndk <NDK path>"
|
||||
print "Usage: " + sys.argv[0] + " --sdk <SDK path> --ndk <NDK path>"
|
||||
|
||||
|
||||
def run():
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "h", ["sdk=", "ndk=", "help"])
|
||||
except getopt.GetoptError as err:
|
||||
print str(err)
|
||||
usage()
|
||||
exit(2)
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "h", ["sdk=", "ndk=", "help"])
|
||||
except getopt.GetoptError as err:
|
||||
print str(err)
|
||||
usage()
|
||||
exit(2)
|
||||
|
||||
sdk = None
|
||||
ndk = None
|
||||
for o, a in opts:
|
||||
if o == "--sdk":
|
||||
sdk = a
|
||||
elif o == "--ndk":
|
||||
ndk = a
|
||||
elif o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
sdk = None
|
||||
ndk = None
|
||||
for o, a in opts:
|
||||
if o == "--sdk":
|
||||
sdk = a
|
||||
elif o == "--ndk":
|
||||
ndk = a
|
||||
elif o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
|
||||
sdkDir = locate_sdk(sdk)
|
||||
ndkDir = locate_ndk(ndk)
|
||||
print '>>> Writing local.properties'
|
||||
write_local_properties(sdkDir, ndkDir)
|
||||
print '>>> Done!'
|
||||
sdkDir = locate_sdk(sdk)
|
||||
ndkDir = locate_ndk(ndk)
|
||||
print '>>> Writing local.properties'
|
||||
write_local_properties(sdkDir, ndkDir)
|
||||
print '>>> Done!'
|
||||
|
||||
run()
|
||||
|
|
Loading…
Add table
Reference in a new issue