buildgen 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,243 @@
1
+ Metadata-Version: 2.4
2
+ Name: buildgen
3
+ Version: 0.1.1
4
+ Summary: Build system generator - Makefile, CMake, and more.
5
+ Keywords: makefile,cmake,build-system,code-generation,cpp,c++
6
+ Author: Shakeeb Alireza
7
+ Author-email: Shakeeb Alireza <me@example.org>
8
+ License-Expression: GPL-3.0-or-later
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Build Tools
19
+ Classifier: Topic :: Software Development :: Code Generators
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: pyyaml>=6.0 ; extra == 'yaml'
22
+ Requires-Python: >=3.11
23
+ Project-URL: Changelog, https://github.com/shakfu/buildgen/blob/main/CHANGELOG.md
24
+ Project-URL: Homepage, https://github.com/shakfu/buildgen
25
+ Project-URL: Issues, https://github.com/shakfu/buildgen/issues
26
+ Project-URL: Repository, https://github.com/shakfu/buildgen
27
+ Provides-Extra: yaml
28
+ Description-Content-Type: text/markdown
29
+
30
+ # buildgen
31
+
32
+ A build system generator package supporting Makefile, CMake, and cross-generator project definitions.
33
+
34
+ Originally inspired by prior work on `shedskin.makefile` in the [shedskin project](https://github.com/shedskin/shedskin).
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install buildgen
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```bash
45
+ # Create a project config
46
+ buildgen project init -t full -n myproject -o project.json
47
+
48
+ # Generate both Makefile and CMakeLists.txt
49
+ buildgen project generate -c project.json --all
50
+
51
+ # Or generate CMake with Makefile frontend
52
+ buildgen project generate -c project.json --cmake
53
+ ```
54
+
55
+ ## Features
56
+
57
+ - **Makefile Generation**: Programmatic Makefile creation with variables, pattern rules, conditionals
58
+ - **CMake Generation**: Full CMakeLists.txt generation with find_package, FetchContent, install rules
59
+ - **Cross-Generator**: Define project once in JSON/YAML, generate both build systems
60
+ - **CMake Frontend**: Use CMake as build system with convenient Makefile wrapper
61
+ - **Project Templates**: Quick-start templates for common project types
62
+
63
+ ## Usage
64
+
65
+ ### CLI
66
+
67
+ ```bash
68
+ # Project configuration workflow (recommended)
69
+ buildgen project init -t full -n myproject -o project.json
70
+ buildgen project generate -c project.json --all
71
+ buildgen project types # List available templates
72
+
73
+ # Direct Makefile generation
74
+ buildgen makefile generate -o Makefile --targets "all:main.o:"
75
+ buildgen makefile build myprogram --cppfiles main.cpp
76
+
77
+ # Direct CMake generation
78
+ buildgen cmake generate -o CMakeLists.txt --project myapp --cxx-standard 17
79
+ buildgen cmake build -S . -B build --build-type Release
80
+ ```
81
+
82
+ ### Python API
83
+
84
+ ```python
85
+ from buildgen import ProjectConfig, TargetConfig, DependencyConfig
86
+
87
+ # Load from config file
88
+ config = ProjectConfig.load("project.json")
89
+ config.generate_all() # Creates Makefile and CMakeLists.txt
90
+
91
+ # Or build programmatically
92
+ config = ProjectConfig(
93
+ name="myproject",
94
+ version="1.0.0",
95
+ cxx_standard=17,
96
+ compile_options=["-Wall", "-Wextra"],
97
+ dependencies=[
98
+ DependencyConfig(name="Threads"),
99
+ DependencyConfig(
100
+ name="fmt",
101
+ git_repository="https://github.com/fmtlib/fmt.git",
102
+ git_tag="10.1.1",
103
+ ),
104
+ ],
105
+ targets=[
106
+ TargetConfig(
107
+ name="mylib",
108
+ target_type="static",
109
+ sources=["src/lib.cpp"],
110
+ include_dirs=["include"],
111
+ ),
112
+ TargetConfig(
113
+ name="myapp",
114
+ target_type="executable",
115
+ sources=["src/main.cpp"],
116
+ link_libraries=["mylib", "fmt::fmt"],
117
+ install=True,
118
+ ),
119
+ ],
120
+ )
121
+ config.generate_all()
122
+ ```
123
+
124
+ ### CMake with Makefile Frontend
125
+
126
+ Generate CMake as the build system with a Makefile that wraps cmake commands:
127
+
128
+ ```python
129
+ config.generate_cmake_with_frontend(
130
+ build_dir="build",
131
+ build_type="Release",
132
+ )
133
+ ```
134
+
135
+ This creates:
136
+ - `CMakeLists.txt` - The actual build logic
137
+ - `Makefile` - Convenience wrapper with targets:
138
+
139
+ ```bash
140
+ make # Configure and build
141
+ make build # Same as above
142
+ make configure # Run cmake configure only
143
+ make clean # Remove build directory
144
+ make rebuild # Clean and rebuild
145
+ make install # Install the project
146
+ make test # Run tests with ctest
147
+ make myapp # Build specific target
148
+ make help # Show available targets
149
+
150
+ # Override defaults
151
+ make BUILD_TYPE=Debug
152
+ make BUILD_DIR=cmake-build
153
+ make CMAKE_FLAGS="-DFOO=bar"
154
+ ```
155
+
156
+ ## Project Configuration
157
+
158
+ ### JSON Format
159
+
160
+ ```json
161
+ {
162
+ "name": "myproject",
163
+ "version": "1.0.0",
164
+ "cxx_standard": 17,
165
+ "compile_options": ["-Wall", "-Wextra"],
166
+ "dependencies": [
167
+ "Threads",
168
+ {"name": "OpenSSL", "required": true},
169
+ {
170
+ "name": "fmt",
171
+ "git_repository": "https://github.com/fmtlib/fmt.git",
172
+ "git_tag": "10.1.1"
173
+ }
174
+ ],
175
+ "targets": [
176
+ {
177
+ "name": "mylib",
178
+ "type": "static",
179
+ "sources": ["src/lib.cpp"],
180
+ "include_dirs": ["include"],
181
+ "install": true
182
+ },
183
+ {
184
+ "name": "myapp",
185
+ "type": "executable",
186
+ "sources": ["src/main.cpp"],
187
+ "link_libraries": ["mylib", "Threads::Threads"],
188
+ "install": true
189
+ }
190
+ ]
191
+ }
192
+ ```
193
+
194
+ ### Project Templates
195
+
196
+ ```bash
197
+ buildgen project types
198
+ ```
199
+
200
+ | Template | Description |
201
+ |----------|-------------|
202
+ | `executable` | Single executable (src/main.cpp) |
203
+ | `static` | Static library with include/ |
204
+ | `shared` | Shared library with -fPIC |
205
+ | `header-only` | Header-only/interface library |
206
+ | `library-with-tests` | Library + test executable |
207
+ | `app-with-lib` | Executable with internal library |
208
+ | `full` | Library + app + tests + Threads |
209
+
210
+ ## Low-Level API
211
+
212
+ For fine-grained control, use the generators directly:
213
+
214
+ ```python
215
+ from buildgen import MakefileGenerator, CMakeListsGenerator
216
+
217
+ # Makefile
218
+ gen = MakefileGenerator("Makefile")
219
+ gen.add_cxxflags("-Wall", "-std=c++17")
220
+ gen.add_target("myapp", "$(CXX) $(CXXFLAGS) -o $@ $^", deps=["main.o"])
221
+ gen.add_pattern_rule("%.o", "%.cpp", "$(CXX) $(CXXFLAGS) -c $< -o $@")
222
+ gen.add_phony("all", "clean")
223
+ gen.generate()
224
+
225
+ # CMake
226
+ gen = CMakeListsGenerator("CMakeLists.txt")
227
+ gen.set_project("myapp", version="1.0.0")
228
+ gen.set_cxx_standard(17)
229
+ gen.add_find_package("Threads", required=True)
230
+ gen.add_executable("myapp", ["src/main.cpp"], link_libraries=["Threads::Threads"])
231
+ gen.generate()
232
+ ```
233
+
234
+ ## Development
235
+
236
+ ```bash
237
+ make test # Run tests (194 tests)
238
+ make coverage # Coverage report
239
+ ```
240
+
241
+ ## License
242
+
243
+ GPL-3.0-or-later
@@ -0,0 +1,214 @@
1
+ # buildgen
2
+
3
+ A build system generator package supporting Makefile, CMake, and cross-generator project definitions.
4
+
5
+ Originally inspired by prior work on `shedskin.makefile` in the [shedskin project](https://github.com/shedskin/shedskin).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install buildgen
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Create a project config
17
+ buildgen project init -t full -n myproject -o project.json
18
+
19
+ # Generate both Makefile and CMakeLists.txt
20
+ buildgen project generate -c project.json --all
21
+
22
+ # Or generate CMake with Makefile frontend
23
+ buildgen project generate -c project.json --cmake
24
+ ```
25
+
26
+ ## Features
27
+
28
+ - **Makefile Generation**: Programmatic Makefile creation with variables, pattern rules, conditionals
29
+ - **CMake Generation**: Full CMakeLists.txt generation with find_package, FetchContent, install rules
30
+ - **Cross-Generator**: Define project once in JSON/YAML, generate both build systems
31
+ - **CMake Frontend**: Use CMake as build system with convenient Makefile wrapper
32
+ - **Project Templates**: Quick-start templates for common project types
33
+
34
+ ## Usage
35
+
36
+ ### CLI
37
+
38
+ ```bash
39
+ # Project configuration workflow (recommended)
40
+ buildgen project init -t full -n myproject -o project.json
41
+ buildgen project generate -c project.json --all
42
+ buildgen project types # List available templates
43
+
44
+ # Direct Makefile generation
45
+ buildgen makefile generate -o Makefile --targets "all:main.o:"
46
+ buildgen makefile build myprogram --cppfiles main.cpp
47
+
48
+ # Direct CMake generation
49
+ buildgen cmake generate -o CMakeLists.txt --project myapp --cxx-standard 17
50
+ buildgen cmake build -S . -B build --build-type Release
51
+ ```
52
+
53
+ ### Python API
54
+
55
+ ```python
56
+ from buildgen import ProjectConfig, TargetConfig, DependencyConfig
57
+
58
+ # Load from config file
59
+ config = ProjectConfig.load("project.json")
60
+ config.generate_all() # Creates Makefile and CMakeLists.txt
61
+
62
+ # Or build programmatically
63
+ config = ProjectConfig(
64
+ name="myproject",
65
+ version="1.0.0",
66
+ cxx_standard=17,
67
+ compile_options=["-Wall", "-Wextra"],
68
+ dependencies=[
69
+ DependencyConfig(name="Threads"),
70
+ DependencyConfig(
71
+ name="fmt",
72
+ git_repository="https://github.com/fmtlib/fmt.git",
73
+ git_tag="10.1.1",
74
+ ),
75
+ ],
76
+ targets=[
77
+ TargetConfig(
78
+ name="mylib",
79
+ target_type="static",
80
+ sources=["src/lib.cpp"],
81
+ include_dirs=["include"],
82
+ ),
83
+ TargetConfig(
84
+ name="myapp",
85
+ target_type="executable",
86
+ sources=["src/main.cpp"],
87
+ link_libraries=["mylib", "fmt::fmt"],
88
+ install=True,
89
+ ),
90
+ ],
91
+ )
92
+ config.generate_all()
93
+ ```
94
+
95
+ ### CMake with Makefile Frontend
96
+
97
+ Generate CMake as the build system with a Makefile that wraps cmake commands:
98
+
99
+ ```python
100
+ config.generate_cmake_with_frontend(
101
+ build_dir="build",
102
+ build_type="Release",
103
+ )
104
+ ```
105
+
106
+ This creates:
107
+ - `CMakeLists.txt` - The actual build logic
108
+ - `Makefile` - Convenience wrapper with targets:
109
+
110
+ ```bash
111
+ make # Configure and build
112
+ make build # Same as above
113
+ make configure # Run cmake configure only
114
+ make clean # Remove build directory
115
+ make rebuild # Clean and rebuild
116
+ make install # Install the project
117
+ make test # Run tests with ctest
118
+ make myapp # Build specific target
119
+ make help # Show available targets
120
+
121
+ # Override defaults
122
+ make BUILD_TYPE=Debug
123
+ make BUILD_DIR=cmake-build
124
+ make CMAKE_FLAGS="-DFOO=bar"
125
+ ```
126
+
127
+ ## Project Configuration
128
+
129
+ ### JSON Format
130
+
131
+ ```json
132
+ {
133
+ "name": "myproject",
134
+ "version": "1.0.0",
135
+ "cxx_standard": 17,
136
+ "compile_options": ["-Wall", "-Wextra"],
137
+ "dependencies": [
138
+ "Threads",
139
+ {"name": "OpenSSL", "required": true},
140
+ {
141
+ "name": "fmt",
142
+ "git_repository": "https://github.com/fmtlib/fmt.git",
143
+ "git_tag": "10.1.1"
144
+ }
145
+ ],
146
+ "targets": [
147
+ {
148
+ "name": "mylib",
149
+ "type": "static",
150
+ "sources": ["src/lib.cpp"],
151
+ "include_dirs": ["include"],
152
+ "install": true
153
+ },
154
+ {
155
+ "name": "myapp",
156
+ "type": "executable",
157
+ "sources": ["src/main.cpp"],
158
+ "link_libraries": ["mylib", "Threads::Threads"],
159
+ "install": true
160
+ }
161
+ ]
162
+ }
163
+ ```
164
+
165
+ ### Project Templates
166
+
167
+ ```bash
168
+ buildgen project types
169
+ ```
170
+
171
+ | Template | Description |
172
+ |----------|-------------|
173
+ | `executable` | Single executable (src/main.cpp) |
174
+ | `static` | Static library with include/ |
175
+ | `shared` | Shared library with -fPIC |
176
+ | `header-only` | Header-only/interface library |
177
+ | `library-with-tests` | Library + test executable |
178
+ | `app-with-lib` | Executable with internal library |
179
+ | `full` | Library + app + tests + Threads |
180
+
181
+ ## Low-Level API
182
+
183
+ For fine-grained control, use the generators directly:
184
+
185
+ ```python
186
+ from buildgen import MakefileGenerator, CMakeListsGenerator
187
+
188
+ # Makefile
189
+ gen = MakefileGenerator("Makefile")
190
+ gen.add_cxxflags("-Wall", "-std=c++17")
191
+ gen.add_target("myapp", "$(CXX) $(CXXFLAGS) -o $@ $^", deps=["main.o"])
192
+ gen.add_pattern_rule("%.o", "%.cpp", "$(CXX) $(CXXFLAGS) -c $< -o $@")
193
+ gen.add_phony("all", "clean")
194
+ gen.generate()
195
+
196
+ # CMake
197
+ gen = CMakeListsGenerator("CMakeLists.txt")
198
+ gen.set_project("myapp", version="1.0.0")
199
+ gen.set_cxx_standard(17)
200
+ gen.add_find_package("Threads", required=True)
201
+ gen.add_executable("myapp", ["src/main.cpp"], link_libraries=["Threads::Threads"])
202
+ gen.generate()
203
+ ```
204
+
205
+ ## Development
206
+
207
+ ```bash
208
+ make test # Run tests (194 tests)
209
+ make coverage # Coverage report
210
+ ```
211
+
212
+ ## License
213
+
214
+ GPL-3.0-or-later
@@ -0,0 +1,62 @@
1
+ [project]
2
+ name = "buildgen"
3
+ version = "0.1.1"
4
+ description = "Build system generator - Makefile, CMake, and more."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Shakeeb Alireza", email = "me@example.org" }
8
+ ]
9
+ license = "GPL-3.0-or-later"
10
+ requires-python = ">=3.11"
11
+ dependencies = []
12
+ keywords = [
13
+ "makefile",
14
+ "cmake",
15
+ "build-system",
16
+ "code-generation",
17
+ "cpp",
18
+ "c++",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Environment :: Console",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
25
+ "Operating System :: OS Independent",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Software Development :: Build Tools",
31
+ "Topic :: Software Development :: Code Generators",
32
+ "Typing :: Typed",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/shakfu/buildgen"
37
+ Repository = "https://github.com/shakfu/buildgen"
38
+ Issues = "https://github.com/shakfu/buildgen/issues"
39
+ Changelog = "https://github.com/shakfu/buildgen/blob/main/CHANGELOG.md"
40
+
41
+ [project.optional-dependencies]
42
+ yaml = ["pyyaml>=6.0"]
43
+
44
+ [project.scripts]
45
+ buildgen = "buildgen.cli:main"
46
+
47
+ [tool.pytest.ini_options]
48
+ pythonpath = ["src"]
49
+ testpaths = ["tests"]
50
+
51
+ [dependency-groups]
52
+ dev = [
53
+ "mypy>=1.19.1",
54
+ "pytest>=8.4.2",
55
+ "pytest-cov>=7.0.0",
56
+ "ruff>=0.14.9",
57
+ "twine>=6.2.0",
58
+ ]
59
+
60
+ [build-system]
61
+ requires = ["uv_build>=0.9.18,<0.10.0"]
62
+ build-backend = "uv_build"
@@ -0,0 +1,23 @@
1
+ """buildgen: Build system generator package.
2
+
3
+ Supports generating Makefiles, CMakeLists.txt, and direct compilation.
4
+
5
+ For additional components, import from submodules:
6
+ from buildgen.makefile.variables import Var, SVar, IVar, CVar, AVar
7
+ from buildgen.makefile.functions import makefile_wildcard, makefile_patsubst
8
+ from buildgen.cmake.variables import CMakeVar, CMakeCacheVar
9
+ from buildgen.common.project import TargetConfig, DependencyConfig
10
+ """
11
+
12
+ __version__ = "0.1.1"
13
+
14
+ # Core API - minimal exports for early development flexibility
15
+ from buildgen.common.project import ProjectConfig
16
+ from buildgen.makefile.generator import MakefileGenerator
17
+ from buildgen.cmake.generator import CMakeListsGenerator
18
+
19
+ __all__ = [
20
+ "ProjectConfig",
21
+ "MakefileGenerator",
22
+ "CMakeListsGenerator",
23
+ ]