Skip to content

Commit e4b518f

Browse files
authored
Merge pull request #419 from gonuke/wipe_cycstub_repo
Wipe cycstub repo
2 parents e3ddbc3 + 573d153 commit e4b518f

25 files changed

+158
-155
lines changed

source/arche/cli.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ single-string form ``spec`` (e.g. ``:cycamore:Source``) which is discussed
1313
To view the auto-generated XML schema used for validating archetype
1414
configuration parameters in input files:
1515

16-
.. code-block:: bash
16+
.. code-block:: console
1717
1818
$ cyclus --agent-schema :agents:Source
1919
<interleave>
@@ -33,7 +33,7 @@ configuration parameters in input files:
3333
To view a JSON structured output of all the data generated and collected from
3434
``#pragma cyclus`` annotations for a particular archetype:
3535

36-
.. code-block:: bash
36+
.. code-block:: console
3737
3838
$ cyclus --agent-annotations :cycamore:Source
3939
{
@@ -52,7 +52,7 @@ To view a JSON structured output of all the data generated and collected from
5252
5353
And to list all archetypes inside a particular library:
5454

55-
.. code-block:: bash
55+
.. code-block:: console
5656
5757
$ cyclus --agent-listing :cycamore
5858
:cycamore:DeployInst
@@ -71,7 +71,7 @@ Archetype Versioning
7171
The ``cyclus::Agent`` class exposes a ``version()`` member function which can be
7272
queried with the |Cyclus| CLI. For example,
7373

74-
.. code-block:: bash
74+
.. code-block:: console
7575
7676
$ cyclus --agent-version :agents:Source
7777
1.3.1-7-g9a2c9c9
@@ -94,7 +94,7 @@ your own version tag information for some archetype like
9494
9595
and then access the version with
9696

97-
.. code-block:: bash
97+
.. code-block:: console
9898
9999
$ cyclus --agent-version my/path:my_library:MyArchetype
100100
My Version

source/arche/cmake.rst

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
Building Modules with CMake
44
===========================
55

6-
If you haven't follow the initial example in :ref:`hello_world_cpp`, you should get
7-
the `Cycstub repo <https://github.com/cyclus/cycstub>`_ by either `cloning the
8-
repository <https://github.com/cyclus/cycstub.git>`_ or by `downloading the zip
9-
file <https://github.com/cyclus/cycstub/archive/develop.zip>`_ (see
10-
:ref:`hello_world_cpp` for further instructions).
6+
If you haven't followed the initial example in :ref:`hello_world_cpp`, you should use
7+
``cycstub`` to generate a directory with the "stubs" to build a new archetype.
8+
(see :ref:`hello_world_cpp` for further instructions).
119

12-
The Cycstub repo provides a number of critical tools for building your own
10+
The ``cycstub`` utility provides a number of critical tools for building your own
1311
module:
1412

1513
* ``install.py``: a basic installation script
@@ -69,7 +67,7 @@ The ``UseCyclus.cmake`` macro suite uses the following terms:
6967
``$CYCLUS_INSTALL_PREFIX/lib/cyclus/my_module_dir/``. The value of
7068
``$CYCLUS_INSTALL_PREFIX`` can be queried by
7169

72-
.. code-block:: bash
70+
.. code-block:: console
7371
7472
$ cyclus --install-path
7573
@@ -97,12 +95,44 @@ listing:
9795

9896
Examples
9997
--------
100-
98+
99+
Module Installation
100+
+++++++++++++++++++
101+
102+
The "Hello World" example only allows you to add multiple archetypes to the same
103+
module/library, using the `USE_CYCLUS` and `INSTALL_CYCLUS_MODULE` macros. If
104+
you call `cycstub` multiple times in the same folder, it requires you to specify
105+
the same path and library name for each new archetype. This approach reduces
106+
the number of libraries and executables that are added to a system, perhaps
107+
unnecessarily.
108+
109+
The resulting `src/CMakeLists.txt` file will includes lines like this:
110+
111+
.. literalinclude:: module-cmake
112+
113+
This will generate:
114+
115+
* a single shared object library in ``$CYCLUS_INSTALL_PREFIX/lib/cyclus/tutorial``
116+
named ``libTutorialLibrary.so`` (\*nix) or ``libTutorialLibrary.dylib`` (mac)
117+
118+
* a single unit test executable in ``$CYCLUS_INSTALL_PREFIX/bin`` named
119+
``TutorialLibrary_unit_tests``
120+
121+
where both incorporate the ``TutorialFacility``, ``TutorialInstitution``, and
122+
``TutorialRegion`` :term:`archetypes <archetype>`.
123+
124+
101125
Standalone Installation
102126
+++++++++++++++++++++++
103127

104-
Through the :ref:`hello_world` example, three standalone modules are installed
105-
using a ``src/CMakeLists.txt`` file that looks something like
128+
There may be cases where one prefers to have separate libraries and executables
129+
for each archetype. This is not currently supported by `cycstub` in a direct
130+
way. However, you can modify the above module approach by editing
131+
``src/CMakeLists.txt`` and replacing:
132+
133+
.. literalinclude:: module-cmake
134+
135+
with
106136

107137
.. literalinclude:: standalone-cmake
108138

@@ -123,29 +153,5 @@ and three unit test executables in ``$CYCLUS_INSTALL_PREFIX/bin``:
123153

124154
* ``TutorialRegion_unit_tests``
125155

126-
Module Installation
127-
+++++++++++++++++++
128-
129-
A valid criticism of the hello world standalone approach is that a lot of
130-
libraries and executables are generated for three modules that are grouped
131-
together. We can do better!
132-
133-
What if we wanted to install one module named ``helloworld``? Specifically, we
134-
would want:
135-
136-
* a single shared object library in ``$CYCLUS_INSTALL_PREFIX/lib/cyclus/tutorial``
137-
named ``libhelloworld.so`` (\*nix) or ``libhelloworld.dylib`` (mac)
138-
139-
* a single unit test executable in ``$CYCLUS_INSTALL_PREFIX/bin`` named
140-
``helloworld_unit_tests``
141-
142-
where both incorporate the ``TutorialFacility``, ``TutorialInstitution``, and
143-
``TutorialRegion`` :term:`archetypes <archetype>`.
144-
145-
Such behavior is pretty simple to achieve. We first must call ``UseCyclus`` on
146-
each of our source file roots to inform the build system of their presence and
147-
follow up with a call to ``INSTALL_CYCLUS_MODULE``:
148-
149-
.. literalinclude:: module-cmake
150156

151157

source/arche/errors.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ suppress all warnings and a very large number will print them all. For
132132
example, if the user wished to print the first 42 warnings of each kind they
133133
would call |cyclus| as follows:
134134

135-
.. code-block:: bash
135+
.. code-block:: console
136136
137137
$ cyclus --warn-limit 42 ...
138138
@@ -142,7 +142,7 @@ and throws the error. This is useful for ensuring that only stable code is
142142
executed or to help uncover what is causing a warning to be thrown. It takes
143143
no arguments:
144144

145-
.. code-block:: bash
145+
.. code-block:: console
146146
147147
$ cyclus --warn-as-error ...
148148

source/arche/hello_world_cpp.rst

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,37 @@ Hello, Cyclus! [C++]
44
====================
55
This pages walks you through a very simple hello world example using
66
|cyclus| agents. First make sure that you have the dependencies installed,
7-
namely |Cyclus|, CMake, and a recent version of Python (2.7 or 3.3+).
7+
namely |Cyclus|, CMake, and a recent version of Python (3.11+).
88

9-
First, you need to get the ``cycstub`` code. Cycstub is a skeleton code base
9+
First, you need to use ``cycstub`` to generate a skeleton code base
1010
that you can use to quick-start new |cyclus| module development projects.
11-
You can grab cycstub either by using git to
12-
`clone the repository <https://github.com/cyclus/cycstub.git>`_ or by
13-
`downloading the zip file <https://github.com/cyclus/cycstub/archive/develop.zip>`_.
14-
Let's put this code in a ``tutorial`` directory and go into it.
11+
``cycstub`` is installed with the main ``cyclus`` kernel and should be
12+
available wherever ``cyclus`` is available.
1513

16-
**Getting cycstub via git:**
14+
To use ``cycstub`` to generate the skeleton for a new Facility archetype named ``TutorialFacility`` in
15+
a module named ``TutorialLibrary`` you can issue the following command:
1716

18-
.. code-block:: bash
17+
.. code-block:: console
1918
20-
$ git clone https://github.com/cyclus/cycstub.git tutorial
21-
$ cd tutorial
19+
$ cycstub --type facility tutorial:TutorialLibrary:TutorialFacility
2220
23-
**Getting cycstub via zip:**
21+
This will populate the ``tutorial`` directory with a number of files and subdirectories
22+
that should already be complete for building a new archetype. Without any changes, this archetype
23+
will not do anything, but will be a valid archetype for use in a simulation.
2424

25-
.. code-block:: bash
25+
You can add additional agents to this module by calling `cycstub` multiple times:
2626

27-
$ curl -L https://api.github.com/repos/cyclus/cycstub/zipball > tutorial.zip
28-
$ unzip tutorial.zip
29-
$ mv cyclus-cycstub-* tutorial
30-
$ cd tutorial
27+
.. code-block:: console
3128
32-
------------
33-
34-
Since cycstub is a template project everything is named ``stub``. We need to
35-
change this to reflect the name we want our new project to be called -
36-
``tutorial`` here. Cycstub comes with a renaming tool to do just this! From
37-
the command line, run Python in the following way:
38-
39-
.. code-block:: bash
40-
41-
tutorial $ python rename.py tutorial
29+
$ cycstub --type inst tutorial:TutorialLibrary:TutorialInstitution
30+
$ cycstub --type region tutorial:TutorialLibrary:TutorialRegion
4231
4332
------------
4433

4534
Let's now change the behavior of the TutorialFacility's ``Tick()`` &
4635
``Tock()`` member functions to print "Hello" and "World" respectively. To do
4736
this, please open up the :file:`src/tutorial_facility.cc` file in your
48-
favorite text editor (vim, emacs, gedit, `notepad++ <http://exofrills.org>`_).
37+
favorite text editor (e.g., vim, emacs, gedit, `VS Code <https://code.visualstudio.com/>`_).
4938
Change the original functions to look like:
5039

5140
**Original Tick() and Tock() in src/tutorial_facility.cc:**
@@ -71,19 +60,19 @@ install the ``tutorial`` project. This done with the install.py script.
7160
The install script puts the project into your cyclus userspace,
7261
``${HOME}/.local/lib/cyclus``.
7362

74-
.. code-block:: bash
63+
.. code-block:: console
7564
76-
tutorial $ python install.py
65+
$ python3 install.py
7766
7867
------------
7968

8069
Let's run |cyclus| with the TutorialFacility! In the input directory there is
81-
an :file:`example.xml`. Running |cyclus| on this file with the command
82-
``cyclus input/example.xml`` should produce the following output.
70+
an :file:`example_tutorial_facility.xml`. Running |cyclus| on this file with the command
71+
``cyclus example_tutorial_facility.xml`` should produce the following output.
8372

84-
.. code-block:: bash
73+
.. code-block:: console
8574
86-
tutorial $ cyclus input/example.xml
75+
$ cyclus example_tutorial_facility.xml
8776
:
8877
.CL:CC CC _Q _Q _Q_Q _Q _Q _Q
8978
CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)

