aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.bp92
l---------LICENSE1
-rw-r--r--METADATA15
-rw-r--r--OWNERS1
-rw-r--r--TEST_MAPPING7
-rwxr-xr-xrun-bc-tests-on-android.sh16
6 files changed, 132 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 00000000..7d7afe24
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,92 @@
+package {
+ default_applicable_licenses: ["external_bc_license"],
+}
+
+license {
+ name: "external_bc_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-MIT",
+ ],
+ license_text: [
+ "LICENSE.md",
+ "NOTICE.md",
+ ],
+}
+
+cc_defaults {
+ name: "bc-defaults",
+
+ cflags: [
+ "-include bc-version.h",
+ "-DBC_ENABLED=1",
+ "-DDC_ENABLED=0",
+ "-DBC_ENABLE_EXTRA_MATH=0",
+ "-DBC_ENABLE_HISTORY=0",
+ "-DBC_ENABLE_NLS=0",
+ "-Os",
+ ],
+ generated_headers: ["bc-version.h"],
+ local_include_dirs: ["include"],
+ srcs: [
+ "src/bc/*.c",
+ "src/*.c",
+ ":bc-bc_help.c",
+ ":bc-lib.c",
+ ],
+ stl: "none",
+}
+
+genrule {
+ name: "bc-lib.c",
+ srcs: ["gen/lib.bc"],
+ out: ["gen/lib.c"],
+ tool_files: ["gen/strgen.sh"],
+ cmd: "$(location gen/strgen.sh) $(in) $(out) bc_lib bc_lib_name BC_ENABLED",
+}
+
+genrule {
+ name: "bc-bc_help.c",
+ srcs: ["gen/bc_help.txt"],
+ out: ["gen/bc_help.c"],
+ tool_files: ["gen/strgen.sh"],
+ cmd: "$(location gen/strgen.sh) $(in) $(out) bc_help '' BC_ENABLED",
+}
+
+genrule {
+ name: "bc-version.h",
+ srcs: ["Makefile.in"],
+ out: ["bc-version.h"],
+ cmd: "sed -n 's/VERSION = /#define VERSION /p' $(in) > $(out)",
+}
+
+cc_binary {
+ name: "bc",
+ defaults: ["bc-defaults"],
+}
+
+cc_binary {
+ name: "bc_vendor",
+ defaults: ["bc-defaults"],
+ stem: "bc",
+ vendor: true,
+}
+
+cc_binary_host {
+ name: "gavinhoward-bc",
+ defaults: ["bc-defaults"],
+}
+
+sh_test {
+ name: "bc-tests",
+ src: "run-bc-tests-on-android.sh",
+ filename: "run-bc-tests-on-android.sh",
+ test_suites: ["general-tests"],
+ host_supported: true,
+ device_supported: false,
+ data: [
+ "scripts/functions.sh",
+ "tests/**/*",
+ ],
+}
diff --git a/LICENSE b/LICENSE
new file mode 120000
index 00000000..f0c42986
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+LICENSE.md \ No newline at end of file
diff --git a/METADATA b/METADATA
new file mode 100644
index 00000000..8c235963
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,15 @@
+name: "gavinhoward/bc"
+description: "An implementation of the POSIX bc calculator with GNU extensions and dc."
+third_party {
+ url {
+ type: GIT
+ value: "https://github.com/gavinhoward/bc"
+ }
+ version: "5.0.1"
+ license_type: NOTICE
+ last_upgrade_date {
+ year: 2021
+ month: 8
+ day: 13
+ }
+}
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 00000000..7529cb92
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/system/core:/janitors/OWNERS
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 00000000..c05ac950
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "bc-tests"
+ }
+ ]
+}
diff --git a/run-bc-tests-on-android.sh b/run-bc-tests-on-android.sh
new file mode 100755
index 00000000..10170bfd
--- /dev/null
+++ b/run-bc-tests-on-android.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Copy the tests across.
+adb shell rm -rf /data/local/tmp/bc-tests/
+adb shell mkdir /data/local/tmp/bc-tests/
+adb shell mkdir /data/local/tmp/bc-tests/scripts/
+adb push tests/ /data/local/tmp/bc-tests/
+adb push scripts/functions.sh /data/local/tmp/bc-tests/scripts/
+
+if tty -s; then
+ dash_t="-t"
+else
+ dash_t=""
+fi
+
+exec adb shell $dash_t /data/local/tmp/bc-tests/tests/all.sh bc 0 1 0 0 bc