guru icon indicating copy to clipboard operation
guru copied to clipboard

dev-cpp/fast_obj: new package

Open vitaly-zdanevich opened this issue 9 months ago • 16 comments

vitaly-zdanevich avatar Mar 03 '25 05:03 vitaly-zdanevich

It doesnt define any install target + seems to only compile a static library. You can define src_install and use dolib and patch CMake so it can generate a shared library (or just install the static one, but I think using a shared library would be prefered)

stkw0 avatar Mar 03 '25 10:03 stkw0

use dolib

I got linter error

E: 'dolib' banned in EAPI 8

Please share some example, I do not use C/C++ and do not understand :(

vitaly-zdanevich avatar Mar 03 '25 11:03 vitaly-zdanevich

Something like:

IUSE="test"
RESTRICT="!test? ( test )"

src_configure() {
	local mycmakeargs=(
		-DFAST_OBJ_BUILD_TEST=$(usex test)
	)

	cmake_src_configure
}

src_install() {
	dolib.a "${BUILD_DIR}/libfast_obj_lib.a"
}

You could patch the CMakeLists.txt fail and change the STATIC library to SHARED and use dolib.so instead. Seeing it's such a small program I don't really now if there is much to gain, though.

stkw0 avatar Mar 03 '25 13:03 stkw0

You could patch the CMakeLists.txt fail and change the STATIC library to SHARED

In this PR? OR in Organic Maps?

vitaly-zdanevich avatar Mar 04 '25 07:03 vitaly-zdanevich

Something like:

Thanks, added your code to this PR. Emerging works without errors. Now its done?

vitaly-zdanevich avatar Mar 04 '25 07:03 vitaly-zdanevich

You could patch the CMakeLists.txt fail and change the STATIC library to SHARED

In this PR? OR in Organic Maps?

In this PR, I guess Organic maps will link correctly against it even if it's a shared library.

stkw0 avatar Mar 04 '25 09:03 stkw0

You could patch the CMakeLists.txt fail and change the STATIC library to SHARED

So, please assist - have no idea what to do.

vitaly-zdanevich avatar Mar 04 '25 12:03 vitaly-zdanevich

What I usually do, is git clone the repository, modify it as needed (in this case change the CMakeLists.txt line that creates a STATIC library to SHARED, see https://cmake.org/cmake/help/latest/command/add_library.html for more information). Then get the output of git diff and create a patch file for it and apply that patch in the ebuild using the PATCHES variable.

stkw0 avatar Mar 04 '25 13:03 stkw0

OM includes fast_obj currently in a way that it is expected as bundled source. I didn't find a place where the library is used (e.g. there seems to be no CMake-file that uses fast_obj in some way), is it needed at all? Probably, OM just needs the single header file.

I would suggest to first patch OM to use an unbundled version of fast_obj before investigating in improving the package. Also, upstream also likely only accept a patch for this, if it is still possible to use the bundled version.

gerion0 avatar Mar 04 '25 13:03 gerion0

What I usually do, is git clone the repository, modify it as needed (in this case change the CMakeLists.txt line that creates a STATIC library to SHARED, see https://cmake.org/cmake/help/latest/command/add_library.html for more information). Then get the output of git diff and create a patch file for it and apply that patch in the ebuild using the PATCHES variable.

Thanks, added patch, emerge error:

[ebuild   R   ~] dev-cpp/fast_obj-1.3 

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-cpp/fast_obj-1.3::guru
 * fast_obj-1.3.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                                               [ ok ]
>>> Unpacking source...
>>> Unpacking fast_obj-1.3.tar.gz to /var/tmp/portage/dev-cpp/fast_obj-1.3/work
>>> Source unpacked in /var/tmp/portage/dev-cpp/fast_obj-1.3/work
>>> Preparing source in /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3 ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build"
 * Applying static-to-shared.patch ...
patching file CMakeLists.txt
Hunk #1 succeeded at 1 with fuzz 1.                                                                                                                                                                              [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3 ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build"
cmake -C /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DFAST_OBJ_BUILD_TEST=no -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build/gentoo_toolchain.cmake /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3
loading initial cache file /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build/gentoo_common_config.cmake
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- The C compiler identification is GNU 13.3.1
-- The CXX compiler identification is GNU 13.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- <<< Gentoo configuration >>>
Build type      RelWithDebInfo
Install path    /usr
Compiler flags:
C               -O2                -march=native -pipe -frecord-gcc-switches
C++             -O2                -march=native -pipe -frecord-gcc-switches
Linker flags:
Executable      -fuse-ld=lld -Wl,-O3 -Wl,--as-needed -Wl,--gc-sections -Wl,--defsym=__gentoo_check_ldflags__=0
Module          -fuse-ld=lld -Wl,-O3 -Wl,--as-needed -Wl,--gc-sections -Wl,--defsym=__gentoo_check_ldflags__=0
Shared          -fuse-ld=lld -Wl,-O3 -Wl,--as-needed -Wl,--gc-sections -Wl,--defsym=__gentoo_check_ldflags__=0

-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3 ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build"
ninja -v -j32 -l32
[1/2] /usr/bin/x86_64-pc-linux-gnu-gcc -Dfast_obj_lib_EXPORTS -I/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3  -O2                -march=native -pipe -frecord-gcc-switches -fPIC -MD -MT CMakeFiles/fast_obj_lib.dir/fast_obj.c.o -MF CMakeFiles/fast_obj_lib.dir/fast_obj.c.o.d -o CMakeFiles/fast_obj_lib.dir/fast_obj.c.o -c /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3/fast_obj.c
[2/2] : && /usr/bin/x86_64-pc-linux-gnu-gcc -fPIC -O2                -march=native -pipe -frecord-gcc-switches  -fuse-ld=lld -Wl,-O3 -Wl,--as-needed -Wl,--gc-sections -Wl,--defsym=__gentoo_check_ldflags__=0   -Wl,--dependency-file=CMakeFiles/fast_obj_lib.dir/link.d -shared -Wl,-soname,libfast_obj_lib.so -o libfast_obj_lib.so CMakeFiles/fast_obj_lib.dir/fast_obj.c.o   && :
>>> Source compiled.
 * Skipping make test/check due to ebuild restriction.
>>> Test phase [disabled because of RESTRICT=test]: dev-cpp/fast_obj-1.3

>>> Install dev-cpp/fast_obj-1.3 into /var/tmp/portage/dev-cpp/fast_obj-1.3/image
!!! dolib: /var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build/libfast_obj_lib.a does not exist

Here

/var/tmp/portage/dev-cpp/fast_obj-1.3/work/fast_obj-1.3_build

is what I have:

-rwxr-xr-x 1 portage portage  21K Mar  5 18:03 libfast_obj_lib.so
-rw-r--r-- 1 portage portage  19K Mar  5 18:03 build.ninja
-rw-r--r-- 1 portage portage  16K Mar  5 18:03 CMakeCache.txt
-rw-r--r-- 1 portage portage 2.2K Mar  5 18:03 cmake_install.cmake
-rw-r--r-- 1 portage portage 1.4K Mar  5 18:03 gentoo_common_config.cmake
-rw-r--r-- 1 portage portage  913 Mar  5 18:03 gentoo_rules.cmake
-rw-r--r-- 1 portage portage  484 Mar  5 18:03 gentoo_toolchain.cmake
drwxr-xr-x 6 portage portage  200 Mar  5 18:03 CMakeFiles

vitaly-zdanevich avatar Mar 05 '25 14:03 vitaly-zdanevich

I would suggest to first patch OM to use an unbundled version of fast_obj

but you said that looks like Organic Maps does not use that dependency at all?

vitaly-zdanevich avatar Mar 05 '25 14:03 vitaly-zdanevich

OM seems to use the header but not the library.

gerion0 avatar Mar 10 '25 14:03 gerion0

I do not know C++ - header is still some code? Or we can drop that header from Organic Maps?

vitaly-zdanevich avatar Mar 10 '25 16:03 vitaly-zdanevich

@gerion0 ping

vitaly-zdanevich avatar Apr 11 '25 22:04 vitaly-zdanevich

ping anybody :(

vitaly-zdanevich avatar May 07 '25 22:05 vitaly-zdanevich

OM seems to use the header but not the library.

I do not know C++ - header is still some code? Or we can drop that header from Organic Maps?

@gerion0 please clarify.

vitaly-zdanevich avatar Sep 06 '25 06:09 vitaly-zdanevich