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 do we deal with prebuilt library? #51

Open
hl4 opened this issue May 13, 2019 · 7 comments
Open

how do we deal with prebuilt library? #51

hl4 opened this issue May 13, 2019 · 7 comments

Comments

@hl4
Copy link
Contributor

hl4 commented May 13, 2019

Is your feature request related to a problem? Please describe.
I want to include prebuilt library into the build system. e.g. the boost.filesystem library, unit-test-framework, openssl.

Describe the solution you'd like
We might introduce a configuration of the prebuilt library. e.g library may have name, header files, depends libraries and so on. we can load the config file while project is scanning. There are all binary component in evoke build system just like the builtin libraries.
We also can use the config for builtin libraries.

{
"boost_unit_test_framework": {
    "header": [
      "boost/test"
    ]
  },
  "boost_unittest_standalone": { 
    "headerOnly": true,
    "header": [
      "boost/test/included/unit_test.hpp"
    ]
  }
}

I found it hard to describe and to use the feature variant of prebuilt library. e.g. Boost.Asio library. They are introduced by feature macro, and resulted different library name and more dependancy.

additionally, we need to specify the platform, , runtime and debug variant of prebuilt library.

Describe alternatives you've considered
Should we only introduce those library built from source files?

Additional context
no more

@dascandy
Copy link
Owner

Good question. I've put up a draft in the root to make Evoke build itself with platform libraries - https://github.com/dascandy/evoke/blob/modules/packages.conf - which I seem to have committed to the modules branch. The syntax is pretty close to what you've defined so far, except based on (iirc) toml / the existing configuration file format. Right now, it does not take into account any configuration or toolset, so I know it's insufficient and in need of improvement.

Would you be willing to take that branch & explore where that feature leads?

@hl4
Copy link
Contributor Author

hl4 commented May 15, 2019

Yes, I would like to.
Actually I had roughly implement the feature but in JSON syntax, within json11 parse library from dropbox. I might commit a pr later.

@hl4
Copy link
Contributor Author

hl4 commented May 24, 2019

for discussion

each prebuilt binary file is a library/component. it implicts a configuration variant and can be used under compatible configuration.

the configuration may be encoded to the name of library file, just like boost did.

The critical information to use these library are which header file need the library. we may assume the prebuilt library has a predefined folder structure. We can scan the folder to get this info. such as

the-library-name/
   include/
   lib/
      libsomename.a
      libsomename-cfg.a
      libsomename-other-variant.a

But, It's hardly to define the dependancy of the library itself. for example, I found boost_system need link to ws2_32, and boost_filesystem obviously need boost_system. In this case, I think auto linking would be a good feature.

On the other hand, We should read those headers and libraries within compiler, in order to understand which header belongs to each libraries.

if we would use a configure file:

[boost_filesystem]
prefiex = "path-to-top-folder"
headers = "boost/filesystem"
depends = "boost_system"

[boost_filesystem.vc71]
depends = "ws2_32"

[boost_filesystem.d]
# for example
defines = "BOOST_DEBUG"
"stdc++" = "c++17"

we should decode the library name for vc71 and d.

@dascandy
Copy link
Owner

dascandy commented Jun 4, 2019

The description as you provide it just above is what is there now. It does not consider multiple variants of something to exist at all, so there's a point to improve on it.

What's there now works for me, but I see many places where it could do with improvement.

@hl4
Copy link
Contributor Author

hl4 commented Jun 6, 2019

Great work! but there are still some issue.

stdc++fs library is not always exist, but evoke try to link it all the time.
It's hard to fix.

  1. evoke don't support conditional macro(#if). we found both stdc++fs and boost::filesystem from fw/filesystem.hpp
  2. packages is not supported specify toolset. In my opinion, it may be too complicate to specify toolset and version.

@JulienGrv
Copy link
Contributor

JulienGrv commented Sep 17, 2019

@hl4 regarding 1. We could parse the source code using clang. It resolves macros.

Example: https://shaharmike.com/cpp/libclang/

Edit: add link to example

@dascandy
Copy link
Owner

dascandy commented Jul 9, 2022

Using clang removes one bit of problems, in exchange for lots more. Clang has entirely different goals.

Fundamentally, Evoke's approach does not support macros, and your code dependency graph should not depend (fundamentally) on macros.

Prebuilt libraries are now imported using packages.conf and after a few years of using this, for me it works really well. They basically are for your host platform, and for specific cross-platform builds. Those need a separate packages.conf which is not in right now, but the approach at least seems good.

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

No branches or pull requests

3 participants