Cross-platform development method, device and equipment of application program and storage medium

CN122945930APending Publication Date: 2026-10-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510465096.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0006]本申请实施例提供了一种应用程序的跨平台开发方法、装置、设备及存储介质,以解决相关技术中进行跨平台开发时,存在的开发难度大,开发效率低的问题

Benefits of technology

[0025]本申请实施例提供了一种应用程序的跨平台开发方法、装置、设备及存储介质,该方法中由于可以基于第一代码文件采用的编程语言的语法规则,解析获得第一代码文件的代码运行逻辑,因此可以实现源码级别的转换,无需开发者重新熟悉跨平台开发框架和不常用的各个运行平台的特性,就可以实现跨平台开发,这就大大降低了开发难度,也可以使得开发者利用自己熟悉的编程语言进行任一运行平台下的应用程序开发,从而提高开发效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005359058890000171
    Figure BDA0005359058890000171
  • Figure BDA0005359058890000181
    Figure BDA0005359058890000181
  • Figure BDA0005359058890000191
    Figure BDA0005359058890000191
Patent Text Reader

Abstract

This application relates to the field of computer technology and provides a method, apparatus, device, and storage medium for cross-platform development of applications. The method includes: acquiring first code files of a target application and determining the target runtime platform on which the target application is to be released; for each first code file, performing the following steps: parsing the code execution logic of the first code file based on the syntax rules of the programming language used by the first code file, and disassembling the first code file according to the code execution logic to obtain multiple operation instructions; converting the multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target runtime platform to obtain a corresponding second code file; and generating an installation file corresponding to the target runtime platform based on the obtained second code files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology and provides a method, apparatus, device, and storage medium for cross-platform development of applications. Background Technology

[0002] With the development of mobile internet technology, when developing the same application for different operating platforms (e.g., iOS, Android, Web), it is often necessary to build separate installation files for each platform according to the programming languages ​​supported by each platform. However, this development approach leads to a waste of development resources and an increase in development costs, making cross-platform development technology an increasingly preferred solution for developers.

[0003] Cross-platform technology refers to selecting a cross-platform development framework (such as Flutter or React Native), writing the source code files of the target application using the programming language used by that framework, mapping the source code files to native code files for the target platform through the cross-platform development framework, and then rendering the application according to the rendering rules of the target platform, thereby achieving cross-platform development of the target application.

[0004] However, different cross-platform development frameworks use different programming languages ​​and tools. For example, Flutter uses the Dart language and Flutter libraries, while React Native relies on the JavaScript language and React libraries. This means that developers using cross-platform development frameworks need to learn and adapt to the programming languages ​​and tools used by each framework. This incurs additional learning costs for developers familiar only with a single platform's development process, and using unfamiliar programming languages ​​and tools can also reduce development efficiency.

[0005] This shows that cross-platform development in related technologies still faces challenges such as high development difficulty and low development efficiency. Summary of the Invention

[0006] This application provides a method, apparatus, device, and storage medium for cross-platform application development, in order to solve the problems of high development difficulty and low development efficiency in cross-platform development in related technologies.

[0007] In a first aspect, embodiments of this application provide a cross-platform application development method, comprising:

[0008] Obtain each first code file of the target application and determine the target runtime platform on which the target application is to be released; each first code file is written in at least one programming language;

[0009] For each first code file, the following steps are performed: based on the syntax rules of the programming language used in the first code file, the code execution logic of the first code file is parsed and obtained, and the first code file is decomposed according to the code execution logic to obtain multiple operation instructions; according to the encoding rules of the machine language used by the target running platform, the multiple operation instructions are converted into a machine instruction set to obtain the corresponding second code file.

[0010] Based on the obtained second code files, an installation file corresponding to the target runtime platform is generated.

[0011] Secondly, embodiments of this application also provide a cross-platform development apparatus for an application, comprising: an acquisition unit, configured to: acquire each first code file of a target application, and determine the target runtime platform on which the target application is to be released; wherein each first code file is written in at least one programming language;

[0012] The code interpretation unit is configured to: for each first code file, execute the following steps: based on the syntax rules of the programming language used in the first code file, parse the code execution logic of the first code file to obtain the code execution logic, and decompose the first code file according to the code execution logic to obtain multiple operation instructions; and convert the multiple operation instructions obtained into a machine instruction set according to the encoding rules of the machine language used by the target running platform to obtain the corresponding second code file.

[0013] The installation file generation unit is used to generate an installation file corresponding to the target operating platform based on the obtained second code files.

[0014] In one possible implementation, the code interpretation unit parses the code execution logic of a first code file based on the syntax rules of the programming language used in the first code file, and decomposes the first code file according to the code execution logic to obtain multiple operation instructions. Specifically, it performs code scanning on the first code file based on the syntax rules of the programming language used in the first code file to identify each syntax marker; parses the logical relationship between each syntax marker based on the arrangement order of the syntax markers in the first code file to obtain the code execution logic of the first code file; and decomposes the first code file according to the code execution logic to obtain multiple operation instructions represented by a predefined instruction structure.

[0015] In one possible implementation, the code interpretation unit parses the logical relationships between the syntax markers based on their arrangement in a first code file to obtain the code execution logic of the first code file. Specifically, this is used to: construct an abstract syntax tree based on the arrangement of the syntax markers in the first code file and the logical relationships between them; wherein the abstract syntax tree represents the code execution logic of the first code file; each node in the abstract syntax tree represents the syntax marker, and the edges in the abstract syntax tree represent the logical relationships between connected nodes.

[0016] In one possible implementation, the code interpretation unit performs code scanning on the first code file based on the syntax rules of the programming language used in the first code file. When identifying each syntax marker, the code matching unit is used to divide the first code file into various code segments according to a preset code segmentation method; and to match the hash value of each code segment with each pre-stored reference hash value to obtain the matching result of each code segment; each reference hash value is obtained by parsing at least one historical code file; each matching result indicates whether the hash value of the corresponding code segment matches any reference hash value; specifically, the code interpretation unit is used to perform code scanning on the first code file based on the obtained matching results and in conjunction with the syntax rules of the programming language used in the first code file, to identify each syntax marker.

[0017] In one possible implementation, the code interpretation unit, based on the obtained matching results and in conjunction with the syntax rules of the programming language used in the first code file, performs code scanning on the first code file to identify each syntax marker. Specifically, for each code segment, it performs the following: when the matching result of a code segment indicates that the hash value of the code segment matches any reference hash value, the syntax markers stored in association with any reference hash value are taken as the syntax markers contained in the code segment; when the matching result of a code segment indicates that the hash value of the code segment does not match any reference hash value, the code segment is scanned based on the syntax rules of the programming language used in the first code file to identify the syntax markers contained in the code segment.

[0018] In one possible implementation, the code interpretation unit performs code scanning on the first code file based on the obtained matching results and the syntax rules of the programming language used by the first code file. After identifying each syntax marker, the code matching unit is further configured to: when the hash value of the corresponding code segment represented by a matching result does not match any reference hash value, associate and store each syntax marker contained in the code segment corresponding to the matching result with the hash value of the code segment corresponding to the matching result.

[0019] In one possible implementation, the code interpretation unit converts the obtained multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target running platform, thereby obtaining a corresponding second code file. Specifically, this is used to: allocate registers for each variable in the multiple operation instructions; generate a machine instruction set corresponding to the multiple operation instructions based on the register allocation results and the instruction set architecture corresponding to the target running platform; and convert the generated machine instruction set into machine code to obtain a second code file corresponding to the first code file.

[0020] In one possible implementation, the installation file generation unit generates an installation file corresponding to the target runtime platform based on the obtained second code files. Specifically, it is used to: link the obtained second code files and the library files that each second code file depends on to obtain an executable file corresponding to the target application; and package the executable file according to the distribution format of the target runtime platform to generate an installation file corresponding to the target runtime platform.

