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

Improve handling of feature flags #118

Merged

Conversation

JLockerman
Copy link
Contributor

This PR enables pgx to use cargo feature flags. It has two components:

  1. It adds a --features command line option to all cargo-pgx subcommands that build code or SQL. This flag is analogous to the corresponding cargo flag: the features passed in to this flag are passed to the internal cargo commands when building the library. e.g. cargo pgx run pg13 --features foo will run "cargo" "build" "--no-default-features" "--features" "pg13 foo"
  2. It teaches the script generator to obey a subset of #[cfg(...)] directives; it skips any object following a #[cfg(features="foo")] where the feature foo isn't passed in to the --features flag. (it also understands any(...) and all(...)).

The combination of these two commits allows users to enable and disable SQL functionality using cargo features.

cargo pgx currently builds with --no-default-features along with
a single postgres-version feature. This commit adds a flag allowing
arbitrary additional features to be passed to the underlying cargo
command.
This commit teaches 'cargo pgx' how to understand cfgs based on cargo
features, so that SQL can be generated, or not, depending on what
features are activated.
@eeeebbbbrrrr
Copy link
Contributor

eeeebbbbrrrr commented Apr 10, 2021

Can you take a look at the test that failed?

EDIT: I've taken care of this part

@eeeebbbbrrrr
Copy link
Contributor

Thanks @JLockerman! We'll take care of these, but there's two little changes before we merge:

  • centralize the duplicated code in main.rs related to pulling "features" string from the argument set
  • update the --help output in the various places in cargo-pgx' README.md

@eeeebbbbrrrr eeeebbbbrrrr changed the base branch from master to develop April 21, 2021 15:38
@Hoverbear Hoverbear merged commit 8e31a72 into pgcentralfoundation:develop Apr 21, 2021
@Hoverbear Hoverbear self-assigned this Apr 21, 2021
@Hoverbear Hoverbear requested review from Hoverbear and eeeebbbbrrrr and removed request for Hoverbear and eeeebbbbrrrr April 21, 2021 17:32
Hoverbear added a commit that referenced this pull request May 1, 2021
`pgx` v0.1.21 is a minor feature release with the following features:

* aarch64 support was added (#127)
* add Nix flake (#124)
* `cargo-pgx pgx init` does `initdb` (#123)
* Improve handling of feature flags (#118)
* Allow overriding function names and returning schema-qualified type (#117)
* update dependencies (#122).
* (docs) Add caveat about reconnecting after updating extension (#116)

There were the following fixes:

* (`cargo-pgx`) on init, lazy fetch version list (#119)

To upgrade, please run:

```
$ cargo install cargo-pgx --version 0.1.21
```

Also, make sure to update your Cargo.toml dependencies.

Signed-off-by: Ana Hobden <[email protected]>
@Hoverbear Hoverbear mentioned this pull request May 1, 2021
Hoverbear added a commit that referenced this pull request May 1, 2021
`pgx` v0.1.21 is a minor feature release with the following features:

* aarch64 support was added (#127)
* add Nix flake (#124)
* `cargo-pgx pgx init` does `initdb` (#123)
* Improve handling of feature flags (#118)
* Allow overriding function names and returning schema-qualified type (#117)
* update dependencies (#122).
* (docs) Add caveat about reconnecting after updating extension (#116)

There were the following fixes:

* (`cargo-pgx`) on init, lazy fetch version list (#119)

To upgrade, please run:

```
$ cargo install cargo-pgx --version 0.1.21
```

Also, make sure to update your Cargo.toml dependencies.

Signed-off-by: Ana Hobden <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants