3DSlicer开发之路——Extensions(九)

BuildTestPackageDistributeExtensions

这一节用来解释怎样将你的Extensions进行Build,Test,Package和Distribute。同时解释MIDAS账户(extension server是基于它的)和其API key的用处

一、Step-by-step: How to create, publish, distribute and maintain an extension ?(一步一步来实现)

  • Scan through the user and developer extension FAQs(首先你要先浏览一下用户和开发者的关于extension 的FAQs,实际上user extension FAQs是developer extension FAQs的一部分,浏览developer extension FAQs就行了)
  • Inform a community about your plans on the Slicer forum to get information about potential parallel efforts (other developers may already work on a similar idea and you could join or build on each other's work), past efforts (related tools might have been available in earlier Slicer versions or in other software that you may reuse), and get early feedback from prospective users. You may also seek advice on the name of your extension and how to organize features into modules. All these can save you a lot of time in the long term.(先在Slicer forum上发表你关于自己extension的想法,看看有没有跟你做类似工作的人,或者你的extension的思想别人已经做过,你可以用别人开发好的工具,另外你也可以获取到很多关于你extension设计的建议)
  • Optional (required if developing loadable or CLI module types): Build Slicer application in Release. Not needed if you only develop Python modules.(如果你想要开发loadable或者CLI类型的模块的话,你需要自行对slicer从源码进行编译,并且编译版本得是Release版,因为你开发的模块需要用到很多Release版的库;对于Python 类型的模块,直接在slicer的二进制形式的发行版上开发就行了。参见Tutorials for software developers
  • Use the Extension Wizard module in Slicer to create an extension that will contain your module(s). Learn more about ExtensionWizard capabilities here(利用现有的模板创建extension ,可以有命令行的方式和GUI的方式,Extension Wizard的功能是很强大的,后面讲). To learn about extension description file format see here(前面讲过)
  • Save source code of your extension to a publicly available repository. It is recommended to start the repository name with "Slicer" (to make Slicer extensions easier to identify) followed by your extension name (for example, "Sequences" extension is stored in "SlicerSequences" repository). However, this is not a mandatory requirement. If you have a compelling reason not to use Slicer prefix, please make a note while making the pull request.(命名规则前面讲过)
  1. GitHub is recommended (due to large user community, free public project hosting): join Github and setup Git
  2. Extension Wizard command-line interface can upload source code of your extension to GitHub:
$ bin/slicerExtensionWizard --publish ~/Slicer-MyExtension/
  • Implement your extension. Hack, hack, hack :).(自行编程实现你的extension 的各种功能)Make sure to commit often using meaningful commit message.
  • Create documentation page for your extension(要创建一个documentation page)

  1.        It is recommended to put documentation in a README.md file in your repository use the Slicer wiki: Create a documentation page for your extension.(有模板套就行)

  • Optional (only needed, if you want to upload test data to MIDAS or troubleshoot extension upload problems)(这就是你前面创建MIDAS账户的原因): Create an account on the extension server and obtain an API Key. You will then use your midas login and api key to substitute <YOUR-MIDAS-LOGIN> and <YOUR-MIDAS-APIKEY> in the examples. Go to NA-MIC community and click on Join community</p></li>
  • Assuming the source code of your extension is located in folder MyExtension, you could upload your extension doing:

     @Linux or MacOSX (Makefile):

$ mkdir MyExtension-build
$ cd MyExtension-build
$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DMIDAS_PACKAGE_EMAIL:STRING=<YOUR-MIDAS-LOGIN> -DMIDAS_PACKAGE_API_KEY:STRING=<YOUR-MIDAS-APIKEY> -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build ../MyExtension
$ make ExperimentalUpload

     @Windows (Visual Studio)

  1. Start CMake, select source and build directory

  2. Add Slicer_DIR, MIDAS_PACKAGE_EMAIL and MIDAS_PACKAGE_API_KEY entries to the cache

                    

     3. Click on Configure, select Generator, then click on Generate button.

     4. Open MyExtension.sln (1), select Release configuration (2), select ExperimentalUpload (3) and Build (4).

                      

      5. To avoid typing the API email and key, you can set the environment variables MIDAS_PACKAGE_EMAIL and MIDAS_PACKAGE_API_KEY. More details here(下面的cache API credentials)

  • Optional (required for loadable and CLI modules): Build your extension(对上述两种类型的模块你需要编译它们)
  • Test your extension:
  1. If you have built your extension then build the PACKAGE target to create a package file that you can install from the Extension Manager by clicking the small tool icon in the top-right corner.(应该在release模式下进行build和PACKAGE,怎样用Extension Manager手动加载extension package前面讲过)
  2. If you have not built your extension then set up your extension manually: Build your extension(怎样Build your extension,后面讲
  • If you consider your extension is ready for distribution (你是否想要对Slicer贡献你的extension 并公开源码,不想的话,这一步就不要了), contribute it to the ExtensionsIndex:
  1. Fork ExtensionIndex repository on GitHub by clicking Fork button on https://github.com/Slicer/ExtensionsIndex page

  2. Add your .s4ext file to your forked repository: it can be done using a git client or simply by clicking Upload files button
  3. Create a pull request: by clicking Create pull request button
  4. Note: the Extension Wizard can automate this by the following command:

     

$ bin/slicerExtensionWizard --contribute ~/Slicer-MyExtension/

(强大的slicerExtensionWizard,但是自己试的话是有问题的,包括上面的--publish功能,不知道是不是与自己编译的slicerdebug模式有关,当初编译的debug版本的slicer,等我编译一波release版本再说

二、Contribution Checklist

Wait for your pull request to be merged. Respond to comments posted on the pull request. The following checklist will automatically be associated with your pull request.(接下来你就要等待你的pull request被slicer的管理者merged,你需要对你的pull request下的评论作出回应。并且 following checklist这个文件将会自动与你的pull request相关联。 following checklist这个文件就是ExtensionsIndex中的PULL_REQUEST_TEMPLATE.md文件,描述了你pull request的extension 的必要信息,让管理者和其它使用者明白你这个extension ,分为更新一个已存在extension pull request和添加一个新extensionpull request)

三、Continuous Integration

If you shared your extension by using the ExtensionWizard, make sure you know about the Slicer testing dashboard:(如果你用ExtensionWizard来分享你的extension,你需要了解Slicer testing dashboard )

http://slicer.cdash.org/index.php?project=Slicer4&display=project

The dashboard will attempt to check out the source code of your extension, build, test and package it on Linux, MacOSX and Windows platforms.(dashboard 将帮你在不同平台上检测你的源代码)

To find your extension, use the following link replacing Slicer-MyExtension with the name of your extension:

http://slicer.cdash.org/index.php?project=Slicer4&filtercount=1&showfilters=1&field1=buildname&compare1=63&value1=Slicer-MyExtension

For example, here is the link to check the status of the SlicerDMRI extension:

http://slicer.cdash.org/index.php?project=Slicer4&filtercount=1&showfilters=1&field1=buildname&compare1=63&value1=SlicerDMRI

If you see red in any of the columns for your extension, click on the hyperlinked number of errors to see the details.

Always check the dashboard after you first introduce your extension, or after you make any changes to the code!

 

来自 <https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/BuildTestPackageDistributeExtensions>

 

 

 

 

 

 

原文地址:https://www.cnblogs.com/oneDongHua/p/14264077.html