source/arche/hello_world_py.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ an :file:`example.xml`. First modify it to point to the archetype we just wrote.
7171
Running |cyclus| on this file with the command
7272
``cyclus input/example.xml`` should produce the following output.
7373

74-
.. code-block:: bash
74+
.. code-block:: console
7575
76-
tutorial $ cyclus input/example.xml
76+
$ cyclus input/example.xml
7777
:
7878
.CL:CC CC _Q _Q _Q_Q _Q _Q _Q
7979
CC;CCCCCCCC:C; /_\) /_\)/_/\\) /_\) /_\) /_\)

source/arche/logger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Logging
44
=======================
55

6-
.. code-block:: bash
6+
.. code-block:: console
77
88
LOG(LogLevel level, std::string prefix)
99

source/arche/module-cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USE_CYCLUS("helloworld" "tutorial_facility")
2-
USE_CYCLUS("helloworld" "tutorial_inst")
3-
USE_CYCLUS("helloworld" "tutorial_region")
4-
INSTALL_CYCLUS_MODULE("helloworld" "tutorial")
1+
USE_CYCLUS("TutorialLibrary" "tutorial_facility")
2+
USE_CYCLUS("TutorialLibrary" "tutorial_inst")
3+
USE_CYCLUS("TutorialLibrary" "tutorial_region")
4+
INSTALL_CYCLUS_MODULE("TutorialLibrary" "")

