YACSGEN - Salome Module Generator

Does anyone have a sample YACSGEN - SALOME module generator script that I can use to get started making Salome modules from C++ or Fortran? I tried a few times to put a script together after reading the documentation, but I don’t think I am putting everything into the script needed to make it work.

If someone could provide a working sample script for a simple component that would really help me get going.

I am using Ubuntu 20.04, Salome-9.9.0.

I run from terminal:

source env_build.sh
python mymodule.py

Where mymodule,py contains the following:

from module_generator import *
import os

kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
gui_root_dir=os.environ["GUI_ROOT_DIR"]
yacs_root_dir=os.environ["YACS_ROOT_DIR"]
salome_env="~/programs/SALOME-9.9.0/env_build.sh"

context={'update':1,
         "prerequisites":salome_env,
         "kernel":kernel_root_dir,
         "yacs":yacs_root_dir
        }

c1=CPPComponent("mycompo",
                 services=[
                           Service("myservice",
                                   inport=[("inputport","double"),],
                                   outport=[("outputport","double")],
                                   defs="#include <iostream>",
                                   body="outputport=2*inputport;",
                                  ),
                          ]
               )

m=Module("mymodule",components=[c1],prefix="myInstall")
g=Generator(m,context)
g.generate()
g.configure()
g.make()
g.install()
g.make_appli("myappli",restrict=["KERNEL","GUI","YACS"])

The error I get is:

Traceback (most recent call last):
  File "mymodule.py", line 32, in <module>
    g.make_appli("myappli",restrict=["KERNEL","GUI","YACS"])
  File "/home/dan/programs/SALOME-9.9.0/INSTALL/YACSGEN/lib/python3.8/site-packages/module_generator/gener.py", line 954, in make_appli
    salome_context = os.path.join(ROOT_SALOME, "salome_context.cfg")
  File "/usr/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Note that:

echo ${ROOT_SALOME}

indicates ROOT_SALOME is empty.

Thanks in advance,

Sesqui

Hoping someone can help by providing a simple example procedure for using YACSGEN to make a module on Ubuntu 20.04 with SALOME-9.9.0. The online documentation is still a bit different…

Sesqui

Hi Sesqui,
it seems that the approach described in the Yacsgen documentation is not universal and needs to be revisited.
Here is how you can proceed to implement your module (C++, which may then link against some software written in fortran), and taking advantage from the fact that migration to new SALOME session less mode (SSL) is implemented in that module.

Below, I am basically translating the steps that were described for the implementation of a Python module (see this discussion SF-354
In your case, do the following (the MYMODULE.tar.gz archive is attached)

# 0 - extract SALOME
tar zxf SALOME-9.9.0-native-UB20.04-SRC.tar.gz
cd SALOME-9.9.0-native-UB20.04-SRC
chmod +x ./install_bin.sh

#- 1 -  setup developer mode
./install_bin.sh

# 2 - clone  CONFIGURATION 
./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION

# 3 - generate environment scripts
./sat/sat environ SALOME-9.9.0-native

# 4 - setup SALOME build environment
source ./env_build.sh

# 5 -  clone the HELLO C++  module
cd  $PRODUCT_ROOT_DIR/SOURCES
git clone https://git.salome-platform.org/gitpub/samples/hello.git MYMODULE
cd MYMODULE

# 6 -  rename all directories from HELLO to MYMODULE
find . -execdir rename 's/HELLO/MYMODULE/' '{}' \+
find . -execdir rename 's/hello/mymodule/' '{}' \+

# 7 - rename all occurences of HELLO MYMODULE
find . -type f -exec sed -i 's/HELLO/MYMODULE/g' {} +
find . -type f -exec sed -i 's/hello/mymodule/g' {} +
find . -type f -exec sed -i 's/Hello/myModule/g' {} +

# 8 -  build my module MYMODULE
mkdir -p $PRODUCT_ROOT_DIR/BUILD/MYMODULE
cd $PRODUCT_ROOT_DIR/BUILD/MYMODULE
cmake  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PRODUCT_ROOT_DIR/INSTALL/MYMODULE $PRODUCT_ROOT_DIR/SOURCES/MYMODULE
make
make install

# 9 - generate SALOME launcher.
cd $PRODUCT_ROOT_DIR
./sat/sat launcher SALOME-9.9.0-native 

# 10 -  edit file salome and just before section: # [APPLI variables], add following lines:

    #[MYMODULE]
    context.setVariable(r"MYMODULE_ROOT_DIR", r"${PRODUCT_ROOT_DIR}/INSTALL/MYMODULE", overwrite=True)
    context.setVariable(r"MYMODULE_SRC_DIR", r"${PRODUCT_ROOT_DIR}/SOURCES/MYMODULE", overwrite=True)
    context.addToPath(r"${MYMODULE_ROOT_DIR}/bin/salome")
    context.addToLdLibraryPath(r"${MYMODULE_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYMODULE_ROOT_DIR}/bin/salome")
    context.addToPythonPath(r"${MYMODULE_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYMODULE_ROOT_DIR}/${PYTHON_LIBDIR}/salome")
    appendPath(r"SALOME_MODULES", r"MYMODULE",separator=",")
    appendPath(r"SalomeAppConfig", r"${PRODUCT_ROOT_DIR}/INSTALL/MYMODULE/share/salome/resources/mymodule",separator=":")

    # [APPLI variables]

# 11 - Launch SALOME either with your module only or with all modules

cd $PRODUCT_ROOT_DIR
./salome
or
./salome -m MYMODULE


HTH

MYMODULE.tar.gz (713.7 KB)