github.com/true-sqn/fabric@v2.1.1+incompatible/docs/source/dev-setup/build.rst (about)

     1  Building Hyperledger Fabric
     2  ---------------------------
     3  
     4  The following instructions assume that you have already set up your
     5  :doc:`development environment <devenv>`.
     6  
     7  To build Hyperledger Fabric:
     8  
     9  ::
    10  
    11      cd $GOPATH/src/github.com/hyperledger/fabric
    12      make dist-clean all
    13  
    14  Building the documentation
    15  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    16  
    17  If you are contributing to the documentation, you can build the Fabric
    18  documentation on your local machine. This allows you to check the formatting
    19  of your changes using your web browser before you open a pull request.
    20  
    21  You need to download the following prerequisites before you can build the
    22  documentation:
    23  
    24  - `Python 3.7 <https://wiki.python.org/moin/BeginnersGuide/Download>`__
    25  - `Pipenv <https://pipenv.readthedocs.io/en/latest/#install-pipenv-today>`__
    26  
    27  After you make your updates to the documentation source files, you can generate
    28  a build that includes your changes by running the following commands:
    29  
    30  ::
    31  
    32      cd fabric/docs
    33      pipenv install
    34      pipenv shell
    35      make html
    36  
    37  This will generate all the html files in the ``docs/build/html`` folder. You can
    38  open any file to start browsing the updated documentation using your browser. If you
    39  want to make additional edits to the documentation, you can rerun ``make html``
    40  to incorporate the changes.
    41  
    42  Running the unit tests
    43  ~~~~~~~~~~~~~~~~~~~~~~
    44  
    45  Before running the unit tests, a PKCS #11 cryptographic token implementation
    46  must be installed and configured. The PKCS #11 API is used by the bccsp
    47  component of Fabric to interact with devices, such as hardware security modules
    48  (HSMs), that store cryptographic information and perform cryptographic
    49  computations. For test environments, SoftHSM can be used to satisfy this
    50  requirement.
    51  
    52  SoftHSM can be installed with the following commands:
    53  
    54  ::
    55  
    56      sudo apt install libsofthsm2 # Ubuntu
    57      sudo yum install softhsm     # CentOS
    58      brew install softhsm         # macOS
    59  
    60  Once SoftHSM is installed, additional configuration may be required. For
    61  example, the default configuration file stores token data in a system directory
    62  that unprivileged users are unable to write to.
    63  
    64  Configuration typically involves copying ``/etc/softhsm2.conf`` to
    65  ``$HOME/.config/softhsm2/softhsm2.conf`` and changing ``directories.tokendir``
    66  to an appropriate location. Please see the man page for ``softhsm2.conf`` for
    67  details.
    68  
    69  After SoftHSM has been configured, the following command can be used to
    70  initialize the required token:
    71  
    72  ::
    73  
    74      softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432
    75  
    76  If the test cannot find libsofthsm2.so in your environment, specify its path,
    77  the PIN and the label of the token through environment variables. For example,
    78  on macOS:
    79  
    80  ::
    81  
    82      export PKCS11_LIB="/usr/local/Cellar/softhsm/2.5.0/lib/softhsm/libsofthsm2.so"
    83      export PKCS11_PIN=98765432
    84      export PKCS11_LABEL="ForFabric"
    85  
    86  Use the following sequence to run all unit tests:
    87  
    88  ::
    89  
    90      cd $GOPATH/src/github.com/hyperledger/fabric
    91      make unit-test
    92  
    93  To run a subset of tests, set the TEST_PKGS environment variable.
    94  Specify a list of packages (separated by space), for example:
    95  
    96  ::
    97  
    98      export TEST_PKGS="github.com/hyperledger/fabric/core/ledger/..."
    99      make unit-test
   100  
   101  To run a specific test use the ``-run RE`` flag where RE is a regular
   102  expression that matches the test case name. To run tests with verbose
   103  output use the ``-v`` flag. For example, to run the ``TestGetFoo`` test
   104  case, change to the directory containing the ``foo_test.go`` and
   105  call/execute
   106  
   107  ::
   108  
   109      go test -v -run=TestGetFoo
   110  
   111  
   112  Running Node.js Client SDK Unit Tests
   113  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   114  
   115  You must also run the Node.js unit tests to ensure that the Node.js
   116  client SDK is not broken by your changes. To run the Node.js unit tests,
   117  follow the instructions
   118  `here <https://github.com/hyperledger/fabric-sdk-node/blob/master/README.md>`__.
   119  
   120  Configuration
   121  -------------
   122  
   123  Configuration utilizes the `viper <https://github.com/spf13/viper>`__
   124  and `cobra <https://github.com/spf13/cobra>`__ libraries.
   125  
   126  There is a **core.yaml** file that contains the configuration for the
   127  peer process. Many of the configuration settings can be overridden on
   128  the command line by setting ENV variables that match the configuration
   129  setting, but by prefixing with *'CORE\_'*. For example, setting
   130  `peer.networkId` can be accomplished with:
   131  
   132  ::
   133  
   134      CORE_PEER_NETWORKID=custom-network-id peer
   135  
   136  .. Licensed under Creative Commons Attribution 4.0 International License
   137     https://creativecommons.org/licenses/by/4.0/