This commit is contained in:
ZtRXR 2024-06-15 23:22:44 +08:00
parent 02fec5c637
commit 311d74fdf4
3 changed files with 252 additions and 3 deletions

View File

@ -99,6 +99,62 @@
"detail": "typing",
"documentation": {}
},
{
"label": "Literal",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "Self",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "Type",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "TypeVar",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "List",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "Tuple",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "Union",
"importPath": "typing",
"description": "typing",
"isExtraImport": true,
"detail": "typing",
"documentation": {}
},
{
"label": "*",
"importPath": "pymake",
@ -108,7 +164,7 @@
"documentation": {}
},
{
"label": "cmake",
"label": "*",
"importPath": "pymake",
"description": "pymake",
"isExtraImport": true,
@ -196,6 +252,186 @@
"detail": ".venv.Scripts.activate_this",
"documentation": {}
},
{
"label": "cmake",
"kind": 6,
"importPath": "build.lib.pymake.cmake",
"description": "build.lib.pymake.cmake",
"peekOfCode": "class cmake:\n __write_stack__:List[str] = []\n __file_name__:str\n def __init__(self,version_min:str,file_name:str=\"CMakeLists.txt\") -> None:\n self.__file_name__ = file_name\n self.__write_stack__.append(f\"cmake_minimum_required(VERSION {version_min})\")\n def write(self)->None:\n with open(file=self.__file_name__,mode=\"+w\",encoding=\"utf8\") as f:\n for i in self.__write_stack__:\n f.write(i)",
"detail": "build.lib.pymake.cmake",
"documentation": {}
},
{
"label": "ModesPPI",
"kind": 5,
"importPath": "build.lib.pymake.cmake",
"description": "build.lib.pymake.cmake",
"peekOfCode": "ModesPPI = Literal[\"PUBLIC\",\"PRIVATE\",\"INTERFACE\"]\nModesSSM = Literal[\"STATIC\",\"SHARED\",\"MODULE\"]\nclass cmake:\n __write_stack__:List[str] = []\n __file_name__:str\n def __init__(self,version_min:str,file_name:str=\"CMakeLists.txt\") -> None:\n self.__file_name__ = file_name\n self.__write_stack__.append(f\"cmake_minimum_required(VERSION {version_min})\")\n def write(self)->None:\n with open(file=self.__file_name__,mode=\"+w\",encoding=\"utf8\") as f:",
"detail": "build.lib.pymake.cmake",
"documentation": {}
},
{
"label": "ModesSSM",
"kind": 5,
"importPath": "build.lib.pymake.cmake",
"description": "build.lib.pymake.cmake",
"peekOfCode": "ModesSSM = Literal[\"STATIC\",\"SHARED\",\"MODULE\"]\nclass cmake:\n __write_stack__:List[str] = []\n __file_name__:str\n def __init__(self,version_min:str,file_name:str=\"CMakeLists.txt\") -> None:\n self.__file_name__ = file_name\n self.__write_stack__.append(f\"cmake_minimum_required(VERSION {version_min})\")\n def write(self)->None:\n with open(file=self.__file_name__,mode=\"+w\",encoding=\"utf8\") as f:\n for i in self.__write_stack__:",
"detail": "build.lib.pymake.cmake",
"documentation": {}
},
{
"label": "var",
"kind": 2,
"importPath": "build.lib.pymake.tools",
"description": "build.lib.pymake.tools",
"peekOfCode": "def var(name:str)->str:\n return f\"${{{name}}}\"\ndef args_to_str(args:Union[List[str],Tuple[str,...]])->str:\n vars_str = \"\"\n for i in args:\n vars_str=f\"{vars_str} {i}\"\n return vars_str",
"detail": "build.lib.pymake.tools",
"documentation": {}
},
{
"label": "args_to_str",
"kind": 2,
"importPath": "build.lib.pymake.tools",
"description": "build.lib.pymake.tools",
"peekOfCode": "def args_to_str(args:Union[List[str],Tuple[str,...]])->str:\n vars_str = \"\"\n for i in args:\n vars_str=f\"{vars_str} {i}\"\n return vars_str",
"detail": "build.lib.pymake.tools",
"documentation": {}
},
{
"label": "cmake_export_compile_commands",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "cmake_export_compile_commands = \"CMAKE_EXPORT_COMPILE_COMMANDS\"\nproject_name=\"PROJECT_NAME\"\npublic = \"PUBLIC\"\nstatic = \"STATIC\"\nshared = \"SHARED\"\nmodule = \"MODULE\"\nprivate = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "public",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "public = \"PUBLIC\"\nstatic = \"STATIC\"\nshared = \"SHARED\"\nmodule = \"MODULE\"\nprivate = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "static",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "static = \"STATIC\"\nshared = \"SHARED\"\nmodule = \"MODULE\"\nprivate = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "shared",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "shared = \"SHARED\"\nmodule = \"MODULE\"\nprivate = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "module",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "module = \"MODULE\"\nprivate = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "private",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "private = \"PRIVATE\"\ninterface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "interface",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "interface = \"INTERFACE\"\nglob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "glob_recurse",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "glob_recurse = \"GLOB_RECURSE\"\ncmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "cmake_cxx_standard",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "cmake_cxx_standard = \"CMAKE_CXX_STANDARD\"\ncmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "cmake_cxx_flags",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "cmake_cxx_flags = \"CMAKE_CXX_FLAGS\"\no3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "o3",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "o3 = \"-O3\"\no2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "o2",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "o2 = \"-O2\"\ncmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "cmake_cxx_flags_release",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "cmake_cxx_flags_release = \"CMAKE_CXX_FLAGS_RELEASE\"\ncmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "cmake_cxx_flags_debug",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "cmake_cxx_flags_debug = \"CMAKE_CXX_FLAGS_DEBUG\"\non=\"ON\"\nproject_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "project_source_dir",
"kind": 5,
"importPath": "build.lib.pymake.values",
"description": "build.lib.pymake.values",
"peekOfCode": "project_source_dir = \"PROJECT_SOURCE_DIR\"",
"detail": "build.lib.pymake.values",
"documentation": {}
},
{
"label": "cmake",
"kind": 6,

View File

@ -65,3 +65,15 @@ class cmake:
pybind11_add_module(example example.cpp)
"""
self.__write_stack__.append(f"pybind11_add_module({project_name} {args_to_str(source)})")
return self
def find_package(self,package_name:str,quiet:Literal["REQUIRED","QUIET"]="REQUIRED"):
"""
find_package(<package> [version] [EXACT] [QUIET] [MODULE]
[REQUIRED] [[COMPONENTS] [components...]]
[OPTIONAL_COMPONENTS components...]
[NO_POLICY_SCOPE])
"""
self.__write_stack__.append(f"find_package({package_name} {quiet})")

View File

@ -1,8 +1,9 @@
from pymake import cmake
from pymake import *
(
cmake("3.15")
# TODO
.project("test_pybind11")
.pybind11_add_module(var(project_name),"main.cpp")
.write()
)