apps: hello_rust example program
This commit is contained in:
parent
7df20da96c
commit
c1757660a6
29
examples/hello_rust/Kconfig
Normal file
29
examples/hello_rust/Kconfig
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config EXAMPLES_HELLO_RUST
|
||||
tristate "\"Hello, Rust!\" example"
|
||||
default n
|
||||
---help---
|
||||
Enable the \"Hello, Rust!\" example
|
||||
|
||||
if EXAMPLES_HELLO_RUST
|
||||
|
||||
config EXAMPLES_HELLO_RUST_PROGNAME
|
||||
string "Program name"
|
||||
default "hello_rust"
|
||||
---help---
|
||||
This is the name of the program that will be used when the
|
||||
program is installed.
|
||||
|
||||
config EXAMPLES_HELLO_RUST_PRIORITY
|
||||
int "Hello Rust task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_HELLO_RUST_STACKSIZE
|
||||
int "Hello Rust stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
endif
|
23
examples/hello_rust/Make.defs
Normal file
23
examples/hello_rust/Make.defs
Normal file
@ -0,0 +1,23 @@
|
||||
############################################################################
|
||||
# apps/examples/hello_rust/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_HELLO_RUST),)
|
||||
CONFIGURED_APPS += $(APPDIR)/examples/hello_rust
|
||||
endif
|
34
examples/hello_rust/Makefile
Normal file
34
examples/hello_rust/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
############################################################################
|
||||
# apps/examples/hello_rust/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Hello, Rust! built-in application info
|
||||
|
||||
PROGNAME = $(CONFIG_EXAMPLES_HELLO_RUST_PROGNAME)
|
||||
PRIORITY = $(CONFIG_EXAMPLES_HELLO_RUST_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_HELLO_RUST_STACKSIZE)
|
||||
MODULE = $(CONFIG_EXAMPLES_HELLO_RUST)
|
||||
|
||||
# Hello, Rust! Example
|
||||
|
||||
MAINSRC = hello_rust_main.rs
|
||||
|
||||
include $(APPDIR)/Application.mk
|
57
examples/hello_rust/hello_rust_main.rs
Normal file
57
examples/hello_rust/hello_rust_main.rs
Normal file
@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/hello_rust/hello_rust_main.rs
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Attributes
|
||||
****************************************************************************/
|
||||
|
||||
#![no_main]
|
||||
|
||||
/****************************************************************************
|
||||
* Externs
|
||||
****************************************************************************/
|
||||
|
||||
extern "C"
|
||||
{
|
||||
pub fn printf(format: *const u8, ...) -> i32;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* hello_rust_main
|
||||
****************************************************************************/
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn hello_rust_main(_argc: i32, _argv: *const *const u8) -> i32
|
||||
{
|
||||
/* "Hello, Rust!!" using printf() from libc */
|
||||
|
||||
unsafe
|
||||
{
|
||||
printf(b"Hello, Rust!!\n\0" as *const u8);
|
||||
}
|
||||
|
||||
/* exit with status 0 */
|
||||
|
||||
0
|
||||
}
|
Loading…
Reference in New Issue
Block a user