Salome HOME
Merge branch 'V7_dev'
[tools/yacsgen.git] / Examples / mpi1 / components.py
1 # -*- coding: utf-8 -*-
2 import os
3 from module_generator import Generator,Module,Service
4 from module_generator import MPIComponent
5 from module_generator import Library
6
7 SALOME_ROOT=os.getenv("SALOME_DIR")
8 prerequis_file=os.path.join(SALOME_ROOT, "salome_prerequisites.sh")
9
10 kernel_root_dir=os.getenv("KERNEL_ROOT_DIR")
11 gui_root_dir=os.getenv("GUI_ROOT_DIR")
12 yacs_root_dir=os.getenv("YACS_ROOT_DIR")
13
14 context={'update':1,
15          "makeflags":"-j2",
16          "prerequisites":prerequis_file,
17          "kernel":kernel_root_dir
18         }
19
20 cwd=os.getcwd()
21
22 # PUT HERE DEFINITIONS OF THE COMPONENTS AND THE SERVICES
23 body_a="""
24 Mylibmpi myinstance;
25 res_val = myinstance.mympi_funct(in_val);
26 """
27
28 defs_service="""
29 """
30
31 service_s = Service("mpifunc",
32                     inport=[("in_val", "long")],
33                     outport=[("res_val", "long")],
34                     body=body_a,
35                     defs=defs_service
36                     )
37
38 mpilib_root_path = os.path.join(cwd, "mpilib")
39 mpilib_include_path = os.path.join(mpilib_root_path, "include")
40 mpilib_lib_path = os.path.join(mpilib_root_path, "lib")
41
42 compodefs = """
43 #include "mylibmpi.h"
44 """
45
46 compo=MPIComponent("mycompoMpi",
47                  services=[service_s],
48                  compodefs=compodefs,
49                  libs=[Library(name="mylibmpi", path=mpilib_lib_path)],
50                  rlibs=mpilib_lib_path,
51                  includes=mpilib_include_path,
52                 )
53
54 g=Generator(Module("mymodule",components=[compo],prefix="./install"),context)
55 g.generate()
56 g.configure()
57 g.make()
58 g.install()
59 g.make_appli("appli",
60              restrict=["KERNEL","GUI","YACS","JOBMANAGER"])
61
62