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
Tutorial: Targeting multiple platforms #1075
Conversation
```bash | ||
kotlinc -target ios_arm64 -output bin/ios_arm64 main.kt | ||
``` | ||
to create a binary for fresh iPhone supporting arm64. |
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.
Add something like:
Native executable bin/ios_x64.kexe will be produced, check that with file bin/ios_x64.kexe
.
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.
👍
for those OSes. So on each of the operation systems we call the compiler: | ||
|
||
```bash | ||
kotlinc main.kt |
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.
Better specify -o, otheriwse it's pretty hard to guess where output will go.
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.
fixed
kotlinc main.kt | ||
``` | ||
|
||
There is no need to specify `-target` parameter explicitly, because |
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.
Replace with smth like: "If no -target option specified, native executable for host platform where compiler was executed is produced, which matches behavior of other native compilers".
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.
Done. Simplified a bit
The
-target
parameter is optional. If it is not included, the binary will be produced for the system, where the compiler is executed. It matches the behavior of other native compilers.
Including @B1ggDave to help us to check the language |
issue: EVAN-5121 | ||
--- | ||
|
||
With Kotlin/Native can compile a native binary for |
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.
"With Kotlin/Native can compile a native binary for"
either of these works:
With Kotlin/Native, you can compile a native binary for
With Kotlin/Native, it is possible to compile a native binary for
|
||
* [Specify a Target Platform](#specifying-target-platform) | ||
* [Build for a Specific Platform](#building-for-a-specific-platform) | ||
* [Build a Console Utility for several OSes](#building-a-console-utility) |
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.
"OSes"
consider:
OS's
Operating Systems
* [Build for a Specific Platform](#building-for-a-specific-platform) | ||
* [Build a Console Utility for several OSes](#building-a-console-utility) | ||
|
||
We need to have Kotlin/Native compiler on our machines. |
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.
+We need to have a Kotlin/Native compiler on our machines.
We need to have Kotlin/Native compiler on our machines. | ||
You may have a look at the | ||
[A Basic Kotlin/Native Application](basic-kotlin-native-app.html#obtaining-the-compiler) | ||
tutorial for more information in that step. |
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.
+tutorial for more information on performing this step.
zephyr_stm32f4_disco: | ||
``` | ||
|
||
The set of targets of Kotlin/Native compiler depends on the host operating system. |
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 set of targets for the Kotlin/Native compiler depends on the host operating system.
``` | ||
|
||
The set of targets of Kotlin/Native compiler depends on the host operating system. | ||
We may specify target explicitly with `-target <name>` argument. The default target |
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.
We may specify a target explicitly with a '-target ' argument.
tutorial for more information in that step. | ||
Let's assume we have a console, where `kotlinc` (or the older `konanc`) command is available. | ||
|
||
## Specifying Target Platform |
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.
Specifying a Target Platform
|
||
## Building for a Specific Platform | ||
|
||
Let's create a sample Kotlin/Native program and save it as `main.kt`. You may see the previous tutorial |
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.
You may want to have a look at the tutorial A Basic Kotlin/Native Application for more details.
You can see the previous tutorial A Basic Kotlin/Native Application for more details.
} | ||
``` | ||
|
||
We use `-target` argument of the `kotlinc` to specify the platform. It is also |
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.
We use the -target
argument from the kotlinc
to specify the platform.
|
||
We use `-target` argument of the `kotlinc` to specify the platform. It is also | ||
helpful to use `-output` to explicitly instruct | ||
the compiler on where to create the compiled binary, e.g., to build for the iOS emulator on macOS we use: |
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 compiler on where to create the compiled binary, for example, to build for the iOS emulator on macOS we use:
you use for example throughout the page, this e.g. seemed out of place.
```bash | ||
kotlinc -target ios_arm64 -output bin/ios_arm64 main.kt | ||
``` | ||
to create a binary for fresh iPhone supporting arm64. |
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.
to create a binary for the fresh iPhone supporting arm64.
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.
Used
to create a binary for an iPhone supporting arm64.
|
||
## Building a Console Utility | ||
|
||
We saw above that the set of supported target platforms depends on the host operating system. |
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.
+Running the compiler on Windows, macOS, and Linux is required to create a console application
+for these Operating Systems. On each of the operating system we call the compiler:
may be used to automate and simplify the process. | ||
|
||
## Next Steps | ||
|
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.
+Build tools help to deal with compiler arguments. You might want to consider
+using Gradle build system for your project.
+Gradle with the Kotlin/Native plugin simplifies the setup for each operating system, just download and run the
+Kotlin/Native compiler and it will be even more pleasant for you.
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 was intended to mean a bit different: Gradle ... downloads and runs ...
Fixed it in the other way
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.
added in some suggestions for the text to consider. :)
@B1ggDave I've included fixed your comments |
I've squashed and merged the branch into master to follow commit message guidelines |
https://youtrack.jetbrains.com/issue/EVAN-5121