-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CLI for creating a debug build (#7)
This is useful for hooking up as a VSCode launch configuration alongside an LLDB debugger.
- Loading branch information
Showing
7 changed files
with
69 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import argparse | ||
import os | ||
import shutil | ||
import subprocess | ||
|
||
from pydust import config, zigexe | ||
|
||
parser = argparse.ArgumentParser() | ||
sub = parser.add_subparsers(dest="command", required=True) | ||
|
||
debug = sub.add_parser("debug", help="Compile a Zig file with debug symbols. Useful for running from an IDE.") | ||
debug.add_argument("entrypoint") | ||
|
||
|
||
def main(): | ||
args = parser.parse_args() | ||
|
||
if args.command == "debug": | ||
debug(args) | ||
|
||
|
||
def debug(args): | ||
"""Given an entrypoint file, compile it for test debugging. Placing it in a well-known location.""" | ||
entrypoint = args.entrypoint | ||
|
||
filename = os.path.basename(entrypoint) | ||
name, _ext = os.path.splitext(filename) | ||
|
||
ext_module = config.ExtModule( | ||
name=name, | ||
root=entrypoint, | ||
# Not sure how else we could guess this? | ||
limited_api=False, | ||
) | ||
|
||
with zigexe.build_argv("test", ext_module, optimize="Debug") as argv: | ||
subprocess.run(argv, check=True) | ||
|
||
os.makedirs("zig-out/", exist_ok=True) | ||
shutil.move(ext_module.test_bin, "zig-out/debug.bin") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ description = "" | |
authors = ["Nicholas Gates <[email protected]>"] | ||
license = "Apache 2.0" | ||
readme = "README.md" | ||
packages = [{include = "pydust"}] | ||
packages = [{ include = "pydust" }] | ||
include = ["src"] | ||
exclude = ["example"] | ||
|
||
|
@@ -19,6 +19,9 @@ pytest = "^7.4.0" | |
ruff = "^0.0.286" | ||
black = "^23.7.0" | ||
|
||
[tool.poetry.scripts] | ||
pydust = "pydust.__main__:main" | ||
|
||
[tool.black] | ||
line-length = 120 | ||
|
||
|