[0021] Thirdly, embodiments of this application also provide a computer device, including a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor performs the steps of any of the above-described cross-platform development methods for applications, including: obtaining each first code file of a target application and determining the target operating platform on which the target application is to be released; each first code file is written in at least one programming language; for each first code file, the following steps are performed: based on the syntax rules of the programming language used by the first code file, parsing to obtain the code execution logic of the first code file, and disassembling the first code file according to the code execution logic to obtain multiple operation instructions; converting the multiple operation instructions obtained into a machine instruction set according to the encoding rules of the machine language used by the target operating platform to obtain a corresponding second code file; and generating an installation file corresponding to the target operating platform based on each obtained second code file.

[0022] Fourthly, embodiments of this application also provide a computer-readable storage medium including program code, which, when the program product is run on a computer device, is used to cause the computer device to execute the steps of any of the above-described cross-platform development methods for an application.

[0023] Fifthly, embodiments of this application also provide a computer program product, including computer instructions, which are executed by a processor using the steps of any of the above-described cross-platform development methods for applications.

[0024] The beneficial effects of this application are as follows:

[0025] This application provides a method, apparatus, device, and storage medium for cross-platform application development. In this method, the code execution logic of the first code file can be obtained by parsing based on the syntax rules of the programming language used in the first code file. Therefore, source code-level conversion can be achieved. Developers do not need to re-familiarize themselves with cross-platform development frameworks and the characteristics of various less commonly used operating platforms. This greatly reduces the development difficulty and allows developers to use their familiar programming languages ​​to develop applications on any operating platform, thereby improving development efficiency.

[0026] Furthermore, since this method can obtain the second code file based on the encoding rules of the machine language used by the target operating platform, it is possible to develop the source code of the target application program once and simultaneously obtain the target code under other operating platforms, further improving development efficiency.

[0027] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0028] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0029] Figure 1 A schematic diagram illustrating the process of a cross-platform development method in the related technologies provided in this application embodiment;

[0030] Figure 2 This is an optional schematic diagram of an application scenario in the embodiments of this application;

[0031] Figure 3 This is a schematic diagram of the internal architecture of the server provided in an embodiment of this application;

[0032] Figure 4 An exemplary flowchart of a cross-platform development method for an application provided in this application embodiment;

[0033] Figure 5 An exemplary flowchart of the method for obtaining operation instructions provided in the embodiments of this application;

[0034] Figure 6 This is a schematic diagram of the syntax marker recognition process provided in the embodiments of this application;

[0035] Figure 7 This is a schematic diagram of the abstract syntax tree generation process provided in the embodiments of this application;

[0036] Figure 8 A schematic diagram illustrating the process of obtaining operation instructions provided in this application embodiment;

[0037] Figure 9 This is a schematic diagram illustrating the second code file generation process provided in an embodiment of this application;

[0038] Figure 10 This is a schematic diagram of the linking process provided in the embodiments of this application;

[0039] Figure 11 This is a schematic diagram of the packaging and deployment process provided in an embodiment of this application;

[0040] Figure 12 A schematic diagram illustrating the overall process of cross-platform development of an application, provided as an embodiment of this application;

[0041] Figure 13 A schematic diagram of the structure of a cross-platform development apparatus for an application provided in this application embodiment;

[0042] Figure 14 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of this application;

[0043] Figure 15 This is a schematic diagram of the hardware structure of another computer device that applies an embodiment of this application. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0045] The design concept of the embodiments of this application is briefly introduced below:

[0046] See Figure 1 This is a schematic diagram illustrating the process of a cross-platform development method in the related art provided in this application embodiment. In the related art, when developing an application across platforms, the developer first selects a cross-platform development framework and then uses the programming language used by that framework to write the source code files of the target application. For example, if the Flutter development framework is selected, then... Figure 1 The method shown involves writing the source code file for the target application in the Dart language. Then, the Flutter development framework maps the written source code file to the native code file of the target runtime platform, and renders it according to the rendering rules of the target runtime platform to obtain the display interface of the target application on the target runtime platform, thereby realizing cross-platform development of the target application.

[0047] However, different cross-platform development frameworks use different programming languages ​​and tools. For example, Flutter uses the Dart language and Flutter libraries, while React Native relies on the JavaScript language and React libraries. This means that developers using cross-platform development frameworks need to learn and adapt to the programming languages ​​and tools used by each framework. This incurs additional learning costs for developers familiar only with a single platform's development process, and using unfamiliar programming languages ​​and tools can also reduce development efficiency.

[0048] Furthermore, different operating platforms differ in their implementations of rendering mechanisms, compilation and execution, and communication mechanisms. Since the raw code files obtained in these technologies still need to be rendered according to corresponding rendering rules, developers must be familiar with the characteristics and rendering rules of each operating platform. This significantly increases the difficulty and complexity of cross-platform application development.

[0049] This shows that cross-platform development in related technologies still faces challenges such as high development difficulty and low development efficiency.

[0050] In view of this, embodiments of this application provide a method, apparatus, device, and storage medium for cross-platform development of applications. The method includes: acquiring first code files of a target application and determining the target runtime platform on which the target application is to be released. For each first code file, the following steps are performed: parsing the code execution logic of the first code file based on the syntax rules of the programming language used in the first code file, and disassembling the first code file according to the code execution logic to obtain multiple operation instructions; converting the multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target runtime platform to obtain a corresponding second code file. Based on the obtained second code files, an installation file corresponding to the target runtime platform is generated.

[0051] By using the above method, the code execution logic of the first code file can be obtained by parsing based on the syntax rules of the programming language used in the first code file. Therefore, source code-level conversion can be achieved. Developers do not need to relearn the characteristics of cross-platform development frameworks and various less commonly used operating platforms. This greatly reduces the development difficulty and allows developers to use their familiar programming languages ​​to develop applications on any operating platform, thereby improving development efficiency.

[0052] Furthermore, since this method can obtain the second code file based on the encoding rules of the machine language used by the target operating platform, it is possible to develop the source code of the target application program once and simultaneously obtain the target code under other operating platforms, further improving development efficiency.

[0053] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0054] Figure 2 One application scenario is shown, which includes a terminal device 210 and a server 220. The terminal device 210 can establish a communication connection with the server 220 through a wired network or a wireless network.

[0055] Terminal device 210 can obtain the first code files of the target application input by the developer, as well as the target running platform on which the target application is to be released, and send them to server 220.

[0056] Server 220 can perform the following steps for each first code file: based on the syntax rules of the programming language used in the first code file, it parses the code execution logic of the first code file, then decomposes the first code file according to the code execution logic to obtain multiple operation instructions, and then converts the multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target operating platform to obtain the corresponding second code file. Based on the second code file corresponding to each of the first code files, it generates the installation file corresponding to the target operating platform.

[0057] The terminal device 210 in this embodiment of the application may be a smartphone, tablet computer, laptop computer, desktop computer, etc., but is not limited to these.

[0058] The server 220 in this application embodiment can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. This application does not impose any restrictions on these services.

[0059] Further, see Figure 3 This is a schematic diagram of the internal architecture of the server provided in an embodiment of this application. Figure 3 As shown, in Figure 2 In the application scenario shown, the server 220 can obtain the second code file corresponding to each first code file by deploying an interpreter 221, a virtual machine 222, and an integrated development environment tool 223.

[0060] Specifically, for each first code file, the interpreter 221 can parse the code execution logic of the first code file based on the syntax rules of the programming language used in the first code file, and then decompose the first code file according to the code execution logic to obtain multiple operation instructions. These multiple operation instructions are then sent to the virtual machine 222. The virtual machine 222 can convert the multiple operation instructions corresponding to the first code file into a machine instruction set according to the encoding rules of the machine language used by the target running platform, thus obtaining the second code file corresponding to the first code file.

