TrickLogo

HomeDocumentation HomeBuilding a Simulation → Trickified Project Libraries

Classic Trickify

This document details the revamped form of Trickify added in Trick-25. For the original documentation, see Trickified Project Libraries Classic

Overview

During a simulation build, Trick generates several rounds of files to support data recording, checkpointing, and Python access:

Due to the framework Trick creates, it is not feasible to build external libraries with Trick utilities enabled. The external libraries must either be rebuilt with each clean sim build, or pre-compiled and sacrifice Trick utilities.

This is where Trickification comes in. Trickfication is a utility that allows external libraries to be compiled with Trick utilities included. This convenience feature is intended to save time on unnecessary rebuilding of external libraries that are not going be changed as part of normal workflow.

Who's Responsible?

Support of Trickification is the project owner's responsibility. While it is possible for anyone to Trickify any set of files, you really want the project to maintain the files we're going to talk about. This will ensure that's it done correctly, in one place, and stays synchronized with the project.

Trickifying Your Project

Trickifying your project requires only a few steps.

  1. Identify the files you want included in your library. You do not necessarily need to manually create a list of files. Trick-ify just needs to know what directories to look in.
  2. Run the Trickify script.
  3. Include S_overrides_trickify.mk in your sims trickify.mk. S_overrides_trickify.mk is generated by Trickify. trickify.mk is a list of all Trickified libraries you want to include in your build. trickify.mk must be created by you, in the same directory as your S_define. Note, you should use -include in your trickify.mk, otherwise it can interfere with trick-CP.

Checking In Your Trickified Library

If you would like to check in your Trickification to a repository, you only need to push two files. First is the trickify.mk file you created in your sim directory. The second is the core makefile in the Trickified build directory. The core makefile contains a command to rebuild the library, so no other files from the build directory are needed.

Note: Before you check in your makefile, make sure the Trickify call only contains relative paths.

Trick-ify Script

The core script behind Trickification is the trick-ify script (which lives at $(TRICK_HOME)/bin/). While this script contains everything you need to Trickify, it can be tedious to work with directly. We advise you check out the GUI section for a friendlier way to construct your Trickify commands.

IMPORTANT: If you are not using absolute paths, all paths other than the build directory must be relative to the Trickified build directory! The build directory must be relative to where you invoke Trickify!

Trick-ify Input Arguments

Trick-ify Build Arguments

Trick-ify Advanced Make Arguments

These are additional build arguments that are not intended to be used by the vast majority of users. These options allow the user to modify some internal Trickify behaviors. Unless you are trying to do something hacky, you can safely skip these options.

Trick-ify Other Arguments

Trick-ify GUI

The Trickify GUI is a covenience feature for generating Trickify commands. The GUI is not required to Trickify your project, nor does it provide any additional features compared to the core script. However, the GUI can simplify the process of formatting your script arguments.

The GUI allows for it's state to be exported/imported as a config file, with the options under the File menu item.

Trickify GUI - Overview

Trickify GUI Default S_define Tab The Trickify GUI consists of several tabs of text fields, several buttons for discrete options, and two buttons for generating the Trickify command.

Discrete Options

Buttons

Trickify GUI - S_define Tab

Trickify GUI Default S_define Tab This tab is for building a library with respect to a particular sim. By Trickifying with an S_define, Trickify is able to automatically generate the list of files you need from a particular repository. On top of simplifying the Trickifcation process, this method ensures only files your sim uses are included in the library, reducing the the library size and build time.

For example, say you have a sim that makes use of JEOD. If you only wish to include JEOD files your sim actually uses, instead of the full JEOD library, you would use this method.

Limitation: If you have multiple sims that make use of the same repository, this method would require you to Trickify each sim separately. If you want to create a generic library for a repository, that includes all of its files, see the Input tab below.

Trickify GUI - Inputs Tab

Trickify GUI Default Inputs Tab This tab is for generic input options that are indifferent to the S_define options.

Trickify GUI - Outputs Tab

Trickify GUI Default Outputs Tab This tab details where the library should be built

Trickify GUI - Advanced Tab

Trickify GUI Default Advanced Tab This tab is for advanced options, that 99% of users won't care about. These are all optional, and only exists for compatiability purposes with libraries that don't like being Trickified.

Additional Features and Options

Once you have linked in an S_overrides_trickify.mk into your sim, you gain access to several additional benefits and customization options.

Make Targets

Trickify provides additional make targets to make managing your library easier. These can be invoked from your sim directory, just like other sim make options.

NOTE: Each of these options (except rebuild) is invoked along side the standard Trick make clean/spotless/apocalypse options.

Automatic Rebuilding

When running trick-CP, by default your Trickified libraries will be rebuilt if they are out of date. To disable this check, set TRICKIFY_AUTO_REBUILD to 0 in either your S_overrides.mk or trickify.mk.

Trickify uses the flag TRICKIFY_LD_FLAGS to provide the list of Trickified libraries to link during the sim build. By default, TRICKIFY_LD_FLAGS are linked in prior to TRICK_LD_FLAGS. If your sim requires the Trickified libraries to be linked in another order, you can set the flag MANUAL_TRICKIFY_LD to 1 in either your S_overrides.mk or trickify.mk. This flag disables TRICKIFY_LD_FLAGS, allowing you to include your Trickified libraries in your TRICK_LD_FLAGS list in the needed order.

Trickify Directory

A Trickified build directory contains a lot more than just a library. There are a handful of supporting makefiles, as well as many build artifacts that can be useful in debugging.

Core files

Supporting Makefiles

Build Metadata

Build Artifacts

Limitations

As of writing this, Trickify is still a very new feature. It has only been tested on a handful of real sims, so compatability issues are expected. If your sim has problems running with Trickify, please write an issue on the Trick Github page, so that this feature can be made more robust.

Trickify currently has a handful of known limitations.

Demo

The Trick repository contains an example of a Trickified sim 'trick/trick_sims/SIM_trickified_demo'. This sim is based on another Trick sim, the Ball sim. You will notice two additions compared to the normal Ball sim. First is a trickify.mk file under the sim directory, which links the Trickified library to the sim. The second addition is a "trickified" directory, which contains the core makefile for the Trickified library. These are the only two files that should be added to a Trickified sim's repository.

Note: You don't have to put your Trickified library in a dir named "trickified", that's just the name we used.

The demo Trickified library was initially built with the following command. Most sims will likely use something similar.

'trick-ify --trick_home "../../../" --trickify_make "../../../share/trick/makefiles/" --include "../models/Core_Model ../models/Support_Code" --s_define "../S_define" --s_define_filter "../models/Support_Code" --build "/home/<user>/trick/trick_sims/SIM_trickified_demo/trickified" --s_overrides "../S_overrides.mk" -n "Ball_Lib" -b "a"'

To build the demo sim, first go to the "trickified" directory and make. Afterwards, run trick-CP like any other sim.

That's all there is to it. All Trickified libraries should operate exactly the same as the demo once configured. The only difference would be setting up the initial Trickify build command.