Cat-Printer/build-android/fix-ndk-execs.py
NaitLee 70cdd84359 Write Android build guide; fixed:
error when LANG=None
initial config have incorrect strength/energy
adjustments to docs and scripts
2022-09-12 02:20:08 +08:00

33 lines
894 B
Python

''' Some casual code to fix those alias files
in Android NDK llvm bin to symlinks instead
'''
import os
import sys
MAX_LENGTH = 256
ndk_path = sys.argv[1] if len(sys.argv) > 1 else input('Android NDK path: ')
bin_path = os.path.join(ndk_path, 'toolchains/llvm/prebuilt/linux-x86_64/bin/')
workdir = os.getcwd()
os.chdir(bin_path)
try:
for path in os.listdir():
# with this encoding it won't error when reading binary
file = open(path, 'r', encoding='iso8859-1')
data = file.read(MAX_LENGTH).strip()
file.close()
# inside the alias file is the filename that should be executed
# let's see if there is one
if os.path.isfile(data):
print('Will fix %s -> %s' % (path, data))
#os.remove(path)
os.rename(path, path + '.alias')
os.symlink(data, path)
finally:
os.chdir(workdir)