Method for rapid porting of electron software

By adding and modifying code in the Electron source code to support Loongson and Shenwei architectures, the problem of Electron software being unable to be ported to domestic CPU platforms was solved, enabling rapid porting and saving development time.

CN116204227BActive Publication Date: 2026-02-03KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310072052.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-19
Publication Date
2026-02-03
Estimated Expiration
2043-01-19

AI Technical Summary

Technical Problem

Electron software does not support domestic CPU platforms such as Loongson and Shenwei architectures, which means that the IDE requirements on domestic CPU platforms cannot be met.

Method used

Added and modified relevant code in the Electron source code to support Loongson and Shenwei architectures, including adding code for the target CPU architecture to the v8 directory, third-party software and main directory, and modifying the ffmpeg compilation method.

Benefits of technology

It enabled the rapid porting of Electron software to domestic CPU platforms, saving development time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116204227B_ABST
    Figure CN116204227B_ABST
Patent Text Reader

Abstract

The method for quickly transplanting electron software comprises the following steps: adding the code of the target architecture in the v8 directory of the electron source code; modifying the v8 test program to increase the test program of the target architecture; searching the existing CPU architecture related code in the third party software of the electron source code, and increasing the corresponding code of the target CPU architecture in the source code according to the specification of the target CPU architecture; modifying the compiling mode of the third party software ffmpeg of the electron source code; searching the existing CPU architecture related code in the main directory of the electron source code, and increasing the corresponding code of the target CPU architecture in the source code according to the specification of the target CPU architecture; and executing the electron building command. The present application can save the development time of the domestic CPU platform electron transplantation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of operating system function implementation compatibility technology, and more specifically to a method for rapidly porting Electron software. Background Technology

[0002] Electron is an open-source framework developed by GitHub. It enables the development of cross-platform desktop GUI applications using Node.js (as the backend) and Chromium's rendering engine (as the frontend). Electron is now used by numerous open-source web applications for both frontend and backend development, combining Chromium and Node.js with HTML, CSS, and JavaScript to build cross-platform desktop applications for Mac, Windows, and Linux. Notable projects include GitHub's Atom and Microsoft's Visual Studio Code. Electron was designed from the outset to fully integrate today's best web technologies, serving as a cross-platform "integration framework" that is easily compatible with Mac, Windows, and Linux.

[0003] The Electron open-source community offers good support for both x86 and ARM architectures, allowing for direct download and use. However, it does not support domestic CPU platforms such as Loongson and Shenwei. With the increasing demand for domestic CPUs, the demand for IDEs on these platforms is also growing. Visual Studio Code, widely known among developers, has won favor due to its rich features, lightning-fast response, and excellent user experience. As Electron serves as the development framework for Visual Studio Code, the demand for Electron on domestic CPU platforms is also increasing.

[0004] Electron code supports architectures such as x86, ARM, PowerPC, and S390, but it does not support Electron software for some domestic CPU platforms, such as Loongson and Shenwei architectures. The ecosystem of domestic CPU platforms is incomplete, and the required Electron versions are often unavailable. Significant obstacles were encountered when specific Electron software versions for domestic CPU platforms like Loongson and Shenwei were needed. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a method for rapidly porting Electron software, comprising the following steps:

[0006] Step S1: Add the code for the target architecture to the v8 directory of the Electron source code;

[0007] Step S2: Modify the v8 test program to add a test program for the target architecture;

[0008] Step S3: Search for existing CPU architecture-related code in third-party software within the Electron source code, and add the corresponding code to the source code according to the specifications of the target CPU architecture.

[0009] Step S4: Modify the compilation method of the third-party software ffmpeg in the Electron source code;

[0010] Step S5: Search for existing CPU architecture-related code in the main directory of the Electron source code, and add the code corresponding to the target CPU architecture to the source code according to the specifications of the target CPU architecture.

[0011] Step S6: Execute the Electron build command.

[0012] Step S1 includes:

[0013] Step S11: Search for existing CPU architecture code in the v8 directory;

[0014] Step S12: In the v8 code, according to the specifications of the target CPU architecture, add the implementation of the code corresponding to the target architecture to the source code.

[0015] In step S4, the compilation method of the third-party software ffmpeg is modified to use the ffmpeg runtime library in the operating system corresponding to the target architecture.

[0016] The target architecture includes Loongson or Shenwei architecture.

[0017] This invention can save development time for porting domestically produced CPU platforms to Electron. Attached Figure Description

[0018] Figure 1 The present invention provides a method for rapidly porting Electron software. Detailed Implementation

[0019] To gain a better understanding of the technical solution and beneficial effects of the present invention, the technical solution of the present invention and its beneficial effects are described in detail below with reference to the accompanying drawings.

[0020] The purpose of this invention is to propose a method for quickly porting Electron to a domestic CPU platform, thereby saving development time for porting Electron to a domestic CPU platform.

[0021] The technical concept of this invention is as follows:

[0022] 1. Port the corresponding versions of Electron software to domestic CPU platforms (Loongson, Shenwei), and quickly add Shenwei and Loongson architectures to the source code.

[0023] 2. The Electron source code is massive, and analyzing the required porting code takes a significant amount of time. This invention can quickly locate the areas that need porting, rapidly add CPU architectures, and save substantial development time.