[0061] Then, the virtual machine 222 can send the second code file corresponding to each of the obtained first code files to the integrated development environment tool 223 to generate the installation file corresponding to the target running platform.

[0062] Optionally, the integrated development environment tool can also be deployed in the terminal device 210. In this case, the virtual machine 222 can send the second code file corresponding to each of the obtained first code files to the terminal device 210. The integrated development environment tool in the terminal device 210 can then generate the installation file corresponding to the target running platform based on the obtained second code files.

[0063] It should be noted that, Figure 2 The application scenarios shown are merely illustrative. For example, the cross-platform development method of the application provided in this application embodiment can also be implemented by the terminal device 210. That is, the terminal device 210 can also deploy an interpreter, a virtual machine, and an integrated development environment tool. This application does not limit this.

[0064] This application provides a cross-platform development method for applications that can be applied to... Figure 2 and Figure 3 In server 220 shown. See also Figure 4 An exemplary flowchart of a cross-platform development method for an application provided in this application embodiment, the method may include steps 41-43:

[0065] Step 41: Obtain the first code files of the target application and determine the target platform on which the target application will be released.

[0066] Each first code file is written in at least one programming language. A first code file can refer to a source code file used to develop the target application. An application can typically be developed by writing one or more source code files. For example, an application may include multiple modules, each of which is used to implement different functions of the application. To improve the readability, maintainability, and reusability of the source code, developers can write one or more source code files for each module.

[0067] Furthermore, different source code files can be written in different programming languages, or they can be written in the same programming language.

[0068] For example, suppose the first code files used to develop the target application include file A, file B, and file C. In one scenario, the different first code files are written in different programming languages; for example, file A might be written in Java, file B in C, and file C in Python. In another scenario, some first code files are written in different programming languages, while others are written in the same programming language. For example, files A and B might both be written in Java, and file C in C. In yet another scenario, all first code files are written in the same programming language; for example, files A, B, and C might all be written in Java.

[0069] In addition, a source code file can be written in multiple programming languages. For example, a PHP file can mix HTML, CSS, and JavaScript (JS) to write static content using these languages, which can then be directly output to the client browser.

[0070] It should be noted that the programming language used in each of the above-mentioned first code files can be any one or more high-level programming languages ​​that can be used for application development, including but not limited to Java, C, C#, JS, Python, Kotlin, PHP, etc. This application does not limit this.

[0071] In some embodiments, the target runtime platform for the target application to be released can be any one of one or more runtime platforms on which the target application needs to be released. When the target application needs to be released on multiple runtime platforms, the cross-platform development method of the application provided in this application embodiment can be executed on each runtime platform as a target runtime platform, thereby obtaining the installation files corresponding to each of the multiple runtime platforms and realizing the development of the target application on multiple runtime platforms.

[0072] It should be noted that the target operating platform includes, but is not limited to, Android, iOS, Web, mini-programs, Windows, etc., and this application does not limit it.

[0073] Step 42: For each first code file, perform the following steps 421-422 respectively:

[0074] Step 421: Based on the syntax rules of the programming language used in a first code file, parse the code execution logic of the first code file, and decompose the first code file according to the code execution logic to obtain multiple operation instructions.

[0075] In one possible implementation, see Figure 5 An exemplary flowchart of the method for obtaining operation instructions provided in the embodiments of this application is shown below. Figure 5 As shown, step 421 may include steps 4211-4213:

[0076] Step 4211: Based on the syntax rules of the programming language used in a first code file, perform code scanning on the first code file to identify each syntax marker.

[0077] In some embodiments, when identifying the syntax tokens contained in a first code file, the basic syntax units of the programming language can be determined first based on the syntax rules of the programming language used in the first code file. Then, the source code contained in the first code file can be converted into a series of syntax tokens in the order of arrangement to obtain a sequence of syntax tokens.

[0078] Each syntax marker represents a basic syntactic unit, which can be a keyword, identifier, operator, delimiter, etc. Keywords are language-reserved identifiers for specific functions; for example, "if" is the keyword for conditional statements. Identifiers are variable, function, or class names defined by the developer. For example, in the first code file, there is a statement: `int count = 0;` where "count" is a variable name, therefore "count" is an identifier. Operators are symbols that perform arithmetic, logical, or other operations; for example, "+" is the addition operator. Delimiters are used to separate code structures, such as parentheses and semicolons.

[0079] Because different programming languages ​​have different syntax rules, their basic syntactic units can also be different. For example, "if" is a keyword for conditional statements in C, Java, and Python. JavaScript has the strict equality operator "===", while other languages ​​do not have this operator.

[0080] In one possible implementation, the server can pre-configure the basic syntactic units for each programming language. For example, these can be stored in the server as a table of basic syntactic units, with C language corresponding to table 1, Java language to table 2, C# language to table 3, and so on. It should be noted that this application does not limit the storage format of the basic syntactic units for each programming language.

[0081] The basic syntax unit table for each programming language can be modified and supplemented multiple times as the cross-platform development method of the application provided in this application is implemented, making the syntax markers that can be identified through the basic syntax unit table more accurate and comprehensive. For example, when scanning the first code file written in C language for the first time, if the syntax marker category corresponding to some characters cannot be identified, these unidentified characters can be grouped into one category. Subsequently, developers can set their respective syntax marker categories for these characters and update the basic syntax unit table 1 for C language. In this case, when scanning the first code file written in C language again, the syntax marker category corresponding to each character can be identified according to the updated basic syntax unit table 1.

[0082] Optionally, lexical errors may be encountered during the scanning of a first code file. Therefore, regular expressions can be pre-set to capture these errors and provide error messages. Once captured, these messages can be returned to the terminal device, allowing developers to correct the identified syntax marker sequences based on the error information. For example, account names can only contain alphanumeric characters and underscores. This can be achieved by setting the regular expression: ^[a-zA-Z0-9_]+$ to capture the error message.

[0083] Since application development typically involves developing new features based on product requirements or fixing errors discovered in the code after the application goes live, it's advisable to use a different approach after each modification to one or more initial code files of the application. Figure 4 The process shown generates the installation files for a new version of the application. In this scenario, when developing cross-platform applications for a target application, the first code files obtained from each target application may include modified first code files, that is, first code files that the server once scanned but subsequently modified some of their code.

[0084] In some embodiments, for the above scenario, when performing step 4211, it can be first determined whether there is code in a first code file that has been previously scanned and has not changed in this identification. If not, the entire first code file can be scanned, and the identified syntax markers can be stored. If there is, since the syntax markers contained in the unchanged code have already been stored, this identification can directly obtain the syntax markers contained in the previously stored unchanged code, thereby avoiding repeated scanning of code that has already been scanned and identified, and thus reducing the computational load on the server. A hash algorithm can be used to determine whether the code in a first code file has changed.

[0085] In practice, the server can divide a first code file into various code segments according to a preset code segmentation method. The hash value of each code segment is then matched against pre-stored reference hash values ​​to obtain matching results for each segment. Based on these matching results and the syntax rules of the programming language used in the first code file, a code scan is performed to identify various syntax markers. Each reference hash value is obtained by parsing at least one historical code file, and each matching result indicates whether the hash value of the corresponding code segment matches any reference hash value.

[0086] Specifically, if the hash value of a code segment matches any stored reference hash value, then the matching result indicates that the hash value of that code segment has matched any reference hash value, and also indicates that the code segment has not changed, meaning the developer has not modified it. Conversely, if the hash value of a code segment does not match any stored reference hash value, then the matching result indicates that the hash value of that code segment has not matched any reference hash value, and also indicates that the code segment has changed, meaning the developer has modified it.

