mdavidsaver / pvxs

PVA protocol client/server library and utilities.
https://mdavidsaver.github.io/pvxs/
Other
19 stars 25 forks source link

CMake support? #15

Open thomasms opened 3 years ago

thomasms commented 3 years ago

Hi, is there any chance that there will be CMake support for pvxs in the future?

I could potentially have a go at adding this if there are no plans to do so.

mdavidsaver commented 3 years ago

I hadn't thought about cmake for this module. Have you found https://github.com/epicsdeb/cmake4epics ? I think this would be fairly straightforward to apply, with the possible exception of cleverness involving configure/toolchain.c. Another complication is CI coverage to make sure it stays working. The ci-scripts module assumes use of the Base makefiles.

thomasms commented 3 years ago

Ah no, I hadn't come across cmake4epics before. CMake would really be a lot nicer to manage and would prevent the current build system from polluting my machine. Surely just because epics-base doesn't use CMake doesn't mean PVXS can't.

With regard to PVXS if I understand correctly it doesn't depend on pvData or pvAccess, right? Does it just depend on libcom from epics-base?

Ideally, I would like to avoid the perl scripts and Makefiles which make it very difficult to incorporate into other projects or to even build applications using PVXS and pvAccess.

For one, I have epics-base v7.0 already built on my machine and have some (working) applications using pvAccess and pvDatabase but I would also like to try and use PVXS in this application (to compare how the APIs work, etc), but when I follow the steps here I get the following error:

$make
#....

perl -CSD /home/user/dev/epics-base/bin/linux-x86_64/convertRelease.pl checkRelease

Definition of EPICS_BASE conflicts with PVXS support.
In this application or module, a RELEASE file
conflicts with PVXS at /home/user/dev/pvxs/
  Here: EPICS_BASE = ${EPICS7_DIR}
  PVXS: EPICS_BASE = /home/user/dev/pvxs//../epics-base

/home/user/dev/epics-base//configure/RULES_BUILD:190: recipe for target 'checkRelease' failed
#...
make: *** [configure.install] Error 2

Note: I am using the exampleCPP project template: https://github.com/epics-base/exampleCPP so my configure/RELEASE.local looks something like:

# This is a an  example RELEASE.local file for use with epics 7 releases.
# Copy this file to configure/RELEASE.local.
# Change the first line and also EPICS_BASE if using different version of base.
# type make at top level

PVXS=/home/user/dev/pvxs/
EPICS7_DIR=/home/user/dev/epics-base/

PVDATABASE=${EPICS7_DIR}
PVACLIENT=${EPICS7_DIR}
PVA2PVA=${EPICS7_DIR}
PVACCESS=${EPICS7_DIR}
NORMATIVETYPES=${EPICS7_DIR}
PVDATA=${EPICS7_DIR}
EPICS_BASE=${EPICS7_DIR}
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top

I've probably missed something or not correctly understood the documentation, so apologies if it is a simple fix, but CMake would still be a nice enhancement.

bhill-slac commented 3 years ago

Thomas, Make sure your RELEASE.local uses parenthesis instead of curly brackets for variable expansion. i.e. PVACLIENT=$(EPICS7_DIR) not PVACLIENT=${EPICS7_DIR} Cheers,

...

thomasms commented 3 years ago

@bhill-slac Thanks! Indeed that fixes the previous error, it's odd because it worked with curly braces using pvAccess + pvDatabase, maybe it would be good to correct the documentation on exampleCPP to reflect this, as it uses curly braces: https://github.com/epics-base/exampleCPP/blob/master/ExampleRELEASE.local - but I guess that is a separate issue and nothing to do with PVXS.

However I am do get a warning regarding duplicate definitions:

/home/user/dev/epics-base//configure/RULES_BUILD:578: Warning: Base configure/RULES_BUILD file included more than once. Does configure/RELEASE have multiple pointers to /home/user/dev/epics-base/?
mdavidsaver commented 3 years ago

Surely just because epics-base doesn't use CMake doesn't mean PVXS can't.

It certainly could. cmake4epics ended up as a separate module after my unsuccessful attempt to convert epics-base itself to use cmake.

With regard to PVXS if I understand correctly it doesn't depend on pvData or pvAccess, right? Does it just depend on libcom from epics-base?

Yes and Yes.

$ readelf -d lib/linux-x86_64/libpvxs.so|grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libCom.so.3.18.2]
 0x0000000000000001 (NEEDED)             Shared library: [libevent_core-2.1.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libevent_pthreads-2.1.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]

Ideally, I would like to avoid the perl scripts and Makefiles ...

fyi. Recent epics-base also installs pkg-config files. Plain epics-base.pc being an alias for the build target.

$ ls lib/pkgconfig/
epics-base-linux-x86_64-debug.pc  epics-base-linux-x86_64.pc  epics-base.pc
$ PKG_CONFIG_PATH=$PWD/lib/pkgconfig pkg-config --cflags-only-I epics-base
-I/home/mdavidsaver/work/epics/base-git/include -I/home/mdavidsaver/work/epics/base-git/include/os/Linux -I/home/mdavidsaver/work/epics/base-git/include/compiler/gcc
mdavidsaver commented 3 years ago

it's odd because it worked with curly braces

This is likely arising from a detail that configure/RELEASE is parsed both as a Makefile and as a configuration file for the convertRelease.pl script. GNU make will expand either ${} or $() almost equivalently, however the script only expands $().
So the example you found is broken.

thomasms commented 3 years ago

I think this is an epics-base issue but follows on from the comments above.

For my configure/RELEASE.local, if I do as follows, all is fine.

PVXS=/home/user/Dev/pvxs
EPICS7_DIR=/home/user/Dev/epics-base
PVDATABASE=$(EPICS7_DIR)
PVACLIENT=$(EPICS7_DIR)
PVA2PVA=$(EPICS7_DIR)
PVACCESS=$(EPICS7_DIR)
NORMATIVETYPES=$(EPICS7_DIR)
PVDATA=$(EPICS7_DIR)
EPICS_BASE=$(EPICS7_DIR)
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top

But reordering such that PVXS is in between EPICS7_DIR and PVDATABASE variables, as below:

EPICS7_DIR=/home/user/Dev/epics-base
PVXS=/home/user/Dev/pvxs
PVDATABASE=$(EPICS7_DIR)
PVACLIENT=$(EPICS7_DIR)
PVA2PVA=$(EPICS7_DIR)
PVACCESS=$(EPICS7_DIR)
NORMATIVETYPES=$(EPICS7_DIR)
PVDATA=$(EPICS7_DIR)
EPICS_BASE=$(EPICS7_DIR)
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top

Gives the following error:

This application's RELEASE file(s) define
    PVDATABASE = /home/user/Dev/epics-base
and
    EPICS7_DIR = /home/user/Dev/epics-base
Module definitions that share the same path must have their
first definitions grouped together. Either remove a module,
or arrange them so all those with that path are adjacent.
Any non-module definitions belong in configure/CONFIG_SITE.

The error is indeed accurate and telling me what is wrong, I am just a bit shocked that the order of variables definitions can cause such a catastrophic error.

Is there a specific reason for this? Is this an artifact of make or the way epics-base builds?

mdavidsaver commented 3 years ago

Is there a specific reason for this? Is this an artifact of make or the way epics-base builds?

This is related to my earlier statement about RELEASE files also being parsed by the convertRelease.pl script. The ordering of definitions in this file (or files) controls the search order for headers and libraries (eg. -I and -L).

thomasms commented 3 years ago

Is this a known bug or a feature of epics-base?