[0024] Figure 1 The method for rapidly porting Electron software according to the present invention, taking Loongson and Shenwei as target architectures as examples, is implemented as follows:

[0025] S1: v8, used for parsing and executing JavaScript, requires porting testing first. Adding Loongson and Shenwei architecture code to the v8 directory of the Electron source code ensures that JavaScript code runs on Loongson and Shenwei platforms;

[0026] Furthermore, the specific steps of S1 include:

[0027] S11: Search for existing CPU architecture code in the v8 directory;

[0028] S12: Based on the specifications of the Loongson and Shenwei CPU architectures, the source code of the V8 code includes code implementations corresponding to the Loongson and Shenwei architectures: search for "V8_TARGET_ARCH_MIPS64", "V8_HOST_ARCH_MIPS", and "MIPS64" in the V8 code.

[0029] The string "mips64el" is followed by code corresponding to the Loongson and Shenwei CPU architecture specifications. This is done by adding the Loongson (loongarch64) and Shenwei (sw_64) CPU architecture codes to the directories src / deoptimizer, src / wasm / baseline, src / compiler / backend, src / regexp, src / execution, src / builtins, src / codegen, src / diagnostics, src / wasm, and src / heap / base / asm.

[0030] S2: Modify the v8 test program to add test programs for Shenwei and Loongson architectures, and use the v8 self-test program to test the v8 code to ensure the success rate of the code;

[0031] S3: Search for existing CPU architecture-related code in third-party software within the Electron source code. Based on the specifications of the Loongson and Shenwei CPU architectures, add the corresponding code to the source code. Specifically, search for strings such as "mips," "MIPS," "mips64," and "MIPS64" in the `third_party` directory of the source code, and add the corresponding Loongson (loongarch64) and Shenwei (sw_64) CPU architecture code after these architecture identifiers. Specifically, the Loongson (loongarch64) and Shenwei (sw_64) CPU architecture code needs to be added to the following directories: webrtc, tcmalloc, swiftshader, icu, electron_node, crashpad, breakpad, boringssl, angle, and abseil-cpp.

[0032] S4: Modify the compilation method of the third-party software ffmpeg in the Electron source code to use the ffmpeg runtime library in the operating system, which can reduce a lot of code porting time.

[0033] S5: Search for existing CPU architecture code in the main Electron source code directory. Based on the specifications of the Loongson and Shenwei CPU architectures, add the corresponding code for each architecture to the source code. Specifically, excluding the third_party and v8 directories, search for the strings "ARCH_CPU_MIPS_FAMILY", "mips64el", and "__mips__" in the source code directories. Add the corresponding Loongson (loongarch64) and Shenwei (sw_64) CPU architecture code after these architecture identifiers. Specifically, add the Loongson (loongarch64) and Shenwei (sw_64) CPU architecture code to the following directories: skia, sandbox, media, gpu, content, components, chrome, build, and base.

[0034] S6: Execute the Electron build command. Specifically, execute the command "ninja-Cout / Releaseelectron" in the main code directory to perform the build.

[0035] Although the present invention has been described using the above preferred embodiments, it is not intended to limit the scope of protection of the present invention. Any changes and modifications made by those skilled in the art to the above embodiments without departing from the spirit and scope of the present invention shall still fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be defined by the claims.

Claims

1. A method for rapidly porting Electron software, characterized in that, Includes the following steps: Step S1: Add the target architecture code to the v8 directory of the Electron source code, including: Step S11: Search for existing CPU architecture code in the v8 directory; Step S12: In the v8 code, according to the specifications of the target CPU architecture, add the implementation of the corresponding code for the target architecture to the source code: search for the strings "V8_TARGET_ARCH_MIPS64", "V8_HOST_ARCH_MIPS", "MIPS64", and "mips64el" in the v8 code, and add the corresponding code for the Loongson and Shenwei CPU architecture specifications after these architecture identifiers; Step S2: Modify the v8 test program to add a test program for the target architecture; Step S3: Search for existing CPU architecture-related code in the third-party software of the Electron source code. According to the specifications of the target CPU architecture, add the corresponding code of the target CPU architecture to the source code: search for the strings "mips", "MIPS", "mips64", and "MIPS64" in the third_party directory of the source code, and add the code of Loongson loongarch64 and Shenwei sw_64 CPU architectures after these architecture identifiers. Step S4: Modify the compilation method of the third-party software ffmpeg in the Electron source code, and change the compilation method of the third-party software ffmpeg to use the ffmpeg runtime library in the operating system corresponding to the target architecture; Step S5: Search for existing CPU architecture-related code in the main directory of the Electron source code. According to the specifications of the target CPU architecture, add the corresponding code for the target CPU architecture to the source code: Remove the third_party directory and the v8 directory, search for the strings "ARCH_CPU_MIPS_FAMILY", "mips64el", and "__mips__" in the source code directory, and add the code for the Loongson loongarch64 and Shenwei sw_64 CPU architectures after these architecture identifiers. Step S6: Execute the Electron build command; The target architecture is either Loongson or Shenwei architecture.

Citation Information

Patent Citations

  • Method for adapting domestic processor and operating system to Eclipse

    CN112527389A

  • Method for adapting domestic operating system to Ceph

    CN114327490A