![]() |
![]()
| ![]() |
![]()
NAMEDir::Project - Project Environment determination SYNOPSIS# Perl use Dir::Project; Dir::Project::get_set_all(); # Makefiles include $(DIRPROJECT_PREFIX)/lib/project_dir.mk # Example script dispatching cd ~/project1 project_dir --project /path/to/project1 my_tool my_args.... # Executes project1/.../my_tool cd ~/project2 project_dir --project /path/to/project2 my_tool my_args.... # Executes project2/.../my_tool DESCRIPTIONDir::Project provides a way to locate a source-controlled directory (CVS, Subversion, Perforce, Git, etc) using only the current working directory (cd). This prevents users from having to set other environment variables when they switch between areas. Project_bin allows a single symlink to a user script to be placed in a global PATH. Project_bin then automatically finds that script inside the source controlled area. Different users, or different checkouts will execute the script in their areas. Thus, problems with version mismatch across executing tools are eliminated. ENVIRONMENT SETUPTo use project_bin, you should make the following settings in your .bashrc or equivalent group file: export DIRPROJECT_PREFIX=/prefix # Any global project prefix export PATH=$DIRPROJECT_PREFIX/bin:$PATH Then for each executable that lives in your source control area that you wish to dispatch to, you create a simlink: ln -s project_bin $DIRPROJECT_PREFIX/dir/my_tool or, instead, make my_tool a script to run project_bin as described in project_bin. More details in project_bin. USAGE IN SCRIPTSDir::Project may be used three different ways inside scripts. First, a script may be totally ignorant of Dir::Project. Simply by placing it in a directory that is part of DIRPROJECT_PATH, and creating a symlink from project_bin, it will be executed automatically based on a search starting at the current directory. Second, a script that is always executed by project_bin can get the root of the checkout by using $DIRPROJECT. Generally I cache the value of DIRPROJECT in a variable called simply $Project. BEGIN { $Project = $ENV{DIRPROJECT} or die "%Error: Can't determine DIRPROJECT: Call me with project_bin, stopped"; } .... my $path_to_file = "$Project/under/project/file/path..."; Third, a script may determine DIRPROJECT itself by using Dir::Project directly. This does not require project_bin to be used to call the program. use Dir::Project; BEGIN { Dir::Project::get_set_project(); $Project = $ENV{DIRPROJECT} or die "%Error: Can't determine PROJECT: Call this under a project, stopped"; } .... my $path_to_file = "$Project/under/project/file/path..."; USAGE IN MAKEFILESDir::Project may be called from inside a Makefile. The include will set the DIRPROJECT variable that can then be used to replace absolute paths inside the makefile. include $(DIRPROJECT_PREFIX)/lib/project_dir.mk # That include will set $(DIRPROJECT) which you can then use # to find files underneath the repository checkout. .... PATHS = $(DIRPROJECT)/path/under/repo Or, if you only need the DIRPROJECT variable, you can more simply: DIRPROJECT := $(shell dir_project --project) USAGE IN EMACS / VERILOG-MODEDir::Project may be used with the AUTOs of Verilog-Mode for Emacs. Install the contrib/dir-project.el file as described at the top of that file. Restart Emacs. Now in your source tree create an input.vc file similar to the following: -v project/path/to/rtl The various Verilog module files would then end in a reference to the file you just created: // Local Variables: // verilog-library-flags:("-f ../../../../input.vc") // End: When AUTOs are expanded the input.vc file will be read. The dir-project.el hook will change the project/ links to an absolute file and that will allow finding any submodules. An alternative technique is to use $DIRPROJECT/path/to/rtl in the input.vc and setting the DIRPROJECT environment variable. However several EDA tools do not support environment variable expansion in .vc files, thus the above project/ technique. METHODS
ENVIRONMENT
DISTRIBUTIONDir-Project is part of the <http://www.veripool.org/> free EDA software tool suite. The latest version is available from CPAN and from <http://www.veripool.org/>. Copyright 2001-2017 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. AUTHORSWilson Snyder <wsnyder@wsnyder.org> SEE ALSOproject_bin, project_dir
|