Rewrite build_clcore.
Change-Id: I1241e66ec691ebb419728042e873ea5f0d337b50
diff --git a/lib/runtime/build_clcore.sh b/lib/runtime/build_clcore.sh
index e07b83e..faa27c9 100755
--- a/lib/runtime/build_clcore.sh
+++ b/lib/runtime/build_clcore.sh
@@ -1,29 +1,17 @@
#!/bin/sh
+# Usually, manually running build_clcore.sh shouldn't be needed. build_clcore.mk should
+# kick in automatically during Android build process.
+
# Generate rs_cl.bc
# =================
-cp ../../../../base/libs/rs/scriptc/rs_cl.rsh rs_cl.h
-sed -e 's/static/extern/' rs_cl.h > rs_cl_extern.h
-
-rm rs_cl.h
-
-clang -O3 rs_cl.c -emit-llvm -S -o rs_cl.ll
-
-llvm-as rs_cl.ll
+clang -c -O3 rs_cl.c -emit-llvm -o rs_cl.bc
# Generate rs_core.bc
# ===================
-cp ../../../../base/libs/rs/scriptc/rs_core.rsh rs_core.h
-
-sed -e 's/extern/static/' rs_core.h > rs_core_extern.h
-
-rm rs_core.h
-
-clang -O3 rs_core.c -emit-llvm -S -o rs_core.ll
-
-llvm-as rs_core.ll
+clang -c -O3 rs_core.c -emit-llvm -o rs_core.bc
# Link everything together
# ========================
diff --git a/lib/runtime/rs_cl.c b/lib/runtime/rs_cl.c
index ca70e59..5d008b8 100644
--- a/lib/runtime/rs_cl.c
+++ b/lib/runtime/rs_cl.c
@@ -1,3 +1,5 @@
#include "../../../../base/libs/rs/scriptc/rs_types.rsh"
-#include "rs_cl_extern.h"
+#define BCC_PREPARE_BC 1
+#include "../../../../base/libs/rs/scriptc/rs_cl.rsh"
+
diff --git a/lib/runtime/rs_core.c b/lib/runtime/rs_core.c
index 4ae1580..f352cda 100644
--- a/lib/runtime/rs_core.c
+++ b/lib/runtime/rs_core.c
@@ -7,4 +7,5 @@
extern float4 __attribute__((overloadable)) convert_float4(uchar4 c);
-#include "rs_core_extern.h"
+#define BCC_PREPARE_BC 1
+#include "../../../../base/libs/rs/scriptc/rs_core.rsh"