[0087] For example, suppose the reference hash values ​​include md5("A1"), md5("B1"), and md5("C1"). The first code file includes code segment AC, where the hash value of code segment A is md5("A1"), the hash value of code segment B is md5("B2"), and the hash value of code segment C is md5("C2"). Since the hash value of code segment A is the same as the reference hash value md5("A1"), it can be determined that the matching result of code segment A indicates that the code segment has matched one of the reference hash values, meaning that code segment A has not changed. Since the hash values ​​of code segments B and C are not the same as any of the reference hash values, it can be determined that the matching results of code segments B and C both indicate that the code segment has not matched any of the reference hash values, meaning that code segments B and C have both changed.

[0088] In some embodiments, the preset code segmentation method can be to divide the code by function, class, or code segment separately, or it can be to combine multiple division units to obtain the various code segments included in a first code file. For example, when using functions as the division unit, if the code in a first code file is used for data cleaning and sorting, then the data cleaning function defined therein can be designated as code segment 1, the data sorting function defined therein as code segment 2, the data output function defined therein as code segment 3, and the main function as code segment 4, thus obtaining a first code file divided into code segment 1 to code segment 4.

[0089] It should be noted that the preset code segment division method can be set by the developer based on the actual situation or experience, and this application does not limit it.

[0090] Based on the above scheme, by dividing the code into segments, the hash value of the matching code segments can be used to determine whether each code segment has changed, thus avoiding repeated scanning of code segments that have not changed. Furthermore, the segmentation method can be pre-set according to the actual situation, allowing for the selection of a more suitable segmentation method based on the actual application scenario of the code and the programming language used, thereby more appropriately reducing the server's computational load. For example, since the concept of classes does not exist in the C language, using classes as the unit of division is clearly inappropriate.

[0091] In one possible implementation, based on the obtained matching results and the syntax rules of the programming language used in the first code file, code scanning is performed on the first code file. When identifying each syntax marker, the following steps can be taken for each segmented code: If the matching result of a code segment indicates that the hash value of a code segment matches any reference hash value, the syntax markers associated with the matched reference hash value are used as the syntax markers contained in that code segment. If the matching result of a code segment indicates that the hash value of a code segment does not match any reference hash value, code scanning is performed on that code segment based on the syntax rules of the programming language used in the first code file to identify the syntax markers contained in that code segment.

[0092] If the matching result of a code segment determines that the code segment has not changed, then since the matched reference hash value is the same as the hash value of the code segment, the various syntax tokens stored in association with the hash value of the code segment can be directly obtained as the various syntax tokens contained in the code segment. If the matching result of a code segment determines that the code segment has changed, then the code segment needs to be scanned again to identify the various syntax tokens contained in the code segment based on the syntax rules of the programming language used.

[0093] Based on the above scheme, when the hash value of a code segment matches any reference hash value, the various syntax tokens associated with the hash value of the code segment can be directly obtained as the syntax tokens contained in the code segment. Therefore, the scanned syntax tokens can be reused. That is, when the same code segment is passed in again, it is not necessary to scan and calculate again, thereby reducing the amount of calculation, shortening the time, and improving the efficiency of cross-platform development.

[0094] In some embodiments, after identifying each syntax marker, when a matching result represents that the hash value of the corresponding code segment does not match any reference hash value, each syntax marker contained in the code segment corresponding to a matching result can be associated and stored with the hash value of the code segment corresponding to a matching result.

[0095] In one example, suppose a first code file is a simple template engine that uses ${} to wrap variables, including <h1> ${title}< / h1> If we divide the code by the type of syntax structure, we get code segment 1: <h1> Code snippet 2: ${title}, Code snippet 3:< / h1> The hash value of each code segment is calculated using the MD5 algorithm, resulting in the md5(" <h1> "), md5("${title}"), md5("< / h1> If, after matching each of the stored reference hash values, it is determined that code segment 1 matches one reference hash value, while the hash values ​​of code segment 2 and code segment 3 do not match any reference hash values, then the md5 hash can be obtained. <h1> ") Syntax markers for associated storage:< / h1> <h1>, as a syntax marker included in code segment 1.

[0096] For code snippets 2 and 3, based on the syntax rules of PHP and HTML respectively, we can identify that code snippet 2 contains the syntax marker `<?php echo htmlspecialchars($title);?>`, and code snippet 3 contains the syntax marker `<?php echo htmlspecialchars($title);?>`.< / h1> Then, the hash value of the code segment is associated with the corresponding syntax marker and stored. The storage format can be as follows:

[0097] md5("${title}"):<? php echo htmlspecialchars($title);? >;

[0098] md5(""):;

[0099] In this case, when the same template needs to be rendered again, each code segment can be traversed. If the hash value of the code segment has been stored, the associated stored syntax markers can be used directly. If the hash value of the code segment does not exist, the syntax markers are re-identified, and the hash value and the identified syntax markers are associated and stored.

[0100] See Figure 6 This is a schematic diagram of the syntax marker recognition process provided in an embodiment of this application. Figure 6 Taking a first code file as an example, we can first use the hash value matching method described above to determine whether each code segment in the first code file has changed. If a code segment has not changed, we can directly obtain the syntax token set corresponding to the hash value. For example, if the calculated hash value of the code segment is hash value 1, we can directly obtain syntax token set 1 as the syntax token set corresponding to the code segment. If a code segment has changed, we rescan to obtain the corresponding syntax tokens, which may include token1, token2, token3, etc., and associate and store each of the scanned syntax tokens as a syntax token set with the calculated hash value of the code segment.

[0101] It should be noted that if this is the first time the cross-platform development method for the application provided in this application embodiment is being used, the first code file can be directly scanned to obtain the syntax markers contained in the first code file. Figure 6 Not shown.

[0102] Step 4212: Based on the order of each syntax marker in a first code file, parse the logical relationship between each syntax marker to obtain the code execution logic of a first code file.

[0103] In one possible implementation, step 4212 can be specifically executed as follows: based on the arrangement order of each syntax marker in a first code file and the logical relationship between each syntax marker, an abstract syntax tree is constructed. Here, the abstract syntax tree represents the code execution logic of a first code file, each node in the abstract syntax tree represents each syntax marker, and the edges in the abstract syntax tree represent the logical relationship between connected nodes.

[0104] A context-free grammar can be used to define syntax rules. The sequence of syntax tokens formed by these tokens can be parsed to obtain an abstract syntax tree representing the code's execution logic. During parsing, the sequence of syntax tokens can be parsed in a top-down manner according to the arithmetic expressions and control structures defined in Table 1.

[0105] Table 1 (Definition Table of Arithmetic Expressions and Control Structures)

[0106]

[0107] Optionally, the server can use a recursive descent parser to parse the sequence of syntax markers, thereby generating an abstract syntax tree.

[0108] For example, see Figure 7This is a schematic diagram of the abstract syntax tree generation process provided in the embodiments of this application. Assume that the first code file contains the statement: x = 1 + 2 * 3, and the parsed syntax marker sequence is [IDENTIFIER(x),ASSIGN,NUMBER(1),PLUS,NUMBER(2),MULTIPLY,NUMBER(3)]. When parsing according to the rules defined in Table 1, since x is an identifier, it can be used as a factor. Since it is followed by zero factors connected by * or / , it is also an item. Since it can be followed by zero items connected by + or -, it is also an expression. Similarly, 1 on the right side of "=" can also be used as one item, while 2 is a factor, 2 * 3 is an item, and 1 + 2 * 3 is an expression composed of 1 and (2 * 3). Therefore, the left and right branches of the "=" node are the two expressions connected by "=", the left and right branches of the "+" node are the two items connected by "+", and the left and right branches of the "*" node are the two factors connected by "*". Then, by representing each node in the form of syntax markers, we can obtain... Figure 7 The abstract syntax tree shown.

