-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Added build-android script #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
.gitignore
Outdated
@@ -20,3 +20,6 @@ Build | |||
*.swp | |||
*.orig | |||
.arcconfig | |||
|
|||
*.tgz | |||
build.ninjae |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this, why not change the sed script so that you're using an already known extension like ~ which will be ignored? Then you don't need to add this.
@@ -1325,11 +1325,13 @@ CF_SWIFT_EXPORT void _CFThreadSetName(const char *_Nullable name) { | |||
} | |||
|
|||
CF_SWIFT_EXPORT int _CFThreadGetName(char *buf, int length) { | |||
#if !TARGET_OS_ANDROID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than wrapping this in an if !
construct, why not add an #elif TARGET_OS_ANDROID
above the #elif DEPLOYMENT_TARGET_LINUX
line? Then there's a sensible place to add implementations in the future should it be needed.
Also, do you know why the variable is TARGET_OS_ANDROID rather than DEPLOYMENT_TARGET_ANDROID?
@@ -27,7 +27,10 @@ | |||
#include <CoreFoundation/ForFoundationOnly.h> | |||
#include <fts.h> | |||
#include <pthread.h> | |||
|
|||
#if !TARGET_OS_ANDROID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would using the other syntax of #if __has_include(<execinfo.h>)
work here, to keep it in line with the other tests?
build-android
Outdated
-DLIBDISPATCH_BUILD_DIR=$SWIFT_PATH/swift-corelibs-libdispatch && | ||
|
||
cp -r /usr/include/uuid $ANDROID_STANDALONE_SYSROOT/usr/include | ||
sed -ie "s/-I.\/ -I\/usr\/include\/x86_64-linux-gnu -I\/usr\/include\/x86_64-linux-gnu -I\/usr\/include\/libxml2//" build.ninja |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(From above) if this was sed -i~
instead, you would generate build.ninja~
as the backup file, which would automatically be excluded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about if I just do "sed -i" will it edit without backup? I don't need to generate backup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amraboelela Yes it should do, from the manage:
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen some versions of using sed -i
when you don't explicitly specify an extension, but it then takes the following word from the command line and uses that as the extension itself. I would recommend using sed -i~
so that the backups aren't committed to git (the *~
pattern is already in the .gitattributes
file) and it avoids any versions of sed
where running sed -i something
doesn't get translated as "use something as the backup extension".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks outstanding from GitHub's diffs?
.gitignore
Outdated
@@ -20,3 +20,6 @@ Build | |||
*.swp | |||
*.orig | |||
.arcconfig | |||
|
|||
*.tgz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what this is blocking here, and would prevent people adding .tgz examples in the future (for example). Can you explain why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to know why this *.tgz is here. Can you remove this from the commit or justify why it's necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the .tgz, change the sed -ie to sed -i~, and rebase the changes (not via merge) so that we can clearly see what's added?
The changes seem to imply more than was originally added, but it's not clear if that's due to the merge and GitHub showing the differences. A clean rebase without the empty merge node and fixing the minor issues should help.
.gitignore
Outdated
@@ -20,3 +20,6 @@ Build | |||
*.swp | |||
*.orig | |||
.arcconfig | |||
|
|||
*.tgz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to know why this *.tgz is here. Can you remove this from the commit or justify why it's necessary?
build-android
Outdated
-DLIBDISPATCH_BUILD_DIR=$SWIFT_PATH/swift-corelibs-libdispatch && | ||
|
||
cp -r /usr/include/uuid $ANDROID_STANDALONE_SYSROOT/usr/include | ||
sed -ie "s/-I.\/ -I\/usr\/include\/x86_64-linux-gnu -I\/usr\/include\/x86_64-linux-gnu -I\/usr\/include\/libxml2//" build.ninja |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks outstanding from GitHub's diffs?
11df58b
to
a406011
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the .gitignore so that it doesn't make any changes to this commit?
Also, can you rebase the code onto master and get rid of the merge nodes so that we can see what is happening? The merge node committed previously makes it a little unclear as to what is here. Doing a git pull --rebase
should fix this up.
.gitignore
Outdated
@@ -20,3 +20,4 @@ Build | |||
*.swp | |||
*.orig | |||
.arcconfig | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn't need to be changed, and the addition of a newline doesn't add any value. Can you revert the file to what it was beforehand?
02cee11
to
a406011
Compare
I am now using -i~ but git status gives: (use "git add ..." to include in what will be committed)
Also I am not able to rebase the branch correctly. |
096cb57
to
2573116
Compare
I am finally able to rebase it after fixing the conflicts :) |
@swift-ci please test |
1 similar comment
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be a pain - just when all the tests had run successfully, too :)
The TestNSLock.swift has ended up reverting a recent PR - can you remove this change from your request?
TestFoundation/TestNSLock.swift
Outdated
@@ -41,14 +41,11 @@ class TestNSLock: XCTestCase { | |||
} | |||
|
|||
let thread = Thread() { | |||
lock.lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to revert #1261 presumably accidentally. Can you remove this file from this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's some more edits required anyway, here's some drive-by formatting nits.
Foundation/Host.swift
Outdated
@@ -28,6 +28,10 @@ open class Host: NSObject { | |||
internal var _names = [String]() | |||
internal var _addresses = [String]() | |||
|
|||
#if os(Android) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: #if
and #endif
should be de-indented (no spaces at the beginning of the line before #
) and the enclosed statements should be indented as though it isn't surrounded by a compile-time condition (that is, static internal let NI_MAXHOST
here should align with static internal let _current
).
Foundation/Host.swift
Outdated
@@ -36,7 +40,7 @@ open class Host: NSObject { | |||
} | |||
|
|||
static internal func currentHostName() -> String { | |||
let hname = UnsafeMutablePointer<Int8>.allocate(capacity: Int(NI_MAXHOST)) | |||
let hname = UnsafeMutablePointer<Int8>.allocate(capacity: Int(NI_MAXHOST)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore the original indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one as well.
Foundation/Host.swift
Outdated
@@ -65,6 +69,9 @@ open class Host: NSObject { | |||
} | |||
|
|||
internal func _resolveCurrent() { | |||
#if os(Android) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nit as above about indentation of #if
and #endif
.
Foundation/Host.swift
Outdated
@@ -65,6 +69,9 @@ open class Host: NSObject { | |||
} | |||
|
|||
internal func _resolveCurrent() { | |||
#if os(Android) | |||
return | |||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise with indentation of #else
.
Foundation/Thread.swift
Outdated
@@ -256,7 +256,11 @@ open class Thread : NSObject { | |||
let maxSupportedStackDepth = 128; | |||
let addrs = UnsafeMutablePointer<UnsafeMutableRawPointer?>.allocate(capacity: maxSupportedStackDepth) | |||
defer { addrs.deallocate(capacity: maxSupportedStackDepth) } | |||
#if os(Android) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nit here about indentation of #if
, #else
and #endif
.
Foundation/Thread.swift
Outdated
@@ -270,6 +274,9 @@ open class Thread : NSObject { | |||
} | |||
|
|||
open class var callStackSymbols: [String] { | |||
#if os(Android) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nit here about #if
, #else
and #endif
; please also de-indent return []
by four spaces so that it aligns with return backtraceAddresses
.
@amraboelela There was another change recently from @johnno1962 that was merged yesterday regarding Android support: #1189 Can you rebase the changes on top of these and test that your changes still make sense? I'm not sure if there's overlap (the lack of conflicts suggests not) but it would be worth verifying it for Android support. Separately, if you're interested, you can configure your git repository with If you're doing local changes, you might also want to use The above will apply to the single repository that you run in; if you want them to apply to all repositories, run Finally, keep up the good work. I know there's been a lot of back-and-forth on this, as well as delays, for which I apologise. I am working to clear the backlog and want to merge these changes in so keep going👍🏻 |
4d5bc3f
to
2ba419d
Compare
All good now? |
@alblue did Apple assign you the task of "cleaning out" all the PRs in Foundation? :) What about swift repo, I have a related PR there needs to get moving: swiftlang/swift#11870 And also in libdispatch: swiftlang/swift-corelibs-libdispatch#302 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor nits - @xwu might be able to clarify the indentation specifics too
Foundation/Host.swift
Outdated
} | ||
|
||
internal func _resolve() { | ||
#if os(Android) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the indentation of this return doesn't line up - it should be one indent to the right, I think. @xwu can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, return
needs four additional preceding spaces.
.gitignore
Outdated
@@ -10,6 +10,7 @@ project.xcworkspace | |||
|
|||
# build files generated by the configure script | |||
*.ninja | |||
*.ninja~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're making other changes to this script, I'd suggest putting *~ at the top of the file and removing this line. That way any backup file won't get committed. It's a fairly standard thing to have in Linux repos, but tends to be forgotten on Mac ones.
See e.g. https://github.com/github/gitignore/blob/master/Global/Linux.gitignore#L1
Foundation/Host.swift
Outdated
@@ -28,6 +28,10 @@ open class Host: NSObject { | |||
internal var _names = [String]() | |||
internal var _addresses = [String]() | |||
|
|||
#if os(Android) | |||
static internal let NI_MAXHOST = 1025 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line looks like it doesn't line up with the static internal let
below - can you indent it to the left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't forget to address this comment
Foundation/Thread.swift
Outdated
@@ -270,6 +274,9 @@ open class Thread : NSObject { | |||
} | |||
|
|||
open class var callStackSymbols: [String] { | |||
#if os(Android) | |||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the return here should line up with the return
of the return backtraceAddresses
below. It's not rendering as that in the GitHub UI. Maybe a mix of tabs and spaces causing problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all spaces here, but agree that return
needs to be de-indented four spaces.
No, I'm just trying to help clear out the queue :) |
One other thing might help - there's two sorts of changes here; stubbing out APIs that don't work on Android, and the build script to help build it. Can we split those into two PRs? The build-script and the .gitignore can go in one and the fixes to help it build in another. In swift's swiftlang/swift#11870 repo there seems to be a proposal of moving towards a CMake instead of autotools for building the code. Is that an approach we can think of using here? |
If we don’t include those changes, the build would give errors, so they should go together. |
The cmake proposal is for libdispatch I think. But the cmake script is not ready yet, so I suggest to keep the autoconf build script for now. |
I was thinking, maybe we commit the code changes first, then have the build script as a dependent change.
OK. We don't have a CMake list for now in foundation, so that makes sense. It would be interesting to know how much it would be to convert it to CMake in the future. Maybe that's something that @compnerd could advise with. |
@swift-ci please test |
|
||
#if __has_include(<malloc/malloc.h>) | ||
#include <malloc/malloc.h> | ||
#if __has_include(<execinfo.h>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is going on here now? Why is execinfo.h being conditionally included twice?
6653b57
to
ad169db
Compare
@@ -343,6 +343,9 @@ open class FileManager : NSObject { | |||
This method replaces fileSystemAttributesAtPath:. | |||
*/ | |||
open func attributesOfFileSystem(forPath path: String) throws -> [FileAttributeKey : Any] { | |||
#if os(Android) | |||
NSUnimplemented() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this line, NSUnimplemented()
means 'This hasn't been implemented yet, but it will be in the future' - whereas NSUnsupported()
means that 'This will not be implemented on this platform'. Can you confirm this is intended to be implemented in the future? If not, using NSUnsupported()
would be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep it NSUnimplemented
, as someone later should be able to implement it in Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Foundation/Thread.swift
Outdated
@@ -256,7 +256,11 @@ open class Thread : NSObject { | |||
let maxSupportedStackDepth = 128; | |||
let addrs = UnsafeMutablePointer<UnsafeMutableRawPointer?>.allocate(capacity: maxSupportedStackDepth) | |||
defer { addrs.deallocate(capacity: maxSupportedStackDepth) } | |||
#if os(Android) | |||
let count = maxSupportedStackDepth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The count here is the number of successful frames returned by backtrace
, and that they've been filled in by the caller. Since they won't have been any returned, isn't 0 the correct answer in the face of not being implemented? Admittedly this is being stubbed out from the caller below, but if it gets added elsewhere later then it would be better if this didn't contain a known bad number.
build-android
Outdated
|
||
set -e | ||
|
||
cd "$(dirname $0)/.." || exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small observation; this changes the directory you're currently in. If you wanted to just find out what directory you are in, you can do it in parenthesis e.g.
@swift-ci please test |
1 similar comment
@swift-ci please test |
74fd485
to
59c4cbe
Compare
51bbadb
to
b42c144
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test and merge |
Yeaaah :) |
No description provided.