o
    ncj                     @  sL   d dl mZ d dlmZ d dlZdZdZdZdZdZ	d	Z
G d
d deZdS )    )annotations)
SampleImplNa  #pragma once
#if defined _WIN32 || defined __CYGWIN__
  #ifdef BUILDING_{utoken}
    #define {utoken}_PUBLIC __declspec(dllexport)
  #else
    #define {utoken}_PUBLIC __declspec(dllimport)
  #endif
#else
  #ifdef BUILDING_{utoken}
      #define {utoken}_PUBLIC __attribute__ ((visibility ("default")))
  #else
      #define {utoken}_PUBLIC
  #endif
#endif

int {utoken}_PUBLIC {function_name}();

z#include <{header_file}>

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

int {function_name}() {{
    return internal_function();
}}
z#include <{header_file}>
#include <stdio.h>

int main(int argc, char **argv) {{
    if(argc != 1) {{
        printf("%s takes no arguments.\n", argv[0]);
        return 1;
    }}
    return {function_name}();
}}
a  project('{project_name}', 'c',
  version : '{version}',
  default_options : ['warning_level=3'])

# These arguments are only used to build the shared library
# not the executables that use the library.
lib_args = ['-DBUILDING_{utoken}']

shlib = shared_library('{lib_name}', '{source_file}',
  install : true,
  c_args : lib_args,
  gnu_symbol_visibility : 'hidden',
)

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)

# Make this library usable from the system's
# package manager.
install_headers('{header_file}', subdir : '{header_dir}')

pkg_mod = import('pkgconfig')
pkg_mod.generate(
  name : '{project_name}',
  filebase : '{ltoken}',
  description : 'Meson sample project.',
  subdirs : '{header_dir}',
  libraries : shlib,
  version : '{version}',
)
a  #include <stdio.h>

#define PROJECT_NAME "{project_name}"

int main(int argc, char **argv) {{
    if(argc != 1) {{
        printf("%s takes no arguments.\n", argv[0]);
        return 1;
    }}
    printf("This is project %s.\n", PROJECT_NAME);
    return 0;
}}
zproject('{project_name}', 'c',
  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 )
CProjectc                   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/ctemplates.pyr      s   
zCProject.__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]_.cwutf-8encoding)project_namemeson.build)r   Zexe_namesource_namer   )
resubr   loweropenwritehello_c_templateformathello_c_meson_templater   )r	   lowercase_tokenr   r   r   r   create_executable   s   zCProject.create_executablec           	      C  s   t dd| j }| }|d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tj	di | tddddtj	di | d S )Nr   r   r      _func_testz.hr   z_test.c)ZutokenZltokenZ
header_dirfunction_nameZheader_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_h_templater!   lib_c_templatelib_c_test_templatelib_c_meson_template)	r	   r#   Zuppercase_tokenr(   r)   Z
lib_h_nameZ
lib_c_nameZtest_c_namekwargsr   r   r   create_library   s0      $zCProject.create_library)r   r   )__name__
__module____qualname__r   r$   r1   __classcell__r   r   r   r   r      s    

r   )
__future__r   Zmesonbuild.templates.sampleimplr   r   r,   r-   r.   r/   r    r"   r   r   r   r   r   <module>   s   &