Skip to content

PLIBS_9 logo


pipeline status Latest release coverage report documentation Phoenix2 documentation phoenixfilegenerator conda channel

Code

Source code is available here

Documentation

User documentation can be found here

Quick Start

Simple sources/header files generation

To generate an empty shadok.h and shadok.cpp files :

phoenix_filegenerator source -n Shadok

Nohting more to say, but it saves some times.

Simple class generation

To generate an empty Shadok class :

phoenix_filegenerator class -n Shadok

The previous command will generate an empty Shadok class with Shadok.h and Shadok.cpp files and basic constructor, destructor, copy function and equal operator.

Class generation from a configuration

Let's define a simple configuration in the file Shadok.pdata

///@brief Test Shadok
Shadok {
    ///Age of the Shadok
    int age;
    ///Name of the Shadok
    std::string name;
}

Do not hesitate to put some documentation into your class definition because it will be transfered into the generated code !

Then, you can call :

phoenix_filegenerator class -c Shadok.pdata

You can add multiple options to the command call depending on your requirements and the following arguments :

option name option type long value short value default value description
name String --name -n NONE base name of the file to be created
template String --template -t NONE template definition of the class
config FILENAME --config -c NONE configuration file .pdata used to create a class
datastream Bool --datastream -s false enable interfacing with PhoenixDataStream
typestream Bool --typestream -y false enable interfacing with PhoenixTypeStream
configstream Bool --configstream -f false enable interfacing with PhoenixConfigStream
tests Bool --tests -u false enable unit tests generation for generated class
testDir FILENAME --testdir -d NONE repository where to save the generated tests. Refers to the current directory for relative path
outputPath FILENAME --outputpath -o NONE Path where the generated source files from the class will be saved
projectName String --projectname -r NONE Name of the project target to generate class in with unit test

Generation of a full project

The project mode allows to generate a full project with some options of your choice, following the given arguments :

option name option type long value short value default value description
description FILENAME --description -d NONE The project descriptor file described in toml
config FILENAME --config -c NONE The class descriptor file described in toml
type String --type -t SimpleCpp Type of the project (base project is Simple cpp project)
pythonWrapper Bool --pythonwrapper -w false enable the generation of the python wrapper for the generated source code
datastream Bool --datastream -s false enable the interfacing with PhoenixDataStream
typestream Bool --typestream -y false enable the interfacing with PhoenixTypeStream
configStream Bool --configstream -f false enable the interfacing with PhoenixConfigStream
tests Bool --tests -u false enable unit test generation for the generated classes

Example project.toml descriptor file:

[project]
name = "StereoData"
url = "https://gitlab.in2p3.fr/CTA-LAPP/RTA/Stereo/StereoData"
version = "0.1.0"
description = "A very important project"
main_branch = "main"
runner_tag = "MUST_big_runner"
ci_toolkit_url = "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/citoolkit/phoenixcitoolkitcpp/phoenix-workflow-cpp"
ci_toolkit_version = "3.0.4"
authors = [
    { firstName = "Oprinsen", lastName = "Thibaut", affiliation = "LAPP, Univ. Savoie Mont-Blanc, CNRS", mail = "thibaut.oprinsen@lapp.in2p3.fr" },
    { firstName = "Aubert", lastName = "Pierre", affiliation = "LAPP, Univ. Savoie Mont-Blanc, CNRS", mail = "pierre.aubert@lapp.in2p3.fr" }
]
maintainers = [
    { firstName = "Aubert", lastName = "Pierre", affiliation = "LAPP, Univ. Savoie Mont-Blanc, CNRS", mail = "pierre.aubert@lapp.in2p3.fr" }
]
contributors = [
    { firstName = "Pollet", lastName = "Vincent", affiliation = "LAPP, Univ. Savoie Mont-Blanc, CNRS", mail = "vincent.pollet@lapp.in2p3.fr" }
]
keywords = ["stereo", "data", "analysis", "CTA", "RTA"]
dependencies = ["PhoenixToml >=1.0.0, <2.0.0",
                "PhoenixYml ==1.0.0",
                "PhoenixCore",
                "PhoenixDataStream >=1.0.0, <2.0.0",
                "PhoenixTypeStream >=1.1.0, <2.0.0",
                "PhoenixConfigStream >=2.0.0, <3.0.0",
                "curl >=8.0.0, <9.0.0"]

