forked from facebook/buck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUCK
138 lines (125 loc) · 4.04 KB
/
BUCK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
python_library(
name = "subprocutils",
srcs = [
"subprocutils.py",
],
visibility = [
"//programs/...",
"//scripts/...",
],
)
python_library(
name = "buck_version",
srcs = [
"buck_version.py",
],
deps = [
":subprocutils",
],
)
python_binary(
name = "gen_buck_info",
main = "gen_buck_info.py",
deps = [
":buck_version",
],
)
# This is bit weird. This rule isn't idempotent, since it calls out
# to git commands to find repo information -- and this stuff clearly
# isn't enumerated in the inputs of arguments for this rule (which
# would normally add it to the rule key). However, since we're just
# trying to generate the Buck version UID, this should work, since the
# in-repo Buck we're using to build this already implicitly adds the
# same Buck version UID to it's rule key. But still... gross.
genrule(
name = "gen_buck_package_info",
out = "buck_package_info.json",
cmd = "$(exe :gen_buck_info) > $OUT",
)
build_type = read_config("build", "type", "LOCAL_PEX")
genrule(
name = "gen_build_type_info",
out = "build_type_info.txt",
bash = "echo {0} > $OUT".format(build_type),
cmd_exe = "echo {0}> %OUT%".format(build_type),
)
BUCK_CORE_RESOURCES = {
"android_agent_path": "//assets/android:agent.apk",
"bootstrapper_jar": "//src/com/facebook/buck/cli/bootstrapper:bootstrapper",
"buck_package_info": ":gen_buck_package_info",
"buck_server": "//src/com/facebook/buck/cli:main-fixed",
"buck_build_type_info": ":gen_build_type_info",
"dx": "//third-party/java/dx:etc_dx",
"jacoco_agent_jar": "//third-party/java/jacoco:agent",
# The name of this resource is important, since it needs to have this filename in the PEX.
"libjcocoa.dylib": "//third-party/java/ObjCBridge:libjcocoa.dylib",
"logging_config_file": "//config:logging.properties",
"native_exopackage_fake_path": "//assets/android:native-exopackage-fakes.apk",
"path_to_asm_jar": "//third-party/java/asm:asm",
"path_to_rawmanifest_py": "//src/com/facebook/buck/util/versioncontrol:rawmanifest",
"path_to_pathlib_py": "//third-party/py/pathlib:pathlib.py",
"path_to_pex": "//src/com/facebook/buck/python:pex",
"path_to_pywatchman": "//third-party/py/pywatchman:pywatchman-archive",
"path_to_typing": "//third-party/py:typing-archive",
"path_to_sh_binary_template": "//src/com/facebook/buck/shell:sh_binary_template",
"report_generator_jar": "//src/com/facebook/buck/jvm/java/coverage:report-generator",
"testrunner_classes": "//src/com/facebook/buck/testrunner:testrunner-bin-fixed",
# TODO(#5448619): We currently don't have a great way of packaging up
# entire directories into a PEX file, so for now, we aren't pulling in
# the following resources.
#':path_to_static_content',
}
python_library(
name = "bucklib",
srcs = [
"buck_package.py",
"buck_project.py",
"buck_repo.py",
"buck_tool.py",
"file_locks.py",
"timing.py",
"tracing.py",
],
resources = BUCK_CORE_RESOURCES,
deps = [
":buck_version",
":subprocutils",
"//third-party/nailgun:ng",
],
)
def interpreter_override_args():
"""Determine interpreter override arguments based on a buck config.
For example, `--config user.buck_pex_interpreter=python2` will generate a pex
which invokes `python2` instead of the default, `python<major>.<minor>`.
"""
val = read_config('user', 'buck_pex_interpreter', '')
if val != '':
return ['--python-shebang', '/usr/bin/env ' + val]
else:
return []
python_binary(
name = "buck",
build_args = interpreter_override_args(),
main = "buck.py",
deps = [
":bucklib",
":subprocutils",
],
)
python_binary(
name = "buckd",
build_args = interpreter_override_args(),
main = "buckd.py",
deps = [
":bucklib",
":subprocutils",
],
)
python_test(
name = "test",
srcs = glob(["test_*.py"]),
deps = [
":bucklib",
":subprocutils",
],
)