Skip to content

Commit

Permalink
Fold okio-files into the main okio artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejesse committed Dec 22, 2020
1 parent e21e897 commit 5cbd353
Show file tree
Hide file tree
Showing 44 changed files with 264 additions and 152 deletions.
40 changes: 40 additions & 0 deletions docs/multiplatform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Multiplatform
=============

Okio is a [Kotlin Multiplatform][kotlin_multiplatform] project. We're still completing our feature
coverage.


### Compression (Deflater, Inflater, Gzip)

JVM-only.


### Concurrency (Pipe, Timeouts, Throttler)

JVM-only.

Timeout is on all platforms, but only the JVM has a useful implementation.


### Core (Buffer, ByteString, Source, Sink)

Available on all platforms.


### Filesystem

Available on all platforms. For JavaScript this requires [Node.js][node_js].


### Hashing

Okio includes Kotlin implementations of MD5, SHA-1, SHA-256, and SHA-512. This includes both hash
functions and HMAC functions.

Okio uses the built-in implementations of these functions on the JVM.


[kotlin_multiplatform]: https://kotlinlang.org/docs/reference/multiplatform.html
[mingw]: http://www.mingw.org/
[node_js]: https://nodejs.org/api/fs.html
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ nav:
- '2.x API': 2.x/okio/okio/index.html
- '1.x API ⏏': https://square.github.io/okio/1.x/okio/
- 'Change Log': changelog.md
- 'Multiplatform': multiplatform.md
- 'Contributing': contributing.md
- 'Code of Conduct': code_of_conduct.md

6 changes: 0 additions & 6 deletions okio-files/README.md

This file was deleted.

100 changes: 0 additions & 100 deletions okio-files/build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions okio-files/gradle.properties

This file was deleted.

9 changes: 7 additions & 2 deletions okio-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ kotlin {
}
}
if (kmpNativeEnabled) {
macosX64()
iosX64()
iosArm64()
watchosArm32()
watchosArm64()
watchosX86()
// Required to generate tests tasks: https://youtrack.jetbrains.com/issue/KT-26547
linuxX64()
macosX64()
mingwX64()
}
sourceSets {
Expand All @@ -33,7 +39,6 @@ kotlin {
api deps.kotlin.stdLib.common
api deps.kotlin.time
api project(":okio")
api project(":okio-files")
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions okio-testing/src/commonMain/kotlin/okio/time.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:JvmName("-Time")
package okio

import kotlinx.datetime.Instant
import kotlin.jvm.JvmName

@JvmName("newFileMetadata")
internal fun FileMetadata(
isRegularFile: Boolean = false,
isDirectory: Boolean = false,
Expand Down
92 changes: 82 additions & 10 deletions okio/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
apply plugin: 'org.jetbrains.kotlin.multiplatform'

/*
* Here's the main hierarchy of variants. Any `expect` functions in one level of the tree are
* `actual` functions in a (potentially indirect) child node.
*
* ```
* common
* |-- jvm
* '-- nonJvm
* |-- js
* '-- native
* |- unix
* | |-- apple
* | | |-- iosArm64
* | | |-- iosX64
* | | |-- macosX64
* | | |-- watchosArm32
* | | |-- watchosArm64
* | | '-- watchosX86
* | '-- linux
* | '-- linuxX64
* '-- mingw
* '-- mingwX64
* ```
*
* Every child of `native` also includes a source set that depends on the pointer size:
*
* * sizet32 for watchOS, including watchOS 64-bit architectures
* * sizet64 for everything else
*
* The `hashFunctions` source set builds on all platforms. It ships as a main source set on non-JVM
* platforms and as a test source set on the JVM platform.
*/
kotlin {
jvm {
withJava()
Expand Down Expand Up @@ -43,6 +75,8 @@ kotlin {
dependencies {
implementation deps.kotlin.test.common
implementation deps.kotlin.test.annotations
implementation deps.kotlin.time
implementation project(":okio-testing")
}
}
nonJvmMain {
Expand All @@ -66,45 +100,83 @@ kotlin {
dependsOn nonJvmMain
dependencies {
api deps.kotlin.stdLib.js
implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7")
}
}
jsTest {
dependencies {
implementation deps.kotlin.test.js
}
}

nativeMain {
dependsOn nonJvmMain
}
nativeTest {
dependsOn commonTest
}
appleMain {
dependsOn nonJvmMain

sizet32Main {
dependsOn nativeMain
}
appleTest {
dependsOn commonTest
sizet64Main {
dependsOn nativeMain
}

mingwMain {
dependsOn nativeMain
}
mingwX64Main {
dependsOn sizet64Main
dependsOn mingwMain
}
mingwX64Test {
dependsOn nativeTest
}

configure([iosX64Main, iosArm64Main, watchosArm32Main, watchosArm64Main, watchosX86Main, linuxX64Main, macosX64Main,
mingwX64Main]) {
unixMain {
dependsOn nativeMain
}
configure([iosX64Test, iosArm64Test, watchosArm32Test, watchosArm64Test, watchosX86Test, linuxX64Test, macosX64Test,
mingwX64Test]) {

appleMain {
dependsOn unixMain
}
appleTest {
dependsOn nativeTest
}
configure([iosX64Main, iosArm64Main, macosX64Main, watchosArm32Main, watchosArm64Main, watchosX86Main]) {
configure([iosX64Main, iosArm64Main, macosX64Main]) {
dependsOn sizet64Main
dependsOn appleMain
}
configure([iosX64Test, iosArm64Test, macosX64Test]) {
dependsOn appleTest
}
configure([watchosArm32Main, watchosArm64Main, watchosX86Main]) {
// Note that size_t is 32-bit on all watchOS versions (ie. pointers are always 32-bit).
dependsOn sizet32Main
dependsOn appleMain
}
configure([iosX64Test, iosArm64Test, watchosArm32Test, watchosArm64Test, watchosX86Test, macosX64Test]) {
configure([watchosArm32Test, watchosArm64Test, watchosX86Test]) {
dependsOn appleTest
}

linuxMain {
dependsOn unixMain
dependsOn nativeMain
}
linuxX64Main {
dependsOn sizet64Main
dependsOn linuxMain
}
linuxX64Test {
dependsOn nativeTest
}
}
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
targetCompatibility = JavaVersion.VERSION_1_8
}

apply from: 'jvm/jvm.gradle'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okio.files
package okio

import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import okio.Buffer
import okio.ByteString.Companion.toByteString
import okio.FakeFilesystem
import okio.Filesystem
import okio.IOException
import okio.Path
import okio.Path.Companion.toPath
import okio.buffer
import okio.use
import kotlin.random.Random
import kotlin.test.BeforeTest
import kotlin.test.Test
Expand Down Expand Up @@ -57,8 +50,9 @@ abstract class AbstractFilesystemTest(
if (filesystem is FakeFilesystem) return
val cwd = filesystem.canonicalize(".".toPath())
assertTrue(cwd.toString()) {
cwd.toString().endsWith("okio${Path.directorySeparator}okio-files") ||
cwd.toString().endsWith("${Path.directorySeparator}okio-okio-files-test")
cwd.toString().endsWith("okio${Path.directorySeparator}okio") ||
cwd.toString().endsWith("${Path.directorySeparator}okio-okio-test") ||
cwd.toString().contains("/CoreSimulator/Devices/")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okio.files
package okio

import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okio.files
package okio

import okio.FakeFilesystem
import okio.Path
import okio.Path.Companion.toPath
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down
Loading

0 comments on commit 5cbd353

Please sign in to comment.