[0109] Based on the above scheme, the sequence of syntax markers is transformed into an abstract syntax tree, which can clearly represent the syntactic structure of the code, making it easier for subsequent parsing and optimization. Moreover, through syntax and semantic checks, it can also ensure that the code conforms to the syntax and semantic rules of the programming language, thereby improving code quality.

[0110] Step 4213: Decompose a first code file based on the code execution logic to obtain multiple operation instructions represented according to a predefined instruction structure.

[0111] In some embodiments, the predefined instruction structure can be three-address instructions. Since each instruction of a three-address instruction represents a simple operation containing at most three addresses, the complex expressions contained in a first code file can be decomposed into simple three-address instructions.

[0112] Specifically, the definition of the instruction structure can be shown in Table 2.

[0113] Table 2 (Instruction Structure Definition Table)

[0114]

[0115]

[0116] In Table 2, OP represents operators, such as addition (+), assignment (=), comparison (>), etc.

[0117] In one possible implementation, when the code execution logic is represented by an abstract syntax tree (AST), multiple operation instructions can be obtained by semantically parsing a first code file based on the structure of the AST. Specifically, multiple operation instructions can be obtained by performing different parsing operations on different node types included in the AST. For nodes representing declaration statements, the relevant variable information can be added to the symbol table; for nodes representing assignment statements, operation instructions to assign the expression result to a variable can be generated; for nodes representing arithmetic operations, operation instructions to perform arithmetic operations can be generated, and the result of the arithmetic operation can be stored in a temporary variable; for nodes representing relational operations, operation instructions to perform relational operations can be generated, and the result of the relational operation can be stored in a temporary variable; for nodes representing control flow statements, operation instructions can be generated according to the instruction structure of unconditional jump instructions shown in Table 2 to control the program execution flow.

[0118] In one example, suppose the obtained abstract syntax tree is as follows: Figure 7 As shown, we can first process 2*3. Since the "*" node represents an arithmetic operation, we can generate the operation instruction t1:=2*3 and store the result of the arithmetic operation in the temporary variable t1. Then we process 1+t1. Since the "+" node also represents an arithmetic operation, we can generate the operation instruction t2:=1+t1 and store the result of the arithmetic operation in the temporary variable t2. Finally, we process x=t2. Since the "=" node represents an assignment statement, we can generate the operation instruction x:=t2 to assign the result of the expression to the variable, and assign the value of t2 to the variable x.

[0119] Based on the above scheme, the abstract syntax tree is converted into operation instructions, which can decompose the complex syntax structure into simple operation instructions, thus making it easier to convert it into machine instructions that conform to the coding rules of the target running platform.

[0120] In one possible implementation, to improve code execution efficiency and reduce code size, after obtaining multiple operation instructions, further optimization can be performed on the additional operation instructions. Since Python provides relevant Application Programming Interfaces (APIs), Python's class libraries can be used to manipulate and optimize these operation instructions.

[0121] Optionally, the operation instructions that need to be optimized can be determined using either of the following two methods, depending on the actual situation:

[0122] Method 1, rule-based optimization: that is, predefine some structural patterns of operation instructions that need to be optimized, such as constant expressions, useless assignments, etc., and then identify and apply the corresponding optimization rules in the operation instructions.

[0123] Method 2, cost-based optimization: Design at least one optimization strategy, then calculate the cost and benefit of each optimization strategy based on factors such as code execution frequency and resource consumption, and select the optimal solution for optimization. Each optimization strategy may include at least one structural pattern of the operation instructions that need to be optimized.

[0124] For example, the structural patterns of optimized operation instructions may include, but are not limited to: constant folding, constant propagation, dead code elimination, loop optimization, etc.

[0125] Constant folding refers to directly calculating the result of constant expressions that can be determined at compile time, thereby reducing runtime calculations. For example, operation instructions include t1:=2+3 and x:=t1. Since 2+3 is a constant expression, the result can be calculated directly. Therefore, the optimized operation instruction can be x:=5.

[0126] Constant propagation refers to propagating known constant values ​​to expressions that use them, thereby reducing the amount of code. For example, operation instructions include t1:=5, t2:=t1+3, and x:=t2. Since 5 is a known constant, it can be directly substituted into t2:=t1+3 to obtain the optimized operation instruction x:=8.

[0127] Dead code elimination refers to removing code that has no impact on the program's execution result or will not be executed, thereby reducing code size. For example, consider unused variable assignment statements. Assume the instructions include `x:=5`, `y:=3`, `z:=x+y`, `goto L1`, `t:=10`, `L1:a:=z`. Since executing the first three instructions will directly jump to `L1` to execute `a:=z`, the instruction `t:=10` will be skipped and not executed. Therefore, this instruction can be eliminated. Optimizing the other instructions, the optimized instructions are: `x:=5`, `y:=3`, `z:=x+y`, `a:=z`. It should be noted that this example does not involve the constant propagation optimization method mentioned above. If the constant propagation optimization method is added, the further optimized instructions would be: `a:=8`.

[0128] Loop optimization refers to optimizing the loop structure to reduce redundant calculations within the loop, such as moving unchanging code outside the loop body. Suppose the operation instructions include `for i:=1 to n{t:=x+y, a[i]:=t*i}`, where `t:=x+y` is an expression that does not change with the loop. Therefore, moving this expression outside the loop avoids redundant calculations. The optimized operation instructions can be: `t:=x+y, for i:=1 to n{a[i]:=t*i}`.

[0129] See Figure 8 This is a schematic diagram illustrating the process of obtaining operation instructions provided in an embodiment of this application. According to the above method, the abstract syntax tree obtained in step 4212 is semantically parsed to obtain multiple initial operation instructions corresponding to the first code file, and then... Figure 8 One or more optimization methods shown can be used to optimize multiple initial operation instructions to obtain optimized operation instructions. The optimization methods can be found in the above description and will not be repeated here.

[0130] Based on the above scheme, by using Three-Address Code (TAC) as the instruction structure for operation instructions, complex expressions can be decomposed into simple three-address instructions. Furthermore, through constant folding and constant propagation, the computational load during code execution can be reduced, improving execution efficiency. Dead code elimination and loop optimization remove unnecessary code from the first code file, reducing code size.

[0131] Step 422: According to the encoding rules of the machine language used by the target operating platform, convert the obtained multiple operation instructions into a machine instruction set to obtain the corresponding second code file.

[0132] The encoding rules of the machine language used by the target runtime platform can include the instruction set architecture corresponding to the target runtime platform. Different runtime platforms may have different instruction set architectures. For example, Android and iOS platforms are usually based on the ARM instruction set architecture, Windows platforms usually use the x86 instruction set architecture, and Web platforms usually use WebAssembly bytecode, etc.

[0133] In addition, the encoding rules of the machine language used by the target operating platform may also include the hardware information, operating environment information, etc. of the corresponding platform. This information can be configured in the configuration file corresponding to the target operating platform, which may also include a general code generation template, so that a second code file corresponding to the first code file can be generated based on the multiple operation instructions obtained and the configuration file corresponding to the target operating platform.

[0134] In one possible implementation, step 422 can be specifically executed as follows: Register allocation is performed on each variable in the multiple operation instructions; based on the register allocation results and the instruction set architecture corresponding to the target operating platform, a machine instruction set corresponding to the multiple operation instructions is generated; the generated machine instruction set is converted into machine code to obtain a second code file corresponding to a first code file.