For more details about the content of the project.toml you can refer to teh documentation of PhoenixGenerator which describes the content required for project generation.

Then, you can call :

phoenix_filegenerator project -d project.toml -c Shadok.pdata

You can also add the --wrapper option to generate the full python wrapper of the project. The wrapper will interpret several extra types : - DataStreamMsg : the message of PhoenixDataStream will be replaced by a ByteArrayObject - PPath and PString : Path and String of Phoenix will be replaced by Python String (str)

Requirements

  • c++ compiler (tested with g++ 11,12 and clang 14)
  • PhoenixCMake
  • cmake > 3
  • make

Installation for Users

Install packages using pixi conda manager

Each Phoenix package is packaged using pixi, a modern and fast conda package manager. Pixi simplifies environment management and installation, ensuring reproducible builds and easy dependency handling. Phoenix packages are hosted on prefix.dev, with two dedicated channels: - phoenix for stable releases. - phoenix-dev for development packages. These packages are build from the latest developments in the Phoenix projects, they can be deleted at any moment. Using pixi is recommended for people that get started using or developing Phoenix packages. It will speed up your setup, handle the dependencies resolution and updates, and allow you to use the tasks defined for common development operations (run test, build doc, etc.)

To install the package in a globally accessible location and exposes its command line applications:

pixi global install -c conda-forge -c https://prefix.dev/phoenix phoenixfilegenerator

Using this command you can specify : - the channel where the package is located: https://prefix.dev/phoenix - the version you want to install, for instance "phoenixfilegenerator==0.8.0"

To use this library as a dependency in your own pixi projects, you must add the dependency into your workspace. First, add the Phoenix channel into your workspace:

[workspace]
channels = [
    "https://prefix.dev/phoenix"
]

then add the dependency on the library. For instance to add the library in your default environment:

pixi add phoenixfilegenerator

Install from sources using pixi

To develop the library using a pixi installation, download the sources and then you will be able to run tasks define in the pixi.toml file using pixi:

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/PhoenixFileGenerator.git
cd PhoenixFileGenerator
pixi install -a 
pixi run test # task defined in the pixi.toml used to run the tests

The basic available tasks in the pixi.toml are : | | Objective | Inputs | Outputs | |-----------------------|:-----------------------------------------------------:|:----------------------------------------------------------:|:-------------------:| | pixi run test | Run the tests of the current package | - | - | | pixi run coverage | Generate the coverage report of the current project. | Output folder for coverage reports. Default is coverage | coverage folder | | pixi run doc | Generate documentation of the current project | docDir Output folder for documentation | docDir folder |

Install from sources

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixFileGenerator.git
cd PhoenixFileGenerator
./install.sh

Then PhoenixFileGenerator is installed in your $HOME/usr.

If you prefer a customized install path you can do :

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixFileGenerator.git
cd PhoenixFileGenerator
./install.sh /your/install/path

If you prefer a customized install path with custom compilation you can do :

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixFileGenerator.git
cd PhoenixFileGenerator
mkdir -p build
cd build
cmake .. $(phoenixcmake-config --cmake)
make -j `nproc`
make install -j `nproc`

The nproc gives the number of cores of the computer. If you want a build on one core you can just type :

make
make install

Update PhoenixFileGenerator

If you want to update the software :

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixFileGenerator.git
cd PhoenixFileGenerator
./update.sh

If you want to update the software with a custom install path :

git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixFileGenerator.git
cd PhoenixFileGenerator
./update.sh /your/install/path