source/arche/standalone-cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
INSTALL_CYCLUS_STANDALONE("TutorialFacility" "tutorial_facility" "tutorial")
2-
INSTALL_CYCLUS_STANDALONE("TutorialInst" "tutorial_inst" "tutorial")
3-
INSTALL_CYCLUS_STANDALONE("TutorialRegion" "tutorial_region" "tutorial")
1+
INSTALL_CYCLUS_STANDALONE("TutorialFacility" "tutorial_facility" "" )
2+
INSTALL_CYCLUS_STANDALONE("TutorialInstitution" "tutorial_inst" "")
3+
INSTALL_CYCLUS_STANDALONE("TutorialRegion" "tutorial_region" "")

source/arche/testing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ haven't already, now is a good time to add the ``$CYCLUS_INSTALL_PATH`` to your
174174
``~/.local``). Next, from your top level directory (where your ``install.py``
175175
file is), run:
176176

177-
.. code-block:: bash
177+
.. code-block:: console
178178
179179
$ ./install.py
180180
$ TickTracker_unit_tests
@@ -322,7 +322,7 @@ This will prevent exceptions from being caught resulting in a core-dump. You
322322
can then use a debugger (e.g. gdb or lldb) to run the failing simulation and
323323
investigate the source of the crash in more detail. Something like this:
324324

