1+ # gen_examples.py
2+
3+ # Index of this file:
4+ # [SECTION] imports
5+ # [SECTION] project
6+ # [SECTION] examples
7+ # [SECTION] generate_scripts
8+
9+ #-----------------------------------------------------------------------------
10+ # [SECTION] imports
11+ #-----------------------------------------------------------------------------
12+
13+ import os
14+ import sys
15+ import platform as plat
16+
17+ import pl_build .core as pl
18+ import pl_build .backend_win32 as win32
19+
20+ #-----------------------------------------------------------------------------
21+ # [SECTION] project
22+ #-----------------------------------------------------------------------------
23+
24+ # where to output build scripts
25+ working_directory = os .path .dirname (os .path .abspath (__file__ )) + "/../src"
26+
27+ with pl .project ("pilotlight_python" ):
28+
29+ # project wide settings
30+ pl .set_output_directory ("../out" )
31+ pl .add_link_directories ("../out" )
32+ pl .add_definitions ("_USE_MATH_DEFINES" )
33+ pl .add_include_directories ("../src" )
34+
35+ #-----------------------------------------------------------------------------
36+ # [SECTION] examples
37+ #-----------------------------------------------------------------------------
38+
39+ with pl .target ("pilotlight_python" , pl .TargetType .EXECUTABLE , False ):
40+
41+ pl .add_include_directories (
42+ "../../pilotlight/libs" ,
43+ "../dependencies/cpython/" ,
44+ "../dependencies/cpython/Include/" ,
45+ "../dependencies/cpython/PC/"
46+ )
47+
48+ pl .add_source_files ("main.c" )
49+ pl .set_output_binary ("pilotlight_python" )
50+
51+ with pl .configuration ("debug" ):
52+
53+ # win32
54+ with pl .platform ("Windows" ):
55+ with pl .compiler ("msvc" ):
56+ pl .add_link_directories ("../dependencies/cpython/PCbuild/amd64/" )
57+ pl .add_linker_flags ("-noimplib" , "-noexp" , "-incremental:no" )
58+ pl .add_compiler_flags ("-Zc:preprocessor" , "-nologo" , "-std:c11" , "-W4" , "-WX" , "-wd4201" ,
59+ "-wd4100" , "-wd4996" , "-wd4505" , "-wd4189" , "-wd5105" , "-wd4115" ,
60+ "-permissive-" , "-Od" , "-MDd" , "-Zi" )
61+ pl .set_post_target_build_step (
62+ '@copy "..\\ dependencies\\ cpython\\ PCbuild\\ amd64\\ python314_d.dll" "..\\ out\\ " >nul\n '
63+ '@copy "..\\ dependencies\\ cpython\\ PCbuild\\ amd64\\ python314.dll" "..\\ out\\ " >nul\n '
64+ '@copy "..\\ dependencies\\ cpython\\ PCbuild\\ amd64\\ python3.dll" "..\\ out\\ " >nul\n '
65+ '@copy "..\\ dependencies\\ cpython\\ PCbuild\\ amd64\\ python3_d.dll" "..\\ out\\ " >nul\n '
66+ )
67+
68+ #-----------------------------------------------------------------------------
69+ # [SECTION] examples
70+ #-----------------------------------------------------------------------------
71+
72+ with pl .target ("pilotlight" , pl .TargetType .DYNAMIC_LIBRARY , False ):
73+
74+ pl .add_include_directories (
75+ "../../pilotlight/libs" ,
76+ "../dependencies/cpython/" ,
77+ "../dependencies/cpython/Include/" ,
78+ "../dependencies/cpython/PC/"
79+ )
80+
81+ pl .add_source_files ("module_pilotlight.c" )
82+ pl .set_output_binary ("_pilotlight" )
83+
84+ with pl .configuration ("distribute" ):
85+
86+ # win32
87+ with pl .platform ("Windows" ):
88+ with pl .compiler ("msvc" ):
89+ pl .set_output_binary_extension (".pyd" )
90+ pl .add_link_directories ("../dependencies/cpython/PCbuild/amd64/" )
91+ pl .add_linker_flags ("-noimplib" , "-noexp" , "-incremental:no" )
92+ pl .add_compiler_flags ("-Zc:preprocessor" , "-nologo" , "-std:c11" , "-W4" , "-WX" , "-wd4201" ,
93+ "-wd4100" , "-wd4996" , "-wd4505" , "-wd4189" , "-wd5105" , "-wd4115" ,
94+ "-permissive-" , "-Od" , "-MD" , "-Zi" )
95+
96+
97+
98+
99+ #-----------------------------------------------------------------------------
100+ # [SECTION] generate scripts
101+ #-----------------------------------------------------------------------------
102+
103+ win32 .generate_build (working_directory + '/' + "build.bat" )
0 commit comments