Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise they would be ignored according .gitignore settings. Probably they should be deleted from repo. Interop/.idea/compiler.xml Interop/.idea/gradle.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml Interop/.idea/modules.xml Interop/.idea/modules/Indexer/Indexer.iml Interop/.idea/modules/Runtime/Runtime.iml Interop/.idea/modules/StubGenerator/StubGenerator.iml backend.native/backend.native.iml backend.native/bc.frontend/bc.frontend.iml backend.native/cli.bc/cli.bc.iml backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt backend.native/tests/link/lib/foo.kt backend.native/tests/link/lib/foo2.kt backend.native/tests/teamcity-test.property
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.8.2)
|
||||
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(NONE)
|
||||
|
||||
add_library(libsupcpp STATIC IMPORTED)
|
||||
|
||||
set_property(TARGET libsupcpp PROPERTY IMPORTED_LOCATION $ENV{GNUARMEMB_TOOLCHAIN_PATH}/arm-none-eabi/lib/thumb/libsupc++.a)
|
||||
|
||||
target_link_libraries(app PRIVATE libsupcpp)
|
||||
|
||||
set_property(TARGET app PROPERTY LINKER_LANGUAGE C)
|
||||
|
||||
target_sources(app PRIVATE build/program.o)
|
||||
|
||||
set_source_files_properties(program.o PROPERTIES EXTERNAL_OBJECT true GENERATED true)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT program.o
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_BINARY_DIR}/kotlin/program.o
|
||||
${CMAKE_BINARY_DIR}/program.o
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set BOARD=stm32f4_disco
|
||||
set ZEPHYR_BASE=%userprofile%\zephyr
|
||||
set TOOLCHAIN=gcc-arm-none-eabi-7-2017-q4-major-win32
|
||||
|
||||
set DIR=%~dp0
|
||||
if "%KONAN_DATA_DIR%"=="" (set KONAN_DATA_DIR=%userprofile%\.konan)
|
||||
set KONAN_DEPS=%KONAN_DATA_DIR%/dependencies
|
||||
set GNU_ARM=%KONAN_DEPS%/%TOOLCHAIN%
|
||||
set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
|
||||
set GNUARMEMB_TOOLCHAIN_PATH=%GNU_ARM%
|
||||
|
||||
if defined KONAN_HOME (
|
||||
set "PATH=%KONAN_HOME%\bin;%PATH%"
|
||||
) else (
|
||||
set "PATH=%DIR%..\..\dist\bin;%DIR%..\..\bin;%PATH%"
|
||||
)
|
||||
|
||||
if not exist build\ (mkdir build)
|
||||
cd build
|
||||
|
||||
if not exist CMakeCache.txt (cmake -GNinja -DBOARD=%BOARD% .. || exit /b)
|
||||
|
||||
:: We need generated headers to be consumed by `cinterop`,
|
||||
:: so we preconfigure the project with `make zephyr`.
|
||||
ninja zephyr
|
||||
|
||||
call %DIR%\c_interop\platforms\%BOARD%.bat
|
||||
|
||||
del program.o
|
||||
|
||||
mkdir %DIR%\build\kotlin
|
||||
|
||||
call konanc %DIR%/src/main.kt ^
|
||||
-target zephyr_%BOARD% ^
|
||||
-r %DIR%/c_interop/platforms/build ^
|
||||
-l %BOARD% ^
|
||||
-opt -g -o %DIR%/build/kotlin/program || exit /b
|
||||
|
||||
ninja || exit /b
|
||||
|
||||
:: ninja flash
|
||||
::
|
||||
:: For our STM32 boards the OpenOCD unable to flash the binary,
|
||||
:: so we go with the following alternative utility:
|
||||
|
||||
echo.
|
||||
echo Now run 'ninja flash' to flash the .bin to the card.
|
||||
echo.
|
||||
echo Or, if that doesn't work, like, for example if you have an stm32f4-disco,
|
||||
echo run the following command:
|
||||
echo st-flash --reset write build/zephyr/zephyr.bin 0x08000000
|
||||
echo.
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BOARD=stm32f4_disco
|
||||
export ZEPHYR_BASE="PLEASE_SET_ZEPHYR_BASE"
|
||||
# By default `modules` directory is installed alongside ZEPHYR_BASE
|
||||
export ZEPHYR_MODULES_DIR="PLEASE_SET_ZEPHYR_MODULES_TOO"
|
||||
|
||||
if [ "$ZEPHYR_BASE" == "PLEASE_SET_ZEPHYR_BASE" ] ; then
|
||||
echo "Please set ZEPHYR_BASE in this build.sh."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export KONAN_DATA_DIR=$HOME/.konan
|
||||
export KONAN_DEPS=$KONAN_DATA_DIR/dependencies
|
||||
|
||||
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
if [ -z "$KONAN_HOME" ]; then
|
||||
PATH="$DIR/../../dist/bin:$DIR/../../bin:$PATH"
|
||||
else
|
||||
PATH="$KONAN_HOME/bin:$PATH"
|
||||
fi
|
||||
|
||||
if [ x$TARGET == x ]; then
|
||||
case "$OSTYPE" in
|
||||
darwin*) TOOLCHAIN=gcc-arm-none-eabi-7-2017-q4-major-mac ;;
|
||||
linux*) TOOLCHAIN=gcc-arm-none-eabi-7-2017-q4-major-linux ;;
|
||||
*) echo "unknown: $OSTYPE" && exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
GNU_ARM="$KONAN_DEPS/$TOOLCHAIN"
|
||||
|
||||
rm -rf $DIR/build || exit 1
|
||||
mkdir -p $DIR/build && cd $DIR/build
|
||||
|
||||
export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
|
||||
export GNUARMEMB_TOOLCHAIN_PATH=$GNU_ARM
|
||||
|
||||
[ -f CMakeCache.txt ] || cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBOARD=$BOARD .. || exit 1
|
||||
|
||||
# We need generated headers to be consumed by `cinterop`,
|
||||
# so we preconfigure the project with `make zephyr`.
|
||||
make zephyr
|
||||
|
||||
. $DIR/c_interop/platforms/$BOARD.sh
|
||||
|
||||
rm -f program.o
|
||||
|
||||
mkdir -p $DIR/build/kotlin
|
||||
|
||||
konanc $DIR/src/main.kt \
|
||||
-target zephyr_$BOARD \
|
||||
-r $DIR/c_interop/platforms/build \
|
||||
-l $BOARD \
|
||||
-opt -g -o $DIR/build/kotlin/program || exit 1
|
||||
|
||||
make || exit 1
|
||||
|
||||
# make flash
|
||||
#
|
||||
# For our STM32 boards the OpenOCD unable to flash the binary,
|
||||
# so we go with the following alternative utility:
|
||||
|
||||
echo
|
||||
echo "Now run 'make flash' to flash the .bin to the card."
|
||||
echo
|
||||
echo "Or, if that doesn't work, like, for example if you have an stm32f4-disco,"
|
||||
echo "run the following command:"
|
||||
echo "st-flash --reset write build/zephyr/zephyr.bin 0x08000000"
|
||||
echo
|
||||
@@ -0,0 +1,36 @@
|
||||
::
|
||||
:: Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
:: that can be found in the license/LICENSE.txt file.
|
||||
::
|
||||
|
||||
:: This is board specific.
|
||||
|
||||
if "%BOARD%" == "" (
|
||||
echo This script is to be included by build.bat
|
||||
exit /b
|
||||
)
|
||||
|
||||
:: TODO: we need a robust automated way to ask Zephyr for
|
||||
:: all these %ZEPHYR_BASE% based paths and the proper defines.
|
||||
:: TODO: The D flag in `-compilerOpts -Dxxx` sequence is interpreted to be a jvm property,
|
||||
:: so we workaround the using -Xclang.
|
||||
|
||||
call cinterop -def %DIR%/c_interop/platforms/%BOARD%.def ^
|
||||
-pkg platform.zephyr.%BOARD% ^
|
||||
-compilerOpts "-Xclang -DSTM32F407xx" ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/kernel/include ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/arch/arm/include ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/soc/arm/st_stm32/stm32f4 ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/soc/arm/st_stm32/common ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/boards/arm/%BOARD% ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/include ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/include/drivers ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/ext/hal/cmsis/Include ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/ext/hal/st/stm32cube/stm32f4xx/soc ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/ext/hal/st/stm32cube/stm32f4xx/drivers/include ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/ext/hal/st/stm32cube/stm32f4xx/drivers/include/Legacy ^
|
||||
-compilerOpts -I%ZEPHYR_BASE%/drivers ^
|
||||
-compilerOpts -I%DIR%/build/zephyr/include/generated ^
|
||||
-compilerOpts -I%DIR%/build/zephyr/include/generated/syscalls ^
|
||||
-o %DIR%/c_interop/platforms/build/%BOARD% ^
|
||||
-target zephyr_%BOARD% || exit /b
|
||||
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
# that can be found in the license/LICENSE.txt file.
|
||||
#
|
||||
|
||||
# Keep this one board independent.
|
||||
|
||||
headers = autoconf.h zephyr.h generated_dts_board.h device.h gpio.h
|
||||
compilerOpts = -DKERNEL -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -D_FORTIFY_SOURCE=2 -D__ZEPHYR__=1 -ffreestanding -std=c99 -nostdinc
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
# that can be found in the license/LICENSE.txt file.
|
||||
#
|
||||
|
||||
# This is board specific.
|
||||
|
||||
if [ x"$BOARD" == x ]; then
|
||||
echo "This script is to be included by build.sh"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# TODO: we need a robust automated way to ask Zephyr for
|
||||
# all these $ZEPHYR_BASE based paths and the proper defines.
|
||||
# TODO: The D flag in `-compilerOpts -Dxxx` sequence is interpreted to be a jvm property,
|
||||
# so we workaround the using -Xclang.
|
||||
|
||||
cinterop -def $DIR/c_interop/platforms/$BOARD.def \
|
||||
-pkg platform.zephyr.$BOARD \
|
||||
-compilerOpts '-Xclang -DSTM32F407xx' \
|
||||
-compilerOpts -I$ZEPHYR_BASE/kernel/include \
|
||||
-compilerOpts -I$ZEPHYR_BASE/arch/arm/include \
|
||||
-compilerOpts -I$ZEPHYR_BASE/soc/arm/st_stm32/stm32f4 \
|
||||
-compilerOpts -I$ZEPHYR_BASE/soc/arm/st_stm32/common \
|
||||
-compilerOpts -I$ZEPHYR_BASE/boards/arm/$BOARD \
|
||||
-compilerOpts -I$ZEPHYR_BASE/include \
|
||||
-compilerOpts -I$ZEPHYR_BASE/include/drivers \
|
||||
-compilerOpts -I$ZEPHYR_BASE/ext/hal/cmsis/Include \
|
||||
-compilerOpts -IZEPHYR_MODULES_DIR/hal/stm32/stm32cube/stm32f4xx/soc \
|
||||
-compilerOpts -IZEPHYR_MODULES_DIR/hal/stm32/stm32cube/stm32f4xx/drivers/include \
|
||||
-compilerOpts -IZEPHYR_MODULES_DIR/hal/stm32/stm32cube/stm32f4xx/drivers/include/Legacy \
|
||||
-compilerOpts -I$ZEPHYR_BASE/drivers \
|
||||
-compilerOpts -I$DIR/build/zephyr/include/generated \
|
||||
-compilerOpts -I$DIR/build/zephyr/include/generated/syscalls \
|
||||
-o $DIR/c_interop/platforms/build/$BOARD \
|
||||
-target zephyr_$BOARD || exit 1
|
||||
@@ -0,0 +1,5 @@
|
||||
CONFIG_CPLUSPLUS=n
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_BOOT_BANNER=y
|
||||
CONFIG_BUILD_OUTPUT_BIN=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import platform.zephyr.stm32f4_disco.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun blinky(value: Int) {
|
||||
|
||||
val port = LED0_GPIO_CONTROLLER
|
||||
val led = LED0_GPIO_PIN
|
||||
var toggler = false
|
||||
val dev = device_get_binding(port)
|
||||
|
||||
gpio_pin_configure(dev, led.convert(), GPIO_DIR_OUT)
|
||||
|
||||
while (true) {
|
||||
/* Set pin to HIGH/LOW every 1 second */
|
||||
gpio_pin_write(dev, led.convert(), if (toggler) 1U else 0U);
|
||||
toggler = !toggler
|
||||
k_sleep(1000 * value);
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
blinky(1)
|
||||
}
|
||||
Reference in New Issue
Block a user