kivy-ios/kivy_ios/tools/liblink
Andre Miras 56431b6922 Moving to dedicated kivy_ios/ package directory
- updates all imports to prefix kivy_ios
- adds basic `setup.py` file
- adds a simple `toolchain.py` to the root folder for compat

Makes it possible to install kivy-ios from PyPI:
```
pip install kivy-ios
toolchain --help
```
Note the `rebuild_updated_recipes.py` is expected to fail as we
moved all the recipes.

This is a working, but unperfect iteration that come with limitations
we would address in subsequent pull requests, such as:
- the new usage is not yet documented
- CI is not testing the source distribution creation and install
- Continuous Delivery to PyPI is not in place
- `toolchain` binary is a bit too generic name
- we're still vendoring things under `tools/`
2020-05-03 23:29:41 +02:00

88 lines
1.6 KiB
Python
Executable file

#!/usr/bin/env python
import sys
import subprocess
from os import environ
libs = [ ]
objects = [ ]
output = None
i = 1
while i < len(sys.argv):
opt = sys.argv[i]
i += 1
if opt == "-o":
output = sys.argv[i]
i += 1
continue
if opt.startswith("-l") or opt.startswith("-L"):
libs.append(opt)
continue
if opt in ("-r", "-pipe", "-no-cpp-precomp"):
continue
if opt in ("--sysroot", "-isysroot", "-framework", "-undefined",
"-macosx_version_min"):
i += 1
continue
if opt.startswith("-I"):
continue
if opt.startswith("-m"):
continue
if opt.startswith("-f"):
continue
if opt.startswith("-O"):
continue
if opt.startswith("-g"):
continue
if opt.startswith("-D"):
continue
if opt.startswith('-arch'):
continue
if opt.startswith("-Wl,"):
continue
if opt.startswith("-W"):
continue
if opt.startswith("-"):
print(sys.argv)
print("Unknown option: ", opt)
sys.exit(1)
if not opt.endswith('.o'):
continue
objects.append(opt)
f = open(output, "w")
f.close()
f = open(output + ".libs", "w")
f.write(" ".join(libs))
f.close()
print('Liblink redirect linking with', objects)
ld = environ.get('ARM_LD')
arch = environ.get('ARCH', 'arm64')
if 'arm' in arch:
min_version_flag = '-ios_version_min'
else:
min_version_flag = '-ios_simulator_version_min'
call = [ld, '-r', '-o', output + '.o', min_version_flag, '8.0', '-arch', arch] + objects
print("Linking: {}".format(" ".join(call)))
subprocess.call(call)