Just getting familiar with the package-id paradigm, and I'm confused a bit
over the fact that it's supposed to be globally unique, yet it's
automatically assigned as "local.project-name" when using ocpidev to set up
a new project.
Is there a way to set a new package-id after the project has been created
using the tools, or do I need to go into the .project.xml to manually set
it?
According to the documentation, it seems like the desired result is to have
something along the lines of <TLD>.<organization>.<project> as the
project-id.
I am using the up-to-date build2 branch.
Thanks,
Neil
Neil,
You are correct that the package-id is automatically assigned to "local.<project-name>" by ocpidev if you do not provide it with a package prefix at creation time. It is true that "local" is not a good name when hoping for globally unique identifiers, but it is hard for us to provide the user with a good globally unique prefix.
"ocpidev create project" accepts a few options which allow the user to set the package-id to whatever they choose at creation time. These options (listed in the help screen) are -N (package name which will replace the <project-name> in the package-id) and -F (package prefix which will replace "local" in your case).
So, we have <package-prefix>.<package-name>, where prefix defaults to "local" and name defaults to <project-name>.
After a project has been created, you cannot modify the package-id using "ocpidev". The only way as of now to modify the package-id of an existing project is through the Project.mk. If you plan to modify the project's package-id, you probably want to unregister it first:
$ cd <project>;
$ ocpidev unregister project
Now, edit the Project.mk, and set the following variables: PackagePrefix and/or PackagePrefix.
Then, reregister the project:
$ ocpidev register project
Note that the package-id is baked into generated files for workers, so you will need to clean the project and rebuild after modifying the package-id.
Also note that these variables also exist for libraries! So, you can modify the Library.mk for your "components" library (if you have a single flattened components library), or sub-library (if you have more than one) in a similar fashion! In this case, the default prefix is the full package-id of the project, and the default name is the directory name for the library (with components being an exception that defaults to <empty>). For libraries, it may be useful to set PackageName to something other than your simple directory name. Then workers/components in that library would have package-ids like my_unique_prefix.my_project.library_abc.component_123.
For more information, please see section 14.2 of the OpenCPI Component Development Guide.
I hope I have answered all of your questions!
Regards,
David
From: discuss discuss-bounces@lists.opencpi.org on behalf of Neil Schafer neil.schafer@nrl.navy.mil
Sent: Thursday, July 12, 2018 5:53:58 PM
To: discuss@lists.opencpi.org
Subject: [Discuss OpenCPI] Package ID
Just getting familiar with the package-id paradigm, and I'm confused a bit
over the fact that it's supposed to be globally unique, yet it's
automatically assigned as "local.project-name" when using ocpidev to set up
a new project.
Is there a way to set a new package-id after the project has been created
using the tools, or do I need to go into the .project.xml to manually set
it?
According to the documentation, it seems like the desired result is to have
something along the lines of <TLD>.<organization>.<project> as the
project-id.
I am using the up-to-date build2 branch.
Thanks,
Neil
The original concept, which predates ocpidev, is that you “start local”, and when decide you want to publish or share a project you assign a package id like java does to achieve global uniqueness.
As David said you need to clean if you change it.
We can make this a bit nicer when we migrate the Project.mk file to XML.
On Jul 12, 2018, at 17:53, Neil Schafer neil.schafer@nrl.navy.mil wrote:
Just getting familiar with the package-id paradigm, and I'm confused a bit
over the fact that it's supposed to be globally unique, yet it's
automatically assigned as "local.project-name" when using ocpidev to set up
a new project.
Is there a way to set a new package-id after the project has been created
using the tools, or do I need to go into the .project.xml to manually set
it?
According to the documentation, it seems like the desired result is to have
something along the lines of <TLD>.<organization>.<project> as the
project-id.
I am using the up-to-date build2 branch.
Thanks,
Neil
Thanks David. This is very thorough. For what it's worth, I did not see this
method discussed in section 14.2, nor in "ocpidev --help", although I now
see that there is help available for each of the ocpidev "verbs" as well,
which does cover this, and I will look to those in the future.
Thanks!
Neil
From: Banks, David david.banks@bia-boeing.com
Sent: Thursday, July 12, 2018 6:17 PM
To: Neil Schafer neil.schafer@nrl.navy.mil; discuss@lists.opencpi.org
Subject: Re: [Discuss OpenCPI] Package ID
Neil,
You are correct that the package-id is automatically assigned to
"local.<project-name>" by ocpidev if you do not provide it with a package
prefix at creation time. It is true that "local" is not a good name when
hoping for globally unique identifiers, but it is hard for us to provide the
user with a good globally unique prefix.
"ocpidev create project" accepts a few options which allow the user to set
the package-id to whatever they choose at creation time. These options
(listed in the help screen) are -N (package name which will replace the
<project-name> in the package-id) and -F (package prefix which will replace
"local" in your case).
So, we have <package-prefix>.<package-name>, where prefix defaults to
"local" and name defaults to <project-name>.
After a project has been created, you cannot modify the package-id using
"ocpidev". The only way as of now to modify the package-id of an existing
project is through the Project.mk. If you plan to modify the project's
package-id, you probably want to unregister it first:
$ cd <project>;
$ ocpidev unregister project
Now, edit the Project.mk, and set the following variables: PackagePrefix
and/or PackagePrefix.
Then, reregister the project:
$ ocpidev register project
Note that the package-id is baked into generated files for workers, so you
will need to clean the project and rebuild after modifying the package-id.
Also note that these variables also exist for libraries! So, you can modify
the Library.mk for your "components" library (if you have a single flattened
components library), or sub-library (if you have more than one) in a similar
fashion! In this case, the default prefix is the full package-id of the
project, and the default name is the directory name for the library (with
components being an exception that defaults to <empty>). For libraries, it
may be useful to set PackageName to something other than your simple
directory name. Then workers/components in that library would have
package-ids like my_unique_prefix.my_project.library_abc.component_123.
For more information, please see section 14.2 of the OpenCPI Component
Development Guide.
I hope I have answered all of your questions!
Regards,
David
From: discuss <discuss-bounces@lists.opencpi.org
mailto:discuss-bounces@lists.opencpi.org > on behalf of Neil Schafer
<neil.schafer@nrl.navy.mil mailto:neil.schafer@nrl.navy.mil >
Sent: Thursday, July 12, 2018 5:53:58 PM
To: discuss@lists.opencpi.org mailto:discuss@lists.opencpi.org
Subject: [Discuss OpenCPI] Package ID
Just getting familiar with the package-id paradigm, and I'm confused a bit
over the fact that it's supposed to be globally unique, yet it's
automatically assigned as "local.project-name" when using ocpidev to set up
a new project.
Is there a way to set a new package-id after the project has been created
using the tools, or do I need to go into the .project.xml to manually set
it?
According to the documentation, it seems like the desired result is to have
something along the lines of <TLD>.<organization>.<project> as the
project-id.
I am using the up-to-date build2 branch.
Thanks,
Neil