o
    nc                     @  sH   d dl mZ d dlmZ d dlZdZdZdZdZdZ	G d	d
 d
eZ
dS )    )annotations)
SampleImplNz#![crate_name = "{crate_file}"]

/* This function will not be exported and is not
 * directly callable by users of this library.
 */
fn internal_function() -> i32 {{
    return 0;
}}

pub fn {function_name}() -> i32 {{
    return internal_function();
}}
zmextern crate {crate_file};

fn main() {{
    println!("printing: {{}}", {crate_file}::{function_name}());
}}
a  project('{project_name}', 'rust',
  version : '{version}',
  default_options : ['warning_level=3'])

shlib = static_library('{lib_name}', '{source_file}', install : true)

test_exe = executable('{test_exe_name}', '{test_source_file}',
  link_with : shlib)
test('{test_name}', test_exe)

# Make this library usable as a Meson subproject.
{ltoken}_dep = declare_dependency(
  include_directories: include_directories('.'),
  link_with : shlib)
zq
fn main() {{
    let project_name = "{project_name}";
    println!("This is project {{}}.\n", project_name);
}}
zproject('{project_name}', 'rust',
  version : '{version}',
  default_options : ['warning_level=3'])

exe = executable('{exe_name}', '{source_name}',
  install : true)

test('basic', exe)
c                      s0   e Zd Z fddZd	ddZd	ddZ  ZS )
RustProjectc                   s   t    |j| _|j| _d S )N)super__init__nameversion)selfoptions	__class__ home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/templates/rusttemplates.pyr   M   s   
zRustProject.__init__returnNonec                 C  sd   t dd| j }|d }t|dddtj| jd tddddtj| j||| j	d	 d S )
N	[^a-z0-9]_.rswutf-8encoding)project_namemeson.build)r   Zexe_namesource_namer   )
resubr   loweropenwritehello_rust_templateformathello_rust_meson_templater   )r	   lowercase_tokenr   r   r   r   create_executableR   s   zRustProject.create_executablec           	      C  s   t dd| j }| }|dd d }|d }|}|d }|d }||||||||| j||| jd	}t|d
ddtj	di | t|d
ddt
j	di | tdd
ddtj	di | d S )Nr   r   r      _func_testr   z_test.rs)ZutokenZltokenZ
header_dirfunction_nameZ
crate_fileZsource_fileZtest_source_filetest_exe_namer   lib_nameZ	test_namer   r   r   r   r   r   )r   r   r   r   upperr   r   r   lib_rust_templater!   lib_rust_test_templatelib_rust_meson_template)	r	   r#   Zuppercase_tokenr(   r)   Zlib_crate_nameZlib_rs_nameZtest_rs_namekwargsr   r   r   create_library\   s.     $zRustProject.create_library)r   r   )__name__
__module____qualname__r   r$   r0   __classcell__r   r   r   r   r   L   s    

r   )
__future__r   Zmesonbuild.templates.sampleimplr   r   r,   r-   r.   r    r"   r   r   r   r   r   <module>   s   