1// 2// Copyright (C) 2014 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17// 18// To sync with upstream: 19// 20 21// # Update. 22// git remote add toybox https://github.com/landley/toybox.git 23// git fetch toybox 24// git merge toybox/master 25 26// # Regenerate generated files. 27// NOBUILD=1 scripts/make.sh 28 29// # Make any necessary Android.bp changes and rebuild. 30// mm -j32 31 32// # Run tests. 33// ./run-tests-on-android.sh 34// # Run a single test. 35// ./run-tests-on-android.sh wc 36 37// # Upload changes. 38// git commit -a --amend 39// git push aosp HEAD:refs/for/master # Push to gerrit for review. 40// git push aosp HEAD:master # Push directly, avoiding gerrit. 41 42// 43// To add a toy: 44// 45 46// Edit .config to enable the toy you want to add. 47// make clean && make # Regenerate the generated files. 48// # Edit `srcs` below to add the toy. 49// # If you just want to use it as "toybox x" rather than "x", you can stop now. 50// # If you want this toy to have a symbolic link in /system/bin, add the toy to symlinks. 51 52cc_defaults { 53 name: "toybox-defaults", 54 srcs: [ 55 "lib/args.c", 56 "lib/commas.c", 57 "lib/dirtree.c", 58 "lib/help.c", 59 "lib/lib.c", 60 "lib/linestack.c", 61 "lib/llist.c", 62 "lib/net.c", 63 "lib/portability.c", 64 "lib/tty.c", 65 "lib/xwrap.c", 66 "main.c", 67 "toys/android/getenforce.c", 68 "toys/android/load_policy.c", 69 "toys/android/log.c", 70 "toys/android/restorecon.c", 71 "toys/android/runcon.c", 72 "toys/android/sendevent.c", 73 "toys/android/setenforce.c", 74 "toys/android/setprop.c", 75 "toys/android/start.c", 76 "toys/lsb/dmesg.c", 77 "toys/lsb/hostname.c", 78 "toys/lsb/killall.c", 79 "toys/lsb/md5sum.c", 80 "toys/lsb/mknod.c", 81 "toys/lsb/mktemp.c", 82 "toys/lsb/mount.c", 83 "toys/lsb/pidof.c", 84 "toys/lsb/seq.c", 85 "toys/lsb/sync.c", 86 "toys/lsb/umount.c", 87 "toys/net/ifconfig.c", 88 "toys/net/microcom.c", 89 "toys/net/netcat.c", 90 "toys/net/netstat.c", 91 "toys/net/ping.c", 92 "toys/net/rfkill.c", 93 "toys/net/tunctl.c", 94 "toys/other/acpi.c", 95 "toys/other/base64.c", 96 "toys/other/blkid.c", 97 "toys/other/blockdev.c", 98 "toys/other/chcon.c", 99 "toys/other/chroot.c", 100 "toys/other/chrt.c", 101 "toys/other/clear.c", 102 "toys/other/devmem.c", 103 "toys/other/dos2unix.c", 104 "toys/other/fallocate.c", 105 "toys/other/flock.c", 106 "toys/other/fmt.c", 107 "toys/other/free.c", 108 "toys/other/freeramdisk.c", 109 "toys/other/fsfreeze.c", 110 "toys/other/fsync.c", 111 "toys/other/help.c", 112 "toys/other/hwclock.c", 113 "toys/other/i2ctools.c", 114 "toys/other/inotifyd.c", 115 "toys/other/insmod.c", 116 "toys/other/ionice.c", 117 "toys/other/losetup.c", 118 "toys/other/lsattr.c", 119 "toys/other/lsmod.c", 120 "toys/other/lspci.c", 121 "toys/other/lsusb.c", 122 "toys/other/makedevs.c", 123 "toys/other/mkswap.c", 124 "toys/other/modinfo.c", 125 "toys/other/mountpoint.c", 126 "toys/other/nbd_client.c", 127 "toys/other/nsenter.c", 128 "toys/other/partprobe.c", 129 "toys/other/pivot_root.c", 130 "toys/other/pmap.c", 131 "toys/other/printenv.c", 132 "toys/other/pwdx.c", 133 "toys/other/readlink.c", 134 "toys/other/realpath.c", 135 "toys/other/rev.c", 136 "toys/other/rmmod.c", 137 "toys/other/setfattr.c", 138 "toys/other/setsid.c", 139 "toys/other/stat.c", 140 "toys/other/swapoff.c", 141 "toys/other/swapon.c", 142 "toys/other/sysctl.c", 143 "toys/other/tac.c", 144 "toys/other/taskset.c", 145 "toys/other/timeout.c", 146 "toys/other/truncate.c", 147 "toys/other/uptime.c", 148 "toys/other/usleep.c", 149 "toys/other/uuidgen.c", 150 "toys/other/vconfig.c", 151 "toys/other/vmstat.c", 152 "toys/other/watch.c", 153 "toys/other/which.c", 154 "toys/other/xxd.c", 155 "toys/other/yes.c", 156 "toys/pending/bc.c", 157 "toys/pending/dd.c", 158 "toys/pending/diff.c", 159 "toys/pending/expr.c", 160 "toys/pending/getfattr.c", 161 "toys/pending/gzip.c", 162 "toys/pending/lsof.c", 163 "toys/pending/modprobe.c", 164 "toys/pending/more.c", 165 "toys/pending/stty.c", 166 "toys/pending/tar.c", 167 "toys/pending/tr.c", 168 "toys/pending/traceroute.c", 169 "toys/posix/basename.c", 170 "toys/posix/cal.c", 171 "toys/posix/cat.c", 172 "toys/posix/chgrp.c", 173 "toys/posix/chmod.c", 174 "toys/posix/cksum.c", 175 "toys/posix/cmp.c", 176 "toys/posix/comm.c", 177 "toys/posix/cp.c", 178 "toys/posix/cpio.c", 179 "toys/posix/cut.c", 180 "toys/posix/date.c", 181 "toys/posix/df.c", 182 "toys/posix/dirname.c", 183 "toys/posix/du.c", 184 "toys/posix/echo.c", 185 "toys/posix/env.c", 186 "toys/posix/expand.c", 187 "toys/posix/false.c", 188 "toys/posix/file.c", 189 "toys/posix/find.c", 190 "toys/posix/getconf.c", 191 "toys/posix/grep.c", 192 "toys/posix/head.c", 193 "toys/posix/iconv.c", 194 "toys/posix/id.c", 195 "toys/posix/kill.c", 196 "toys/posix/ln.c", 197 "toys/posix/ls.c", 198 "toys/posix/mkdir.c", 199 "toys/posix/mkfifo.c", 200 "toys/posix/nice.c", 201 "toys/posix/nl.c", 202 "toys/posix/nohup.c", 203 "toys/posix/od.c", 204 "toys/posix/paste.c", 205 "toys/posix/patch.c", 206 "toys/posix/printf.c", 207 "toys/posix/ps.c", 208 "toys/posix/pwd.c", 209 "toys/posix/renice.c", 210 "toys/posix/rm.c", 211 "toys/posix/rmdir.c", 212 "toys/posix/sed.c", 213 "toys/posix/sleep.c", 214 "toys/posix/sort.c", 215 "toys/posix/split.c", 216 "toys/posix/strings.c", 217 "toys/posix/tail.c", 218 "toys/posix/tee.c", 219 "toys/posix/time.c", 220 "toys/posix/touch.c", 221 "toys/posix/true.c", 222 "toys/posix/tty.c", 223 "toys/posix/ulimit.c", 224 "toys/posix/uname.c", 225 "toys/posix/uniq.c", 226 "toys/posix/unlink.c", 227 "toys/posix/uudecode.c", 228 "toys/posix/uuencode.c", 229 "toys/posix/wc.c", 230 "toys/posix/xargs.c", 231 ], 232 233 cflags: [ 234 "-std=gnu11", 235 "-Os", 236 "-Wall", 237 "-Werror", 238 "-Wno-char-subscripts", 239 "-Wno-deprecated-declarations", 240 "-Wno-missing-field-initializers", 241 "-Wno-pointer-arith", 242 "-Wno-sign-compare", 243 "-Wno-string-plus-int", 244 "-Wno-unused-parameter", 245 "-funsigned-char", 246 "-ffunction-sections", 247 "-fdata-sections", 248 "-fno-asynchronous-unwind-tables", 249 "-DTOYBOX_VENDOR=\"-android\"", 250 ], 251 252 // This doesn't actually prevent us from dragging in libc++ at runtime 253 // because libnetd_client.so is C++. 254 stl: "none", 255 256 // not usable on Android?: freeramdisk fsfreeze makedevs nbd-client 257 // partprobe pivot_root pwdx rev rfkill vconfig 258 // currently prefer external/efs2progs: blkid chattr lsattr 259 // currently prefer external/iputils: ping ping6 260 target: { 261 android: { 262 symlinks: [ 263 "acpi", 264 "base64", 265 "basename", 266 "bc", 267 "blockdev", 268 "cal", 269 "cat", 270 "chcon", 271 "chgrp", 272 "chmod", 273 "chown", 274 "chroot", 275 "chrt", 276 "cksum", 277 "clear", 278 "comm", 279 "cmp", 280 "cp", 281 "cpio", 282 "cut", 283 "date", 284 "dd", 285 "devmem", 286 "df", 287 "diff", 288 "dirname", 289 "dmesg", 290 "dos2unix", 291 "du", 292 "echo", 293 "env", 294 "expand", 295 "expr", 296 "fallocate", 297 "false", 298 "file", 299 "find", 300 "flock", 301 "fmt", 302 "free", 303 "fsync", 304 "getconf", 305 "getenforce", 306 "groups", 307 "gunzip", 308 "gzip", 309 "head", 310 "hostname", 311 "hwclock", 312 "i2cdetect", 313 "i2cdump", 314 "i2cget", 315 "i2cset", 316 "iconv", 317 "id", 318 "ifconfig", 319 "inotifyd", 320 "insmod", 321 "install", 322 "ionice", 323 "iorenice", 324 "kill", 325 "killall", 326 "load_policy", 327 "ln", 328 "log", 329 "logname", 330 "losetup", 331 "ls", 332 "lsmod", 333 "lsof", 334 "lspci", 335 "lsusb", 336 "md5sum", 337 "mkdir", 338 "mkfifo", 339 "mknod", 340 "mkswap", 341 "mktemp", 342 "microcom", 343 "modinfo", 344 "modprobe", 345 "more", 346 "mount", 347 "mountpoint", 348 "mv", 349 "nc", 350 "netcat", 351 "netstat", 352 "nice", 353 "nl", 354 "nohup", 355 "nproc", 356 "nsenter", 357 "od", 358 "paste", 359 "patch", 360 "pgrep", 361 "pidof", 362 "pkill", 363 "pmap", 364 "printenv", 365 "printf", 366 "ps", 367 "pwd", 368 "readlink", 369 "realpath", 370 "renice", 371 "restorecon", 372 "rm", 373 "rmdir", 374 "rmmod", 375 "runcon", 376 "sed", 377 "sendevent", 378 "seq", 379 "setenforce", 380 "setprop", 381 "setsid", 382 "sha1sum", 383 "sha224sum", 384 "sha256sum", 385 "sha384sum", 386 "sha512sum", 387 "sleep", 388 "sort", 389 "split", 390 "start", 391 "stat", 392 "stop", 393 "strings", 394 "stty", 395 "swapoff", 396 "swapon", 397 "sync", 398 "sysctl", 399 "tac", 400 "tail", 401 "tar", 402 "taskset", 403 "tee", 404 "time", 405 "timeout", 406 "top", 407 "touch", 408 "tr", 409 "true", 410 "truncate", 411 "tty", 412 "ulimit", 413 "umount", 414 "uname", 415 "uniq", 416 "unix2dos", 417 "unlink", 418 "unshare", 419 "uptime", 420 "usleep", 421 "uudecode", 422 "uuencode", 423 "uuidgen", 424 "vmstat", 425 "watch", 426 "wc", 427 "which", 428 "whoami", 429 "xargs", 430 "xxd", 431 "yes", 432 "zcat", 433 ], 434 }, 435 }, 436} 437 438toybox_libraries = [ 439 "liblog", 440 "libselinux", 441 // libcutils dependency is needed only for <cutils/sched_policy.h> 442 // inclusion from lib/portability.h. When it's changed to include 443 // <processgroup/sched_policy.h> this dependency should be dropped 444 "libcutils", 445 "libprocessgroup", 446 "libcrypto", 447 "libz", 448] 449 450//########################################### 451// toybox for /system, /vendor, and /recovery 452//########################################### 453 454cc_binary { 455 name: "toybox", 456 defaults: ["toybox-defaults"], 457 host_supported: true, 458 recovery_available: true, 459 shared_libs: toybox_libraries, 460 target: { 461 darwin: { 462 enabled: false, 463 }, 464 }, 465} 466 467cc_binary { 468 name: "toybox_vendor", 469 defaults: ["toybox-defaults"], 470 shared_libs: toybox_libraries, 471 vendor: true, 472} 473