[0135] For example, suppose the target operating platform uses the x86 instruction set architecture. The x86 architecture has a rich instruction set, including various efficient arithmetic operations and Single Instruction Multiple Data (SIMD) extensions. If multiple operation instructions are obtained, including: t1:=x+y, t2:=t1*z, then register allocation can generate the machine instruction sets corresponding to these multiple operation instructions: mov eax, x; add eax, y; movt1, eax; mov ebx, t1; imul ebx, z; mov t2, ebx. In the above machine instruction set, `mov` is a move instruction; `mov eax,x` means assigning the value of `x` to the `eax` register. `add` is an addition operation; `add eax,y` means adding the value in the `eax` register to the value of `y`. `mov t1,eax` means copying the value of the `eax` register to the variable `t1`. `mov ebx,t1` means assigning the value of `t1` to the `ebx` register. `imul` is a multiplication operation; `imul ebx,z` means multiplying the value of `z` by the value in the `ebx` register. `mov t2,ebx` means copying the value in the `ebx` register to the variable `t2`. It should be noted that the semicolons in the above machine instruction set are used to separate multiple machine instructions.

[0136] In the example above, storing intermediate results in registers reduces the number of memory accesses. Since register access is much faster than memory access, reusing registers can significantly improve code execution efficiency.

[0137] After obtaining the aforementioned machine instruction set, the generated machine instruction set can be converted into binary machine code to obtain a second code file corresponding to a first code file. The machine code corresponds to the compilation result of functions and variables in the first code file. In addition to machine code, the second code file may also include a symbol table, relocation information, etc. The symbol table records symbol information such as functions and global variables defined in the second code file, as well as symbol information that needs to be referenced from other second code files or libraries. The relocation information indicates how the linker should adjust the addresses of code and data in the final executable file.

[0138] See Figure 9This is a schematic diagram illustrating the second code file generation process provided in an embodiment of this application. For example... Figure 9 As shown, after obtaining the operation instruction set corresponding to the first code file, register allocation can be performed on each variable in the multiple operation instructions contained in the operation instruction set according to the configuration file corresponding to the target operating platform, thereby obtaining the machine instruction set. For example, if the target operating platform is the iOS platform, the operation instruction set can be converted into a machine instruction set according to the instruction set architecture, hardware information, and operating environment information indicated in configuration file 2. Then, the machine instruction set is converted into binary machine code, and a symbol table and relocation information are generated according to the information of each variable in the machine instruction set, which are then combined to obtain the second code file corresponding to the first code file. The specific implementation methods of each step can be found in the above description and will not be repeated here.

[0139] Step 43: Based on the obtained second code files, generate the installation files corresponding to the target runtime platform.

[0140] In one possible implementation, step 43 can be specifically performed as follows: linking the obtained second code files and the library files that each second code file depends on to obtain the executable file corresponding to the target application. Then, according to the distribution format of the target runtime platform, the executable file is packaged to generate the installation file corresponding to the target runtime platform.

[0141] In some embodiments, when linking the obtained second code files and the library files that each second code file depends on to obtain the executable file corresponding to the target application, the symbol table in each second code file can be resolved by the linker in the virtual machine to ensure that each symbol (such as function name, variable name) in each second code file has a unique address. Then, address relocation is performed based on the relocation information in each second code file, that is, the reference address of the symbol is replaced with the actual memory address, thereby obtaining the executable file corresponding to the target application.

[0142] Optionally, during the linking operation, dynamic linking or static linking can be selected based on the actual situation or experience. Static linking refers to directly copying all dependent library function code into the final executable file. This linking method allows the target application to run without relying on external libraries, resulting in fast execution and convenient deployment. However, the executable file size is larger, and updating library functions requires recompiling and relinking the entire application. Therefore, it is suitable for scenarios where application size is not critical and speed is paramount, such as embedded systems.

[0143] Dynamic linking refers to loading dependent library functions only at application runtime. This linking method results in smaller executable file sizes, saving disk space and memory, and updates only require replacing the corresponding library files without updating the entire application. However, the application needs to load external libraries at runtime, leading to slightly slower startup speeds and potentially more complex deployment due to the dependency on external library files. Therefore, this linking method is suitable for scenarios sensitive to program size and requiring frequent updates to library functions, such as desktop applications.

[0144] See Figure 10 This is a schematic diagram of the linking process provided in an embodiment of this application. Assuming there are n second code files and m library files, the symbol tables of the n second code files can be collected. Then, symbol resolution is performed on the collected symbol tables and the m library files to construct a global symbol table. Next, based on the relocation information in each second code file, address relocation is performed to generate the linked executable file. Static linking can generate a static executable file, while dynamic linking can generate a dynamic executable file.

[0145] Furthermore, in scenarios where new features are developed based on product requirements, or where errors are found in the code after the application has been launched and a new version of the application's installation file needs to be generated, an incremental compilation mechanism can be implemented. This means that only the first modified code file and the first affected code file are executed. Figure 4 The process shown allows for the recompilation of only the modified first code files and those affected by them during compilation. These are then relinked with the unmodified second code files to generate a new executable. This avoids repeatedly compiling the unmodified code, significantly reducing compilation time, especially effective in large projects. The affected first code files refer to those that reference symbols from the modified first code files; these need to be relinked to update symbol addresses and other information.

[0146] In some embodiments, when packaging the executable file according to the distribution format of the target operating platform to generate the installation file corresponding to the target operating platform, the packaging command corresponding to the target operating platform can be used to package the executable file, configuration file, resource file, and other related files into a suitable distribution format to obtain the installation file corresponding to the target operating platform. For example, if the target operating platform is Android, it can be packaged into an APK format installation file; if the target operating platform is iOS, it can be packaged into an IPA format installation file; if the target operating platform is a mini-program, it can be packaged into a wxapkg format installation file.

[0147] Optionally, after obtaining the installation file corresponding to the target runtime platform, the installation file can be automatically deployed to the target runtime platform using continuous integration / continuous delivery / deployment (CI / CD) tools, ensuring that the code in the first code file can be automatically built, tested, and deployed to the target runtime platform environment after each commit.

[0148] See Figure 11 This diagram illustrates the packaging and deployment process provided in this application embodiment. After obtaining the executable file of the target application, the executable file and resource files can be packaged into an installation file according to the release format corresponding to the target operating platform, and then deployed to the target operating platform. For example, when the target operating platform is the Android platform, the executable file and resource files can be packaged into an installation file in .APK format and deployed to the Android platform.

[0149] See Figure 12 This application provides an overall flowchart of cross-platform application development, which includes steps 1201-1208:

[0150] Step 1201: Determine the target operating platform and programming language.

[0151] Determine the target runtime platform for the target application to be released, and at least one programming language used in each of the first code files.

[0152] Step 1202: The interpreter receives each of the first code files.

[0153] Step 1203: Lexical analysis.

[0154] For each first code file, lexical analysis is performed to identify the syntax markers contained in the first code file.

[0155] Step 1204: Syntax analysis.

[0156] For each first code file, an abstract syntax tree is constructed based on the order of the syntax markers.

[0157] Step 1205: Semantic analysis.

[0158] For each first code file, semantic analysis is performed on the abstract syntax tree corresponding to the first code file to obtain multiple operation instructions corresponding to the first code file.

[0159] Step 1206: Generate machine instruction set.

[0160] Based on the configuration file corresponding to the target operating platform, a corresponding machine instruction set is generated. The machine instruction set may be different for different operating platforms.

[0161] Step 1207: Generate each second code file.

[0162] By converting the machine instruction set corresponding to each first code file into machine code and generating a symbol table and relocation information, the second code file corresponding to each first code file is obtained.

[0163] Step 1208: Linking and Packaging.

[0164] Integrated development environment tools can link and package the obtained secondary code files to obtain the installation files of the target application on the target running platform.

[0165] It should be noted that, Figure 12 The specific implementation methods of each step shown can be found in the relevant descriptions in the above method embodiments, and will not be repeated here.

[0166] Based on the same inventive concept as the above-described method embodiments, this application also provides a cross-platform development apparatus for applications. For example... Figure 13 The cross-platform development apparatus 1300 for the application shown may include:

