o
    ƒnóc£  ã                   @  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  #include <iostream>

#define PROJECT_NAME "{project_name}"

int main(int argc, char **argv) {{
    if(argc != 1) {{
        std::cout << argv[0] << " takes no arguments.\n";
        return 1;
    }}
    std::cout << "This is project " << PROJECT_NAME << ".\n";
    return 0;
}}
zêproject('{project_name}', ['cuda', 'cpp'],
  version : '{version}',
  default_options : ['warning_level=3',
                     'cpp_std=c++14'])

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

test('basic', exe)
aý  #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

namespace {namespace} {{

class {utoken}_PUBLIC {class_name} {{

public:
  {class_name}();
  int get_number() const;

private:

  int number;

}};

}}

z¨#include <{header_file}>

namespace {namespace} {{

{class_name}::{class_name}() {{
    number = 6;
}}

int {class_name}::get_number() const {{
  return number;
}}

}}
zý#include <{header_file}>
#include <iostream>

int main(int argc, char **argv) {{
    if(argc != 1) {{
        std::cout << argv[0] << " takes no arguments.\n";
        return 1;
    }}
    {namespace}::{class_name} c;
    return c.get_number() != 6;
}}
aã  project('{project_name}', ['cuda', 'cpp'],
  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,
  cpp_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}',
)
c                      s0   e Zd Z‡ fdd„Zd	dd„Zd	dd„Z‡  ZS )
ÚCudaProjectc                   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/cudatemplates.pyr   ’   s   
zCudaProject.__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]Ú_ú.cuÚwúutf-8©Úencoding)Úproject_nameúmeson.build)r   Zexe_nameÚsource_namer   )
ÚreÚsubr   ÚlowerÚopenÚwriteÚhello_cuda_templateÚformatÚhello_cuda_meson_templater   )r	   Úlowercase_tokenr   r   r   r   Úcreate_executable—   s   ýÿzCudaProject.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   é   Ú_testz.hr   z_test.cu)ZutokenZltokenZ
header_dirÚ
class_nameÚ	namespaceZ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_cuda_templateÚlib_cuda_test_templateÚlib_cuda_meson_template)
r	   r#   Zuppercase_tokenr'   r)   r(   Z
lib_h_nameZlib_cuda_nameZtest_cuda_nameÚkwargsr   r   r   Úcreate_library¡   s4   ô   $zCudaProject.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   !'