Skip to content

Commit 0ba2ffd

Browse files
author
Lucas Marçal
committed
first commit
0 parents  commit 0ba2ffd

148 files changed

Lines changed: 8450 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
![](images/cover.png)
2+
3+
## Setup
4+
What you’ll install:
5+
- Java 11;
6+
7+
## First run
8+
Run: make install_lldb_remap
9+
Run: make xcode

Scripts/build_script.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env python3.6
2+
3+
import json
4+
import os
5+
import sys
6+
import shutil
7+
import subprocess
8+
from distutils.dir_util import copy_tree
9+
from typing import Any, Dict
10+
11+
def copytree(src, dst, symlinks=False):
12+
if os.path.isdir(src):
13+
for item in os.listdir(src):
14+
s = os.path.join(src, item)
15+
d = os.path.join(dst, item)
16+
if os.path.exists(d):
17+
try:
18+
shutil.rmtree(d)
19+
except OSError:
20+
os.unlink(d)
21+
if os.path.isdir(s):
22+
shutil.copytree(s, d, symlinks)
23+
else:
24+
shutil.copy2(s, d)
25+
else:
26+
shutil.copy2(src, dst)
27+
28+
def runBuild() -> None: # noqa C901
29+
# Xcode Environment
30+
arch = os.environ.get("ARCHS", default="")
31+
platform_name = os.environ.get("PLATFORM_NAME", default="")
32+
source_root = os.environ.get("SOURCE_ROOT", default="")
33+
wrapper_name = os.environ.get("WRAPPER_NAME")
34+
executable_name = os.environ.get("EXECUTABLE_NAME")
35+
executable_extension = os.environ.get("EXECUTABLE_EXTENSION")
36+
wrapper_extension = os.environ.get("WRAPPER_EXTENSION")
37+
if wrapper_extension is None:
38+
if executable_name is None:
39+
exit(0)
40+
wrapper_name = executable_name
41+
else:
42+
wrapper_extension = "app"
43+
44+
# Buck Environment
45+
buck_cell_relative_path = os.environ.get("BUCK_CELL_RELATIVE_PATH")
46+
build_target = os.environ.get("BUILD_TARGET").replace("\/\/", "//")
47+
built_products_dir = os.environ.get("TARGET_BUILD_DIR", default="")
48+
target_name = os.environ.get("TARGET_NAME", default="")
49+
50+
buck_cell_root = os.path.normpath(
51+
os.path.join(source_root, buck_cell_relative_path)
52+
)
53+
54+
product_name = (
55+
wrapper_name
56+
if wrapper_name is not None and wrapper_name != ""
57+
else target_name + "." + wrapper_extension
58+
)
59+
path = os.path.join(built_products_dir, product_name)
60+
61+
archs = arch.split(" ")
62+
if len(archs) > 1:
63+
archs.remove("arm64")
64+
archs = ",".join(archs)
65+
arch = archs
66+
67+
build_target += "#" + platform_name + "-" + arch
68+
if executable_extension is not None and executable_extension == "a":
69+
build_target += ",static"
70+
71+
build_command = ["./buck", "build", build_target] + [
72+
"--report-absolute-paths",
73+
"--show-output"
74+
]
75+
print(build_command, file=sys.stderr)
76+
build_output = subprocess.check_output(build_command, encoding="utf-8")
77+
print(build_output, file=sys.stderr)
78+
print("Output:")
79+
print(build_output)
80+
cell_relative_path = os.path.join(
81+
"buck-out", build_output.split(" buck-out/")[-1].strip()
82+
)
83+
print(cell_relative_path)
84+
app = os.path.join(buck_cell_root, cell_relative_path)
85+
app = app.replace("Libraries/buck-out", "/buck-out")
86+
if not os.path.exists(app):
87+
print(
88+
f"error: {product_name} not found at expected path ({app}).",
89+
file=sys.stderr,
90+
)
91+
exit(1)
92+
93+
copytree(app, path, symlinks=True)
94+
95+
machine_log_path = os.path.join(
96+
buck_cell_root, "buck-out", "log", "last_buildcommand", "buck-machine-log"
97+
)
98+
machine_log_first_line = ""
99+
try:
100+
with open(machine_log_path, "r", encoding="utf-8") as fp:
101+
machine_log_first_line = fp.readline()
102+
except OSError:
103+
print("warning Buck machine log unable to be read for run.", file=sys.stderr)
104+
if machine_log_first_line != "":
105+
machine_log_json: Dict[str, Any] = {}
106+
try:
107+
machine_log_json = machine_log_first_line.split()[1]
108+
except IndexError:
109+
print("warning Buck machine log unable to be parsed", file=sys.stderr)
110+
print(path)
111+
print(app)
112+
113+
def touchDummyFiles():
114+
temp_dir = os.environ.get("TEMP_DIR", default="")
115+
native_arch = os.environ.get("NATIVE_ARCH")
116+
product_name = os.environ.get("PRODUCT_NAME")
117+
derived_data_native_arch_path = f'{temp_dir}/Objects-normal/{native_arch}/'
118+
119+
print("Writing files...")
120+
os.makedirs(derived_data_native_arch_path, exist_ok=True)
121+
os.popen(f'mkdir -p {derived_data_native_arch_path}/ && touch {derived_data_native_arch_path}/{product_name}.swiftmodule')
122+
os.popen(f'touch -f {derived_data_native_arch_path}/{product_name}.swiftdoc')
123+
os.popen(f'touch -f {derived_data_native_arch_path}/{product_name}-Swift.h')
124+
os.popen(f'touch -f {derived_data_native_arch_path}/{product_name}-master.d')
125+
126+
127+
runBuild()
128+
touchDummyFiles()

Scripts/build_script.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set -x
2+
set -e
3+
PATH=/opt/homebrew/bin:$PATH
4+
pwd
5+
python3 Scripts/build_script.py

Scripts/lldb-remap.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
cat <<EOF > ~/.lldb-remap
3+
settings set target.source-map . $REPO_ROOT/
4+
settings append target.source-map /APPLE_SDKROOT $SDKROOT/
5+
settings append target.source-map /APPLE_PLATFORM_DIR $PLATFORM_DIR/
6+
settings append target.source-map /APPLE_DEVELOPER_DIR $DEVELOPER_DIR/
7+
EOF

ThirthPartyLibs/BUCK

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
prebuilt_apple_framework(
2+
name = "SDWebImage",
3+
visibility = ["PUBLIC"],
4+
framework = "SDWebImage/a990c053fff71e388a10f3357edb0be17929c9c5/Frameworks/SDWebImage.framework",
5+
preferred_linkage = "static"
6+
)

0 commit comments

Comments
 (0)