Skip to content

Commit 60e6b73

Browse files
committed
Better logging and restructuring
1 parent 546cad2 commit 60e6b73

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

CoreFoundation/Base.subproj/CFUtilities.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,24 @@ void CFLog(CFLogLevel lev, CFStringRef format, ...) {
768768
// Temporary as Swift cannot import varag C functions
769769
void CFLog1(CFLogLevel lev, CFStringRef message) {
770770
#ifdef __ANDROID__
771-
UInt8 buffer[4096];
772-
CFIndex usedBufLen = sizeof buffer-1;
773-
CFStringGetBytes(message, CFRangeMake(0, CFStringGetLength(message)),
774-
kCFStringEncodingUTF8, ' ', FALSE, buffer, usedBufLen, &usedBufLen);
775-
buffer[usedBufLen] = '\000';
776-
__android_log_print(ANDROID_LOG_INFO, "Swift", "%s", buffer);
771+
android_LogPriority priority = ANDROID_LOG_UNKNOWN;
772+
switch ( lev ) {
773+
case kCFLogLevelEmergency: priority = ANDROID_LOG_FATAL; break;
774+
case kCFLogLevelAlert: priority = ANDROID_LOG_ERROR; break;
775+
case kCFLogLevelCritical: priority = ANDROID_LOG_ERROR; break;
776+
case kCFLogLevelError: priority = ANDROID_LOG_ERROR; break;
777+
case kCFLogLevelWarning: priority = ANDROID_LOG_WARN; break;
778+
case kCFLogLevelNotice: priority = ANDROID_LOG_WARN; break;
779+
case kCFLogLevelInfo: priority = ANDROID_LOG_INFO; break;
780+
case kCFLogLevelDebug: priority = ANDROID_LOG_DEBUG; break;
781+
}
782+
CFIndex blen = message ? CFStringGetMaximumSizeForEncoding(CFStringGetLength(message), kCFStringEncodingUTF8) + 1 : 0;
783+
char *buf = message ? (char *)malloc(blen) : 0;
784+
if ( buf ) {
785+
CFStringGetCString(message, buf, blen, kCFStringEncodingUTF8);
786+
__android_log_print(priority, "Swift", "%s", buf);
787+
free( buf );
788+
}
777789
#else
778790
CFLog(lev, CFSTR("%@"), message);
779791
#endif

lib/script.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ def generate_products(self):
3939
if Configuration.current.verbose:
4040
verbose_flags += "-v"
4141
verbose_flags += "\n"
42-
triple = Configuration.current.target.triple
42+
swift_triple = Configuration.current.target.swift_triple
4343
base_flags = """
44-
TARGET = """ + triple + """
44+
TARGET = """ + Configuration.current.target.triple + """
4545
DSTROOT = """ + Configuration.current.install_directory.absolute() + """
4646
"""
47-
swift_triple = triple if triple == "armv7-none-linux-androideabi" else Configuration.current.target.swift_triple
4847
if swift_triple is not None:
4948
base_flags += """
50-
SWIFT_TARGET = """ + swift_triple + """
49+
SWIFT_TARGET = """ + Configuration.current.target.swift_triple + """
5150
SWIFT_ARCH = """ + Configuration.current.target.swift_arch + """
5251
"""
5352
base_flags += """
@@ -131,10 +130,10 @@ def generate_products(self):
131130

132131

133132
ld_flags = """
134-
EXTRA_LD_FLAGS = """ + Configuration.current.extra_ld_flags
133+
EXTRA_LD_FLAGS = """ + Configuration.current.extra_ld_flags
135134

136135
ld_flags += """
137-
TARGET_LDFLAGS = --target=${TARGET} ${EXTRA_LD_FLAGS} -L${SDKROOT}/lib/swift/""" + Configuration.current.target.swift_sdk_name + """ """
136+
TARGET_LDFLAGS = --target=${TARGET} ${EXTRA_LD_FLAGS} -L${SDKROOT}/lib/swift/""" + Configuration.current.target.swift_sdk_name + """ """
138137
if Configuration.current.system_root is not None:
139138
ld_flags += "--sysroot=${SYSROOT}"
140139

lib/target.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ def swift_triple(self):
380380
elif self.sdk == OSType.Linux:
381381
# FIXME: It would be nice to detect the host ABI here
382382
if (self.arch == ArchType.armv6) or (self.arch == ArchType.armv7):
383-
triple += "-unknown-linux-gnueabihf"
383+
if Configuration.current.target.triple == "armv7-none-linux-androideabi":
384+
triple = Configuration.current.target.triple
385+
else:
386+
triple += "-unknown-linux-gnueabihf"
384387
else:
385388
triple += "-unknown-linux"
386389
elif self.sdk == OSType.FreeBSD:

0 commit comments

Comments
 (0)