当前位置:网站首页>Get the openharmony source code: get it from the deveco marketplace (1)

Get the openharmony source code: get it from the deveco marketplace (1)

2022-06-21 20:52:00 51CTO

introduction

OpenHarmony There are three ways to obtain the source code : from gitee、GitHub Based on git Code hosting platform for ; From Huawei DevEco Marketplace Website access ; Get... From the mirror site .

This article introduces how to use the DevEco Marketplace Website access OpenHarmony Source code , And in Ubuntu Create a Hongmeng project in the Hongmeng equipment development environment under the system .

One 、DevEco Marketplace brief introduction

In Huawei  DevEco Marketplace In this website , There are many open source Hongmeng distributions . Most of these open source distributions are for a specific device ( Such as : A development board ), Yes OpenHarmony The full amount of code has been trimmed . such as , A device has limited hardware resources , Can't run OpenHarmony Some functional components in , Then these components will be cut out in the distribution ; In other words, there is no need for a certain function in the application scenario of this device , The corresponding functional components will also be cut in the distribution .

We are developing Hongmeng equipment , You can go to this website to find out if there is a suitable distribution . This site also supports adding or removing some functional components from these distributions , Customize a release . You can also submit your own distribution to this website for open source use .

 DevEco Marketplace The front page of this website is shown in the figure below . For Hongmeng equipment development , Here's the important thing Device components and file . Developers can find various open source distributions and component packages in the device components ; The documentation details how to get the distribution 、 The component package , How to customize a distribution , And how to contribute your own distributions and component packages .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng

below , With Hi3861 Take a development board of the processor as an example , Explain Huawei's DevEco Marketplace Website access OpenHarmony Source code and the process of creating Hongmeng project .

Be careful : from DevEco Marketplace The website needs to register a Huawei account to download and contribute code .

Two 、 Get Hongmeng distribution

Reference resources : https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md

2.1 install Node.js and HPM

To obtain the source code of the distribution, you need to use hpm Command line tools , and hpm Use Node.js Medium npm Installed , So install it first Node.js and hpm. For installation method, refer to part II, section 2.6~2.7 section :

《 Set up Hongmeng equipment development environment :Ubuntu20.04+DevEco Device Tool Release 3.0》   link

If you have built the Hongmeng device development environment according to the above article , Skip this step .

2.2 Get the profile of the distribution

1、 Get into  DevEco Marketplace After the first page , Log in with your account first ( If you have not registered a Huawei account , Please register first ).

2、 open Device components page , choice Open source distribution , Use the... On the left side of the page filter Help find the required open source distribution , As shown in the figure below :

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _02

3、 Click the selected open source distribution , Such as : In the picture above WLAN Connection products , The details page of the latest version of the open source distribution will be opened , As shown in the figure below :

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _03

4、 On the right side of the details page , You can see the version number and release time , single click Direct download This version of the configuration file can be downloaded ( Don't click Download for now ); On the left side of the details page , You can see the description of the current version , single click edition , View all versions of this release , As shown in the figure below :

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _04

Click on any version , You can enter the details page of this version . You can also click the download icon on the far right of the version , Download the configuration file of this version directly .

Make a note of : 2022-06-18,3.1.0~3.1.2 There is a problem with both versions of the configuration file , Unable to successfully download the source code of this distribution . After submitting the problem to Huawei , Huawei acknowledges the existence of bug, I hope when you read this article , Has been repaired .

I've been using it before 2.2.0 edition , At least I don't have any problems right now ;3.0.1 The version of the configuration file has no problem in obtaining the source code , In this paper , Just use this version .

5、 single click 3.0.1 The download icon on the right side of the version , Download to get a .tgz Compressed files , I suggest you change the name of this compressed file , Change to the name of the Hongmeng project you want to create , for example :hispark_pegasus_301.tgz. I put this compressed file in ~/Documents/DevEco/Projects Under the table of contents .

2.3 Download the distribution source code

1、 Unzip the distribution profile zip hispark_pegasus_301.tgz.

Enter the folder where the compressed package is located :~/Documents/DevEco/Projects, Right click in the compressed file , choice Extract Here , You will get a file named hispark_pegasus_301 Folder .

2、 Enter folder hispark_pegasus_301, Right click an empty space in the folder , choose “Open in Terminal”, Open a terminal , Execute command in terminal :hpm install, That is, start to download the code of the distribution and the related tool chain ( Make sure you can connect to the Internet ).

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _05

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _06

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _07

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _08

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _09

After success , Hongmeng project folder hispark_pegasus_301 The file in is shown in the following figure :

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _10

If you're using 3.1.0~3.1.2 Version of the configuration file , The error shown in the following figure may appear ( At least 2022-06-18 The test is like this ):

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _11

3、 ... and 、 Create a Hongmeng project

Please first build the Hongmeng development environment according to the following article :

《 Set up Hongmeng equipment development environment :Ubuntu20.04+DevEco Device Tool Release 3.0》   link

DevEco Device Tool edition : devicetool-linux-tool-3.0.0.401.zip

1、 open DevEco Device Tool, stay “Home” Click on the page “Import Project”.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _12

2、 Select the Hongmeng project folder in the pop-up window hispark_pegasus_301, Then click... In the lower right corner Import .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _13

3、 In the pop-up window, click Import .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _14

4、 choice Import from OpenHarmony Source .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _15

5、 Select the development board according to the following figure 、 Processor and other information , And then click Open .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _16

6、 Check the pop-up window , And then click Yes.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _17

7、 The open Hongmeng project is shown in the following figure .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _18

8、 Compile the project as shown in the following figure .

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _19

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _20

Postscript

We can actually be in DevEco Device Tool in , Complete the second part of this article in one stop 、 The work done in the three parts , However, it seems that you can only download the latest version of the distribution to create the Hongmeng project . So wait for Huawei to repair the above mentioned bug after , Please read my other article :

《 obtain OpenHarmony Source code : from DevEco Marketplace obtain (2)》

Supplement notes

We can also do that Ubuntu In the end , On the command line , Complete the search of Hongmeng distribution in turn 、 Download and compile .

Create a project folder ,

1、 see DevEco Marketplace What are the Hongmeng development boards on this website

hpm search -t distribution

     
  • 1.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _21

Press n Turn to the next page , Press q sign out .

2、 Create a new project folder ( Such as :test), Then initialize

cd ~/Documents/DevEco/Projects
mkdir test
cd test
hpm init -t dist # initialization 

     
  • 1.
  • 2.
  • 3.
  • 4.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _22

3、 Under the project folder , Execute the following command , Download the open source distribution source code and tool chain .

hpm i @ohos/[email protected]

     
  • 1.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _23

4、 compile

There are two ways to compile from the command line :

(1) Mode one : Execute the following command in the project folder

hpm dist

     
  • 1.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _24

(2) Mode two : Execute the following commands in turn

hb set   # Set the project path and the product to compile 
hb build # Compile the project 

     
  • 1.
  • 2.

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _25

 obtain OpenHarmony Source code : from DevEco Marketplace obtain (1)_ Hongmeng _26

In this paper CSDN、 official account 、 Headlines and Zhihu are released simultaneously , Thank you for attention .

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211836364926.html