json icon indicating copy to clipboard operation
json copied to clipboard

Not all source files get extracted with bcp

Open tomaszmi opened this issue 2 years ago • 12 comments

Version of Boost: 1.76

When extracting Boost.JSON from the boost sources using the bcp tool, it seems that not all files get properly copied.

Steps necessary to reproduce the problem:

curl --silent --show-error -L https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 -o ./boost.tar.bz2
mkdir boost_build
tar xf boost.tar.bz2 -C ./boost_build --strip-components=1
cd boost_build && ./bootstrap.sh && ./b2 tools
mkdir ~/boost_json_extract/
./dist/bin/bcp boost/json.hpp ~/boost_json_extract/
tree ~/boost_json_extract > content_stage1.txt
./dist/bin/bcp boost/json/src.hpp ~/boost_json_extract/
tree ~/boost_json_extract > content_stage2.txt

The following are the content files generated. content_stage1.txt content_stage2.txt

Please note that the content_stage1.txt file does not contain the src.hpp file - it gets copied only when passing it to bcp explicitly (so exists in the content_stage2.txt file), however none of these text files contains the src.cpp file entry.

All relevant compiler information

Apple clang version 13.0.0 (clang-1300.0.29.3), MacBook Pro (13-inch, M1, 2020). It seems to be compiler independent.

tomaszmi avatar Nov 13 '21 09:11 tomaszmi

After some investigation I discovered that this is due to optional header-only support (src.cpp does not contain any function definitions, .ipp files do). Unfortunately I don't think we can do anything to fix this on our side. Effectively, we'd have to move all .ipp files to src directory, but that would break b2 headers.

grisumbras avatar Nov 13 '21 11:11 grisumbras

@pdimov ?

vinniefalco avatar Nov 14 '21 14:11 vinniefalco

??

pdimov avatar Nov 14 '21 14:11 pdimov

Judging by

INFO: tracking source dependencies of library container due to presence of "BOOST_CONTAINER_DECL memory_resource* new_delete_resource() BOOST_NOEXCEPT;" in file "boost\container\pmr\global_resource.hpp"

bcp has some heuristic to figure out when a library is compiled, but I don't know what it is.

pdimov avatar Nov 14 '21 14:11 pdimov

I've already explained the reason above: src.cpp doesn't actually contain any function definitions. I guess, we could put a fake function into the file, but, IMO, that's silly. bcp json output_dir should still work.

grisumbras avatar Nov 14 '21 15:11 grisumbras

Also, I suspect making bcp copy sources won't matter much, because building Json also depends on Config jam files, which aren't copied. At this point, it's simpler for users to run bcp json/src.hpp and use Json as a header-only library.

grisumbras avatar Nov 14 '21 15:11 grisumbras

I've already explained the reason above: src.cpp doesn't actually contain any function definitions.

That's not what the word "explained" means.

I guess, we could put a fake function into the file, but, IMO, that's silly.

I don't see anything particularly wrong with that. The other option is fixing this on the bcp side, but I'm not sure how.

pdimov avatar Nov 14 '21 15:11 pdimov

Oh, bcp supports giving it a name of a source file. So dist\bin\bcp libs/json/src/src.cpp tmp-json\ works, kind of. It doesn't copy the Jamfile but it's not clear whether people who use bcp need it.

pdimov avatar Nov 14 '21 15:11 pdimov

There's essentially no point in copying src.cpp without copying build scripts.

grisumbras avatar Nov 14 '21 15:11 grisumbras

dist\bin\bcp libs/json/src libs/json/build tmp-json\ then.

pdimov avatar Nov 14 '21 15:11 pdimov

I'm not at my computer, but IIRC, you also need at least boost-install and most of Config (not just the headers)

grisumbras avatar Nov 14 '21 15:11 grisumbras

bcp has logic to copy the necessary files, which I've updated in https://github.com/boostorg/bcp/pull/5 to include tools/boost-install and libs/headers, but I don't know why it doesn't activate here.

pdimov avatar Nov 14 '21 16:11 pdimov