[0167] The acquisition unit 1301 is configured to: acquire each first code file of the target application and determine the target runtime platform on which the target application is to be released; each first code file is written in at least one programming language;

[0168] The code interpretation unit 1302 is configured to: for each first code file, execute the following steps: based on the syntax rules of the programming language used by the first code file, parse to obtain the code execution logic of the first code file, and decompose the first code file according to the code execution logic to obtain multiple operation instructions; and convert the multiple operation instructions obtained into a machine instruction set according to the encoding rules of the machine language used by the target running platform to obtain the corresponding second code file.

[0169] The installation file generation unit 1303 is used to generate an installation file corresponding to the target operating platform based on the obtained second code files.

[0170] In one possible implementation, the code interpretation unit 1302 parses the code execution logic of a first code file based on the syntax rules of the programming language used in the first code file, and decomposes the first code file according to the code execution logic to obtain multiple operation instructions. Specifically, it is used to: scan the first code file based on the syntax rules of the programming language used in the first code file to identify each syntax marker; parse the logical relationship between each syntax marker based on the arrangement order of the syntax markers in the first code file to obtain the code execution logic of the first code file; and decompose the first code file according to the code execution logic to obtain multiple operation instructions represented by a predefined instruction structure.

[0171] In one possible implementation, the code interpretation unit 1302 parses the logical relationships between the syntax markers based on their arrangement order in the first code file to obtain the code execution logic of the first code file. Specifically, it is used to: construct an abstract syntax tree based on the arrangement order of the syntax markers in the first code file and the logical relationships between them; wherein the abstract syntax tree represents the code execution logic of the first code file; each node in the abstract syntax tree represents the syntax marker, and the edges in the abstract syntax tree represent the logical relationships between connected nodes.

[0172] In one possible implementation, the code interpretation unit 1302 performs code scanning on the first code file based on the syntax rules of the programming language used in the first code file. When identifying each syntax marker, the code matching unit 1304 is used to divide the first code file into various code segments according to a preset code segmentation method; and to match the hash value of each code segment with each pre-stored reference hash value to obtain the matching result of each code segment; each reference hash value is obtained by parsing at least one historical code file; each matching result indicates whether the hash value of the corresponding code segment matches any reference hash value; the code interpretation unit is specifically used to perform code scanning on the first code file based on the obtained matching results and in conjunction with the syntax rules of the programming language used in the first code file, and to identify each syntax marker.

[0173] In one possible implementation, the code interpretation unit 1302, based on the obtained matching results and in conjunction with the syntax rules of the programming language used in the first code file, performs code scanning on the first code file to identify each syntax marker. Specifically, for each code segment, it performs the following: when the matching result of a code segment indicates that the hash value of the code segment matches any reference hash value, the syntax markers stored in association with any reference hash value are taken as the syntax markers contained in the code segment; when the matching result of a code segment indicates that the hash value of the code segment does not match any reference hash value, the code segment is scanned based on the syntax rules of the programming language used in the first code file to identify the syntax markers contained in the code segment.

[0174] In one possible implementation, the code interpretation unit 1302 performs code scanning on the first code file based on the obtained matching results and the syntax rules of the programming language used by the first code file. After identifying each syntax marker, the code matching unit 1304 is further configured to: when the hash value of the corresponding code segment represented by a matching result does not match any reference hash value, associate and store each syntax marker contained in the code segment corresponding to the matching result with the hash value of the code segment corresponding to the matching result.

[0175] In one possible implementation, the code interpretation unit 1302 converts the obtained multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target running platform, and obtains a corresponding second code file. Specifically, it is used to: allocate registers for each variable in the multiple operation instructions; generate a machine instruction set corresponding to the multiple operation instructions based on the register allocation result and the instruction set architecture corresponding to the target running platform; and convert the generated machine instruction set into machine code to obtain a second code file corresponding to the first code file.

[0176] In one possible implementation, the installation file generation unit 1303 generates an installation file corresponding to the target operating platform based on the obtained second code files. Specifically, it is used to: link the obtained second code files and the library files that each second code file depends on to obtain an executable file corresponding to the target application; and package the executable file according to the distribution format of the target operating platform to generate an installation file corresponding to the target operating platform.

[0177] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program with a predetermined function, which works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functions of that module or unit.

[0178] Having described the cross-platform development method and apparatus for applications according to exemplary embodiments of this application, we will now describe a computer device according to another exemplary embodiment of this application.

[0179] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0180] Based on the same inventive concept as the above-described method embodiments, this application also provides a computer device. In one embodiment, the computer device may be a server, such as... Figure 2 The server 220 is shown. In this embodiment, the computer device 1400 is structured as follows: Figure 14 As shown, it may include at least a memory 1401, a communication module 1403, and at least one processor 1402.

[0181] The memory 1401 is used to store computer programs executed by the processor 1402. The memory 1401 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0182] Memory 1401 may be volatile memory, such as random-access memory (RAM); memory 1401 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1401 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1401 may be a combination of the above-described memories.

[0183] The processor 1402 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1402 is used to retrieve first code files of a target application when calling a computer program stored in memory 1401, and to determine the target operating platform on which the target application is to be released. Each first code file is written in at least one programming language. For each first code file, the following steps are performed: based on the syntax rules of the programming language used in the first code file, the code execution logic of the first code file is parsed and obtained; the first code file is then decomposed according to the code execution logic to obtain multiple operation instructions; the multiple operation instructions are converted into a machine instruction set according to the encoding rules of the machine language used by the target operating platform to obtain a corresponding second code file; and based on the obtained second code files, an installation file corresponding to the target operating platform is generated.

[0184] The communication module 1403 is used to communicate with terminal devices and other servers.

[0185] This application embodiment does not limit the specific connection medium between the memory 1401, communication module 1403, and processor 1402. This application embodiment... Figure 14 The memory 1401 and the processor 1402 are connected via a bus 1404, and the bus 1404 is in Figure 14 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1404 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 14 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0186] The memory 1401 stores a computer storage medium, which stores computer-executable instructions. These instructions are used to implement the cross-platform development method for the application program according to embodiments of this application. The processor 1402 is used to execute the aforementioned cross-platform development method for the application program, such as... Figure 4 As shown.

[0187] In another embodiment, the computer device can also be other computer devices, such as... Figure 2 The terminal device 210 is shown. In this embodiment, the structure of the computer device can be as follows: Figure 15 As shown, it includes components such as: communication component 1510, memory 1520, display unit 1530, camera 1540, sensor 1550, audio circuit 1560, Bluetooth module 1570, processor 1580, etc.

[0188] The communication component 1510 is used to communicate with the server. In some embodiments, it may include a Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology, and the electronic device can send and receive information through the WiFi module.

[0189] The memory 1520 can be used to store software programs and data. The processor 1580 executes various functions of the terminal device 210 and performs data processing by running the software programs or data stored in the memory 1520. The memory 1520 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1520 stores an operating system that enables the terminal device 210 to run. In this application, the memory 1520 may store the operating system and various applications, and may also store computer programs that execute cross-platform development methods for the applications of the embodiments of this application.

[0190] The display unit 1530 can also be used to display information input by an object or information provided to an object, as well as a graphical user interface (GUI) for various menus of the terminal device 210. Specifically, the display unit 1530 may include a display screen 1532 disposed on the front of the terminal device 210. The display screen 1532 may be configured as a liquid crystal display, a light-emitting diode, or the like.

[0191] The display unit 1530 can also be used to receive input digital or character information and generate signal inputs related to object settings and function control of the terminal device 210. Specifically, the display unit 1530 may include a touch screen 1531 disposed on the front of the terminal device 210, which can collect touch operations on or near the object, such as clicking a button, dragging a scroll bar, etc.

