Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use dstep generate PostgreSQL & MySQL binding? #289

Open
zoujiaqing opened this issue Mar 15, 2024 · 7 comments
Open

How to use dstep generate PostgreSQL & MySQL binding? #289

zoujiaqing opened this issue Mar 15, 2024 · 7 comments
Labels

Comments

@zoujiaqing
Copy link

Thank you.

@jacob-carlborg
Copy link
Owner

jacob-carlborg commented Mar 15, 2024

  1. Download the latest release from: https://github.com/jacob-carlborg/dstep/releases/tag/v1.0.0. If you're using macOS you probably need to compile it yourself
  2. Run DStep and pass the header file to it dstep mysql.h. It will output a corresponding D file mysql.d.

You can pass multiple files as well. You might need to add imports to the D files after running DStep. You might also need to pass some compiler flags to DStep. DStep accepts the same flags as Clang does.

See the readme as well:

https://github.com/jacob-carlborg/dstep?tab=readme-ov-file#usage

@zoujiaqing
Copy link
Author

Thank you jacob!

Show error:

~/Downloads/dstep mysql.h -o mysql.d
dyld[59002]: missing symbol called
zsh: abort      ~/Downloads/dstep mysql.h -o mysql.d

System info:

uname -a
Darwin mac 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64

@jacob-carlborg
Copy link
Owner

For macOS you need to compile it yourself. There are build instructions in the readme [1]. I recommend using LLVM/libclang 15.0.7.

[1] https://github.com/jacob-carlborg/dstep?tab=readme-ov-file#building

@jacob-carlborg
Copy link
Owner

I'll try to put out a new release, with precompiled binaries, but that might take a while.

@zoujiaqing
Copy link
Author

zoujiaqing commented Mar 16, 2024

Thank you!

mysql.d file has generated!

An warning has occurred:

% ./configure --llvm-path /opt/homebrew/Cellar/llvm@15/15.0.7
% dub build
% mv bin/dstep ~/bin/dstep
% cd ~/projects/test
% ~/bin/dstep mysql.h -o mysql.d
./field_types.h:54:6: warning: a type renamed to 'enum_field_types_' due to the collision with the symbol declared in ./field_types.h:94:31

step version:

% ~/bin/dstep --version
1.0.4-26-g5541229

@jacob-carlborg
Copy link
Owner

I think that warning should be fine. It's printed due to there's an enum named enum_field_types and a typedef with the same name. That's fine in C, since in C you need to explicitly include the enum keyword when referring to an enum. But in D that's not the case.

@jacob-carlborg
Copy link
Owner

BTW, there are several existing bindings to MySQL and PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants