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

[BUILD] Support pkg-config #2269

Merged
merged 8 commits into from
Aug 22, 2023
Merged

Conversation

dbolduc
Copy link
Contributor

@dbolduc dbolduc commented Aug 18, 2023

Fixes #1850

Generates and installs pkgconfig (*.pc) files for the following targets:

  • opentelemetry_api
  • opentelemetry_logs
  • opentelemetry_metrics
  • opentelemetry_resources
  • opentelemetry_trace
  • opentelemetry_version

The API is necessary, because we need to capture cflags, such as -DWITH_ABSEIL. I did not think installing an opentelemetry_sdk.pc was necessary or helpful.

Motivation: googleapis/google-cloud-cpp#10795

Testing

I added a test to validate the installed package configs. This does not guarantee that their contents are 100% correct.

I am new to using the CI. I am yolo'ing the changes to .github/workflows/ci.yml. I ran the steps locally, though, and they were successful:

ci/run_docker.sh

# Then inside docker...
ci/setup_cmake.sh
ci/setup_ci_environment.sh
ci/install_abseil.sh
ci/do_ci.sh cmake.install.test
ci/verify_packages.sh

My test installs opentelemetry-cpp built -DWITH_ABSEIL. The dimensions we care about are: [with/without abseil, with/without gsl] (as far as the install logic for opentelemetry_api goes). But I did not want to write all these tests, so I just checked the abseil case.

Testing while developing

I did some more rigorous testing while developing. The changes are in this commit.

Basically it has an executable that uses OTel types. This executable is built using a Makefile, through the use of pkg-config. With it, I was able to confirm that the installed libraries link, the include directories work, the compile definitions work, etc.

I tested this with/without abseil for all of the added targets listed above.

@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Merging #2269 (ce1b630) into main (11d5d9e) will increase coverage by 0.06%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2269      +/-   ##
==========================================
+ Coverage   87.47%   87.52%   +0.06%     
==========================================
  Files         199      199              
  Lines        5981     5981              
==========================================
+ Hits         5231     5234       +3     
+ Misses        750      747       -3     

see 1 file with indirect coverage changes

@dbolduc
Copy link
Contributor Author

dbolduc commented Aug 18, 2023

Sorry about iterating in the CI. It looks like the "Bazel tsan config" build is failing across the board, so I think this PR is ready for review.

@dbolduc dbolduc marked this pull request as ready for review August 18, 2023 21:01
@dbolduc dbolduc requested a review from a team August 18, 2023 21:01
@owent
Copy link
Member

owent commented Aug 19, 2023

Can we replace the add_library function in otel-cpp with a new function which can call add_library and opentelemetry_add_pkgconfig.And then it could automatically add all cmake targets and ensure that the package name in pkgconfig matches the cmake package name?

@dbolduc
Copy link
Contributor Author

dbolduc commented Aug 19, 2023

Can we replace the add_library function in otlp-cpp with a new function which can call add_library and opentelemetry_add_pkgconfig.And then it could automatically add all cmake targets and ensure that the package name in pkgconfig matches the cmake package name?

opentelemetry_add_pkgconfig inspects properties of the library target:

get_target_property(target_type ${target} TYPE)

... so I think we are already ensuring that the package name in pkgconfig matches the cmake package name.

This also means that we can only call opentelemetry_add_pkgconfig after all of the target_include_directories(target, ...) and target_compile_definitions(target, ...) have been set. I think this means we can not combine the add_library and opentelemetry_add_pkgconfig functions.

otlp-cpp

Sorry if I am misunderstanding your question. I am not so sure what this is. I did not touch any of the OTLP components. We can always address them in a follow up PR.

@owent
Copy link
Member

owent commented Aug 19, 2023

This also means that we can only call opentelemetry_add_pkgconfig after all of the target_include_directories(target, ...) and target_compile_definitions(target, ...) have been set. I think this means we can not combine the add_library and opentelemetry_add_pkgconfig functions.

Thanks, I think it's fine.

Sorry if I am misunderstanding your question. I am not so sure what this is. I did not touch any of the OTLP components. We can always address them in a follow up PR.
Sorry for my mistake. I mean otel-cpp, not OTLP.

Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks.

@dbolduc
Copy link
Contributor Author

dbolduc commented Aug 22, 2023

Any chance this feature makes it into the v1.11.0 release?

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done. Thanks for contributing.

@ThomsonTan - Do you think it can be included in the v1.11.0?

@ThomsonTan
Copy link
Contributor

Nicely done. Thanks for contributing.

@ThomsonTan - Do you think it can be included in the v1.11.0?

This is missed in the v1.1.0 release. As this is a new feature, I think it will be good to stay in main for a release cycle.

@ThomsonTan ThomsonTan merged commit c0f17d9 into open-telemetry:main Aug 22, 2023
44 checks passed
@dbolduc dbolduc deleted the support-pkgconfig branch August 22, 2023 20:34
@dbolduc
Copy link
Contributor Author

dbolduc commented Aug 22, 2023

As this is a new feature, I think it will be good to stay in main for a release cycle.

Ack. Thanks for merging.

@marcalff marcalff changed the title Support pkg-config [BUILD] Support pkg-config Oct 11, 2023
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.

Consider supporting pkg-config
4 participants