[0192] The touchscreen 1531 can be placed on top of the display screen 1532, or the touchscreen 1531 and the display screen 1532 can be integrated to realize the input and output functions of the terminal device 210. After integration, it can be referred to as a touch display screen. In this application, the display unit 1530 can display the application and the corresponding operation steps.

[0193] Camera 1540 can be used to capture still images, and objects can publish images captured by camera 1540 through an application. There can be one or multiple cameras 1540. An optical image of an object is generated through a lens and projected onto a photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to processor 1580 to be converted into a digital image signal.

[0194] The terminal device may also include at least one sensor 1550, such as an accelerometer 1551, a proximity sensor 1552, a fingerprint sensor 1553, and a temperature sensor 1554. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.

[0195] Audio circuitry 1560, speaker 1561, and microphone 1562 provide an audio interface between the device and terminal device 210. Audio circuitry 1560 converts received audio data into electrical signals, which are then transmitted to speaker 1561, where they are converted into sound signals for output. Terminal device 210 may also be equipped with volume buttons for adjusting the volume of the sound signal. Conversely, microphone 1562 converts collected sound signals into electrical signals, which are then received by audio circuitry 1560, converted back into audio data, and output to communication component 1510 for transmission to, for example, another terminal device 210, or to memory 1520 for further processing.

[0196] The Bluetooth module 1570 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1570, thereby exchanging data.

[0197] The processor 1580 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 1520 and calling data stored in the memory 1520. In some embodiments, the processor 1580 may include one or more processing units; the processor 1580 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1580. In this application, the processor 1580 can run an operating system, applications, user interface display and touch response, as well as the cross-platform development method for applications in the embodiments of this application. Furthermore, the processor 1580 is coupled to the display unit 1530.

[0198] Furthermore, it should be noted that in the specific embodiments of this application, object data related to cross-platform development of applications is involved. When the above embodiments of this application are applied to specific products or technologies, object permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0199] In some possible implementations, various aspects of the cross-platform development method for applications provided in this application can also be implemented in the form of a program product, which includes a computer program. When the program product is run on a computer device, the computer program causes the computer device to perform the steps in the cross-platform development method for applications according to various exemplary embodiments of this application described above. For example, the computer device can perform actions such as... Figure 4 The steps are shown in the figure.

[0200] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0201] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0202] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0203] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0204] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The computer program can execute entirely on the user's computer device, partially on the user's computer device, as a standalone software package, partially on the user's computer device and partially on a remote computer device, or entirely on a remote computer device. In cases involving remote computer devices, the remote computer device can be connected to the user's computer device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer device (e.g., via the Internet using an Internet service provider).

[0205] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0206] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0207] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.

[0208] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, produce a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0209] These computer program commands may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the commands stored in the computer-readable storage medium produce an article of manufacture including command means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0210] These computer program commands can also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing the commands executed on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0211] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0212] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A cross-platform development method for an application, characterized in that, include: Obtain each of the first code files of the target application and determine the target runtime platform on which the target application is to be released; Each of the first code files is written in at least one programming language; For each first code file, execute the following: Based on the syntax rules of the programming language used in a first code file, the code execution logic of the first code file is parsed and obtained, and the first code file is decomposed according to the code execution logic to obtain multiple operation instructions; According to the encoding rules of the machine language used by the target operating platform, the obtained multiple operation instructions are converted into a machine instruction set to obtain the corresponding second code file; Based on the obtained second code files, an installation file corresponding to the target runtime platform is generated.

2. The method according to claim 1, characterized in that, The code execution logic of a first code file is obtained by parsing the syntax rules of the programming language used in that first code file, and the first code file is then decomposed according to the code execution logic to obtain multiple operation instructions, including: Based on the syntax rules of the programming language used in the first code file, code scanning is performed on the first code file to identify each syntax marker; Based on the order of the syntax markers in the first code file, the logical relationship between the syntax markers is parsed to obtain the code execution logic of the first code file. Based on the code execution logic, the first code file is decomposed to obtain multiple operation instructions represented according to a predefined instruction structure.

3. The method according to claim 2, characterized in that, The step of parsing the logical relationships between the syntax markers based on their order in the first code file to obtain the code execution logic of the first code file includes: An abstract syntax tree is constructed based on the order of the syntax markers in the first code file and the logical relationships between the syntax markers. The abstract syntax tree represents the code execution logic of the first code file; each node in the abstract syntax tree represents each syntax marker; and the edges in the abstract syntax tree represent the logical relationship between connected nodes.

4. The method according to claim 2, characterized in that, The first code file is scanned based on the syntax rules of the programming language used in the first code file to identify various syntax markers, including: According to the preset code segmentation method, the first code file is divided into various code segments; The hash value of each code segment is matched with each pre-stored reference hash value to obtain the matching result of each code segment; each reference hash value is obtained by parsing at least one historical code file; each matching result indicates whether the hash value of the corresponding code segment matches any reference hash value. Based on the obtained matching results, and in conjunction with the syntax rules of the programming language used in the first code file, code scanning is performed on the first code file to identify each syntax marker.

5. The method according to claim 4, characterized in that, Based on the obtained matching results and in conjunction with the syntax rules of the programming language used in the first code file, code scanning is performed on the first code file to identify various syntax markers, including: For each of the aforementioned code segments, execute the following respectively: The matching result of a code segment is characterized in that when the hash value of the code segment matches any reference hash value, the syntax tokens stored in association with the reference hash value are used as the syntax tokens contained in the code segment. The matching result of the code segment indicates that when the hash value of the code segment does not match any reference hash value, the code segment is scanned based on the syntax rules of the programming language used by the first code file to identify the syntax markers contained in the code segment.

6. The method according to claim 4, characterized in that, Based on the obtained matching results and the syntax rules of the programming language used in the first code file, the method further includes scanning the first code file to identify the syntax markers, and then performing code scanning on the first code file. When a matching result indicates that the hash value of the corresponding code segment does not match any reference hash value, the syntax markers contained in the code segment corresponding to the matching result are associated and stored with the hash value of the code segment corresponding to the matching result.

7. The method according to any one of claims 1-6, characterized in that, The step of converting multiple operation instructions into a machine instruction set according to the encoding rules of the machine language used by the target operating platform to obtain the corresponding second code file includes: Register allocation is performed for each variable in the plurality of operation instructions; Based on the register allocation results and the instruction set architecture corresponding to the target operating platform, a machine instruction set corresponding to the multiple operation instructions is generated. The generated machine instruction set is converted into machine code to obtain a second code file corresponding to the first code file.

8. The method according to any one of claims 1-6, characterized in that, The step of generating the installation file corresponding to the target runtime platform based on the obtained second code files includes: The obtained second code files and the library files that each second code file depends on are linked to obtain the executable file corresponding to the target application; The executable file is packaged according to the release format of the target operating platform to generate the installation file corresponding to the target operating platform.

9. A cross-platform development apparatus for an application, characterized in that, include: The acquisition unit is configured to: acquire each first code file of the target application and determine the target runtime platform on which the target application is to be released; Each of the first code files is written in at least one programming language; The code interpretation unit is configured to: for each first code file, execute the following steps: based on the syntax rules of the programming language used in the first code file, parse the code execution logic of the first code file to obtain the code execution logic, and decompose the first code file according to the code execution logic to obtain multiple operation instructions; and convert the multiple operation instructions obtained into a machine instruction set according to the encoding rules of the machine language used by the target running platform to obtain the corresponding second code file. The installation file generation unit is used to generate an installation file corresponding to the target operating platform based on the obtained second code files.

10. A computer device, characterized in that, It includes a processor and a memory, wherein the memory stores program code that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, It includes program code that, when run on a computer device, causes the computer device to perform the steps of the method according to any one of claims 1 to 8.

12. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8.