Skip to content

Commit 8a8658a

Browse files
egnorAndroid (Google) Code Review
authored andcommitted
Merge "Make static versions of libutils and libbinder." into froyo
2 parents 08e1b94 + 08b3d2e commit 8a8658a

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

include/binder/Binder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class BBinder : public IBinder
7171

7272
Extras* mExtras;
7373
void* mReserved0;
74-
static String16 sEmptyDescriptor;
7574
};
7675

7776
// ---------------------------------------------------------------------------

libs/binder/Android.mk

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,35 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
LOCAL_PATH:= $(call my-dir)
16-
include $(CLEAR_VARS)
17-
1815
# we have the common sources, plus some device-specific stuff
19-
LOCAL_SRC_FILES:= \
20-
Binder.cpp \
21-
BpBinder.cpp \
22-
IInterface.cpp \
23-
IMemory.cpp \
24-
IPCThreadState.cpp \
25-
IPermissionController.cpp \
26-
IServiceManager.cpp \
27-
MemoryDealer.cpp \
16+
sources := \
17+
Binder.cpp \
18+
BpBinder.cpp \
19+
IInterface.cpp \
20+
IMemory.cpp \
21+
IPCThreadState.cpp \
22+
IPermissionController.cpp \
23+
IServiceManager.cpp \
24+
MemoryDealer.cpp \
2825
MemoryBase.cpp \
2926
MemoryHeapBase.cpp \
3027
MemoryHeapPmem.cpp \
31-
Parcel.cpp \
32-
Permission.cpp \
33-
ProcessState.cpp \
34-
Static.cpp
35-
36-
LOCAL_LDLIBS += -lpthread
37-
38-
LOCAL_SHARED_LIBRARIES := \
39-
liblog \
40-
libcutils \
41-
libutils
28+
Parcel.cpp \
29+
Permission.cpp \
30+
ProcessState.cpp \
31+
Static.cpp
4232

43-
LOCAL_MODULE:= libbinder
33+
LOCAL_PATH:= $(call my-dir)
4434

35+
include $(CLEAR_VARS)
36+
LOCAL_LDLIBS += -lpthread
37+
LOCAL_MODULE := libbinder
38+
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
39+
LOCAL_SRC_FILES := $(sources)
4540
include $(BUILD_SHARED_LIBRARY)
41+
42+
include $(CLEAR_VARS)
43+
LOCAL_LDLIBS += -lpthread
44+
LOCAL_MODULE := libbinder
45+
LOCAL_SRC_FILES := $(sources)
46+
include $(BUILD_STATIC_LIBRARY)

libs/binder/Binder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class BBinder::Extras
6969

7070
// ---------------------------------------------------------------------------
7171

72-
String16 BBinder::sEmptyDescriptor;
73-
7472
BBinder::BBinder()
7573
: mExtras(NULL)
7674
{
@@ -88,6 +86,9 @@ status_t BBinder::pingBinder()
8886

8987
const String16& BBinder::getInterfaceDescriptor() const
9088
{
89+
// This is a local static rather than a global static,
90+
// to avoid static initializer ordering issues.
91+
static String16 sEmptyDescriptor;
9192
LOGW("reached BBinder::getInterfaceDescriptor (this=%p)", this);
9293
return sEmptyDescriptor;
9394
}

libs/utils/Android.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,13 @@ endif # sim
104104
LOCAL_MODULE:= libutils
105105
include $(BUILD_SHARED_LIBRARY)
106106

107+
ifneq ($(TARGET_SIMULATOR),true)
108+
ifeq ($(TARGET_OS),linux)
109+
include $(CLEAR_VARS)
110+
LOCAL_C_INCLUDES += external/zlib external/icu4c/common
111+
LOCAL_LDLIBS := -lrt -ldl -lpthread
112+
LOCAL_MODULE := libutils
113+
LOCAL_SRC_FILES := $(commonSources) BackupData.cpp BackupHelpers.cpp
114+
include $(BUILD_STATIC_LIBRARY)
115+
endif
116+
endif

libs/utils/String8.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ static inline char* getEmptyString()
136136

137137
void initialize_string8()
138138
{
139-
#ifdef LIBUTILS_NATIVE
140-
// Bite me, Darwin!
141-
gDarwinIsReallyAnnoying = gDarwinCantLoadAllObjects;
142-
#endif
139+
// HACK: This dummy dependency forces linking libutils Static.cpp,
140+
// which is needed to initialize String8/String16 classes.
141+
// These variables are named for Darwin, but are needed elsewhere too,
142+
// including static linking on any platform.
143+
gDarwinIsReallyAnnoying = gDarwinCantLoadAllObjects;
143144

144145
SharedBuffer* buf = SharedBuffer::alloc(1);
145146
char* str = (char*)buf->data();

0 commit comments

Comments
 (0)