325-
.. code-block:: bash
325+
.. code-block:: console
326326
327327
$ CYCLUS_NO_CATCH=1 gdb --args cyclus my-failing-sim.xml
328328
@@ -339,7 +339,7 @@ with respect to resource exchange. To turn on this debugging, simply run
339339
cyclus with the environment variable ``CYCLUS_DEBUG_DRE`` set to any non-empty
340340
value:
341341

342-
.. code-block:: bash
342+
.. code-block:: console
343343
344344
$ CYCLUS_DEBUG_DRE=1 cyclus my-sim.xml
345345

source/arche/tour_cpp.rst

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ A Tour of Cycstub
22
=================
33

44
Since |Cyclus| version 1.3.1 the Cycstub CLI is included in a standard |Cyclus| installation.
5-
If you have an older version of |Cyclus| please refer to the `Cycstub repository <https://github.com/cyclus/cycstub>`_
6-
for installation instructions.
5+
76
This section will walk through the source files of the stub :term:`archetypes
8-
<archetype>` in Cycstub. Cycstub provides
9-
three stub archetypes:
7+
<archetype>` generated when a user invokes the ``cycstub`` utility. ``Cycstub``
8+
can generate stubs for each of the agent types. The standard usage to generate the
9+
stubs for a Facility, Institution or Region, respectively, is:
10+
11+
.. code-block:: console
1012
11-
* ``StubFacility``
12-
* ``StubInstitution``
13-
* ``StubRegion``
13+
cycstub --type facility :stublibrary:StubFacility
14+
cycstub --type institution :stublibrary:StubInstitution
15+
cycstub --type region :stublibrary:StubRegion
1416
1517
We will walk through ``StubFacility``\ 's source specifically because its the
1618
most complicated of the three.
@@ -34,26 +36,32 @@ which includes most :term:`cyclus kernel` headers as a convenience for new
3436
include the specific kernel headers you need if you require a smaller
3537
executable.
3638

37-
Moving on in the header file we come to the class declaration
39+
Moving on in the header file we come to the class declaration inside the namespace
40+
of this specific module library, `stublibrary`, with standard Doxygen documentation
41+
strings.
3842

3943
.. code-block:: cpp
4044
45+
namespace stublibrary {
46+
47+
/// @class StubFacility
48+
/// ...
49+
4150
class StubFacility : public cyclus::Facility {
4251
4352
which simply states that the ``StubFacility`` inherits from ``cyclus::Facility``.
4453

45-
We then come to the constructor declaration
54+
We then come to the constructor declaration in the header file
4655

4756
.. code-block:: cpp
4857
4958
explicit StubFacility(cyclus::Context* ctx);
5059
51-
and implementation
60+
and definition in the implementation file
5261

5362
.. code-block:: cpp
5463
55-
StubFacility::StubFacility(cyclus::Context* ctx)
56-
: cyclus::Facility(ctx) {};
64+
StubFacility::StubFacility(cyclus::Context* ctx) : cyclus::Facility(ctx) {};
5765
5866
The constructor takes a single ``cyclus::Context`` argument. The :term:`context`
5967
is the mechanism by which :term:`agents <agent>` can query and otherwise

0 commit comments

Comments
 (0)