summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen2018-01-08 15:50:55 -0600
committerDan Willemsen2018-01-08 17:03:21 -0600
commita852f95b534f7b8d0c4dfa79878b925c504e1493 (patch)
tree852f5f699c0c2a96b04a920dd25c5eb81b21603c /toolbox
parentacaeeeed7351cc1fe035c84bc96729bc0a02400d (diff)
downloadplatform-system-core-a852f95b534f7b8d0c4dfa79878b925c504e1493.tar.gz
platform-system-core-a852f95b534f7b8d0c4dfa79878b925c504e1493.tar.xz
platform-system-core-a852f95b534f7b8d0c4dfa79878b925c504e1493.zip
Convert toolbox to Android.bp
This drops the *TOOLS automated logic, though since there are only three tools now, that seems less important. It would have been possible to implement that logic in a Go plugin, but that seems like a lot of overkill to fix a few duplicated entries. See build/soong/README.md for more information. Test: mmma system/core/toolbox Test: List of installed files is the same Test: input.h-labels.h and tools.h are the same Change-Id: I9753083c3f689e689e40001b998b39ad20509598
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/Android.bp83
-rw-r--r--toolbox/Android.mk78
2 files changed, 71 insertions, 90 deletions
diff --git a/toolbox/Android.bp b/toolbox/Android.bp
index 9c2cafac2..de8324af3 100644
--- a/toolbox/Android.bp
+++ b/toolbox/Android.bp
@@ -1,11 +1,18 @@
1common_cflags = [ 1cc_defaults {
2 "-Werror", 2 name: "toolbox_defaults",
3 "-Wno-unused-parameter", 3
4 "-Wno-unused-const-variable", 4 cflags: [
5 "-include bsd-compatibility.h" 5 "-Werror",
6] 6 "-Wno-unused-parameter",
7 "-Wno-unused-const-variable",
8 "-include bsd-compatibility.h",
9 ],
10 local_include_dirs: ["upstream-netbsd/include/"],
11}
7 12
8cc_library_static { 13cc_library_static {
14 name: "libtoolbox_dd",
15 defaults: ["toolbox_defaults"],
9 srcs: [ 16 srcs: [
10 "upstream-netbsd/bin/dd/args.c", 17 "upstream-netbsd/bin/dd/args.c",
11 "upstream-netbsd/bin/dd/conv.c", 18 "upstream-netbsd/bin/dd/conv.c",
@@ -19,17 +26,68 @@ cc_library_static {
19 "upstream-netbsd/lib/libc/string/swab.c", 26 "upstream-netbsd/lib/libc/string/swab.c",
20 "upstream-netbsd/lib/libutil/raise_default_signal.c", 27 "upstream-netbsd/lib/libutil/raise_default_signal.c",
21 ], 28 ],
22 cflags: common_cflags + [ 29 cflags: [
23 "-Dmain=dd_main", 30 "-Dmain=dd_main",
24 "-DNO_CONV", 31 "-DNO_CONV",
25 ], 32 ],
26 local_include_dirs: ["upstream-netbsd/include/"], 33}
27 name: "libtoolbox_dd", 34
35genrule {
36 name: "toolbox_tools",
37 cmd: "echo '/* file generated automatically */' >$(out) && for t in toolbox dd getevent newfs_msdos getprop; do echo \"TOOL($$t)\" >>$(out); done",
38 out: ["tools.h"],
39}
40
41genrule {
42 name: "toolbox_input_labels",
43 tool_files: ["generate-input.h-labels.py"],
44 cmd: "$(location) $(in) >$(out)",
45 srcs: [":kernel_input_headers"],
46 out: ["input.h-labels.h"],
47}
48
49cc_binary {
50 name: "toolbox",
51 defaults: ["toolbox_defaults"],
52 srcs: [
53 "toolbox.c",
54 "getevent.c",
55 "getprop.cpp",
56 "newfs_msdos.c",
57 ],
58 generated_headers: [
59 "toolbox_tools",
60 "toolbox_input_labels",
61 ],
62 whole_static_libs: ["libtoolbox_dd"],
63 shared_libs: [
64 "libbase",
65 "libcutils",
66 ],
67 static_libs: [
68 "libpropertyinfoparser",
69 ],
70 cpp_std: "gnu++1z",
71
72 symlinks: [
73 "dd",
74 "getevent",
75 "getprop",
76 "newfs_msdos",
77 ],
78}
79
80// We only want 'r' on userdebug and eng builds.
81cc_binary {
82 name: "r",
83 defaults: ["toolbox_defaults"],
84 srcs: ["r.c"],
28} 85}
29 86
30// We build BSD grep separately, so it can provide egrep and fgrep too. 87// We build BSD grep separately, so it can provide egrep and fgrep too.
31cc_defaults { 88cc_defaults {
32 name: "grep_common", 89 name: "grep_common",
90 defaults: ["toolbox_defaults"],
33 srcs: [ 91 srcs: [
34 "upstream-netbsd/usr.bin/grep/fastgrep.c", 92 "upstream-netbsd/usr.bin/grep/fastgrep.c",
35 "upstream-netbsd/usr.bin/grep/file.c", 93 "upstream-netbsd/usr.bin/grep/file.c",
@@ -37,9 +95,10 @@ cc_defaults {
37 "upstream-netbsd/usr.bin/grep/queue.c", 95 "upstream-netbsd/usr.bin/grep/queue.c",
38 "upstream-netbsd/usr.bin/grep/util.c", 96 "upstream-netbsd/usr.bin/grep/util.c",
39 ], 97 ],
40 cflags: common_cflags, 98 symlinks: [
41 local_include_dirs: ["upstream-netbsd/include/"], 99 "egrep",
42 symlinks: ["egrep", "fgrep"], 100 "fgrep",
101 ],
43 102
44 sanitize: { 103 sanitize: {
45 integer_overflow: false, 104 integer_overflow: false,
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
deleted file mode 100644
index d1b6114b0..000000000
--- a/toolbox/Android.mk
+++ /dev/null
@@ -1,78 +0,0 @@
1LOCAL_PATH:= $(call my-dir)
2
3common_cflags := \
4 -Werror -Wno-unused-parameter -Wno-unused-const-variable \
5 -include bsd-compatibility.h \
6
7include $(CLEAR_VARS)
8
9BSD_TOOLS := \
10 dd \
11
12OUR_TOOLS := \
13 getevent \
14 newfs_msdos \
15
16OUR_CPP_TOOLS := \
17 getprop \
18
19ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) $(OUR_CPP_TOOLS)
20
21LOCAL_SRC_FILES := \
22 toolbox.c \
23 $(patsubst %,%.c,$(OUR_TOOLS)) \
24 $(patsubst %,%.cpp,$(OUR_CPP_TOOLS)) \
25
26LOCAL_CFLAGS += $(common_cflags)
27LOCAL_CPPFLAGS += -std=gnu++1z
28LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-netbsd/include/
29
30LOCAL_SHARED_LIBRARIES := \
31 libbase \
32 libcutils \
33
34LOCAL_STATIC_LIBRARIES := libpropertyinfoparser
35
36LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
37
38LOCAL_MODULE := toolbox
39
40# Install the symlinks.
41LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
42
43# Including this will define $(intermediates).
44#
45include $(BUILD_EXECUTABLE)
46
47$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
48
49TOOLS_H := $(intermediates)/tools.h
50$(TOOLS_H): PRIVATE_TOOLS := toolbox $(ALL_TOOLS)
51$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
52$(TOOLS_H): $(LOCAL_PATH)/Android.mk
53$(TOOLS_H):
54 $(transform-generated-source)
55
56$(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
57
58UAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input.h bionic/libc/kernel/uapi/linux/input-event-codes.h
59INPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
60$(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
61# The PRIVATE_CUSTOM_TOOL line uses = to evaluate the output path late.
62# We copy the input path so it can't be accidentally modified later.
63$(INPUT_H_LABELS_H): PRIVATE_UAPI_INPUT_EVENT_CODES_H := $(UAPI_INPUT_EVENT_CODES_H)
64$(INPUT_H_LABELS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/generate-input.h-labels.py $(PRIVATE_UAPI_INPUT_EVENT_CODES_H) > $@
65# The dependency line though gets evaluated now, so the PRIVATE_ copy doesn't exist yet,
66# and the original can't yet have been modified, so this is both sufficient and necessary.
67$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
68$(INPUT_H_LABELS_H):
69 $(transform-generated-source)
70
71# We only want 'r' on userdebug and eng builds.
72include $(CLEAR_VARS)
73LOCAL_SRC_FILES := r.c
74LOCAL_CFLAGS += $(common_cflags)
75LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-netbsd/include/
76LOCAL_MODULE := r
77LOCAL_MODULE_TAGS := debug
78include $(BUILD_EXECUTABLE)