CN111209005A - Method and apparatus for compiling program file, and computer-readable storage medium - Google Patents

Method and apparatus for compiling program file, and computer-readable storage medium Download PDF

Info

Publication number
CN111209005A
CN111209005A CN202010008323.0A CN202010008323A CN111209005A CN 111209005 A CN111209005 A CN 111209005A CN 202010008323 A CN202010008323 A CN 202010008323A CN 111209005 A CN111209005 A CN 111209005A
Authority
CN
China
Prior art keywords
program file
compiling
compiled
file
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010008323.0A
Other languages
Chinese (zh)
Other versions
CN111209005B (en
Inventor
唐俊俊
王旭
殷荣桧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010008323.0A priority Critical patent/CN111209005B/en
Publication of CN111209005A publication Critical patent/CN111209005A/en
Application granted granted Critical
Publication of CN111209005B publication Critical patent/CN111209005B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a compiling method and device of a program file and a computer readable storage medium; receiving an original program file uploaded by a terminal, and identifying the type of the original program file; when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system; converting the original program file into a target program file of a target syntax structure based on the interface code file type; based on the target program file, the cloud server can generate a program file to be compiled; and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file. The scheme can improve the compiling efficiency of the program file.

Description

Method and apparatus for compiling program file, and computer-readable storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for compiling a program file, and a computer-readable storage medium.
Background
With the development of communication technology, more and more program files are added in various system platforms, after corresponding program files are installed in related browsers, the browsers can directly call the program files, and the positioning of the program files is to develop and realize programs with functions which are not possessed by original pure system platforms and application software platforms.
In the research and practice process of the related technology, the inventor of the application finds that the existing compiling mode of the program file is compiled and expanded through a command line tool on a local or upper service, the compiling and developing cost is high, each developer to be compiled needs to build a set of compiling environment, the reusability is not high, and the compiling efficiency of the program file is low.
Disclosure of Invention
The embodiment of the application provides a method and a device for compiling a program file and a computer readable storage medium, which can improve the efficiency of compiling the program file.
The embodiment of the application provides a compiling method of a program file, which comprises the following steps:
receiving an original program file uploaded by a terminal, and identifying the type of the original program file;
when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system;
converting the original program file into a target program file of a target syntax structure based on the interface code file type;
generating a program file to be compiled based on the target program file;
and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
Correspondingly, an embodiment of the present application provides a device for compiling a program file, including:
the receiving unit is used for receiving an original program file uploaded by a terminal and identifying the type of the original program file;
the first determining unit is used for determining an interface compiling version corresponding to the original program file in a terminal system when the type of the original program file is identified to be an interface code file type;
the conversion unit is used for converting the original program file into a target program file with a target syntax structure based on the interface code file type;
the generating unit is used for generating a program file to be compiled based on the target program file;
and the first compiling unit is used for compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
In one embodiment, the conversion unit includes:
the cutting subunit is used for cutting the original program file according to a preset rule based on the interface code file type to obtain a cut array;
and the conversion subunit is used for converting the array into a target program file with a target syntax structure.
In one embodiment, the generating unit includes:
the analysis subunit is used for analyzing the target program file to obtain analyzed attribute data information;
and the integration subunit is used for integrating the attribute data information to generate a program file to be compiled.
In an embodiment, the integrating subunit is further configured to obtain a skeleton code corresponding to the analyzed attribute data information; and merging the attribute data information and the skeleton code to generate a program file to be compiled.
In one embodiment, the first compiling unit includes:
the first receiving subunit is used for receiving a compiling instruction;
the setting subunit is used for setting the temporary compiling environment parameter based on the interface compiling version to obtain the temporary compiling environment parameter;
and the compiling subunit is used for compiling the program file to be compiled according to the compiling instruction and the temporary compiling environment parameter to obtain a compiled program file.
In an embodiment, the compiling subunit further comprises:
the detection subunit is used for detecting the state of the compiled program file to obtain a detection result;
the second receiving subunit is used for receiving a compiled program file acquisition request sent by the terminal;
and the sending subunit is configured to send the compiled program file to the terminal based on the detection result and the compiled program file acquisition request.
In one embodiment, the compiling apparatus of the program file further includes:
the second determining unit is used for determining the corresponding extended compiled version of the original program file in the terminal system when the type of the original program file is the type of the extended program;
and the second compiling unit is used for compiling the original program file based on the extended compiling version to obtain a compiled extended program file.
Accordingly, embodiments of the present application further provide a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes steps in the compiling method of the program file provided in any of the embodiments of the present application.
Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, where the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to perform steps in the method for compiling a program file provided in any embodiment of the present application.
The method and the device can receive the original program file uploaded by the terminal and identify the type of the original program file; when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system; converting the original program file into a target program file of a target syntax structure based on the interface code file type; generating a program file to be compiled based on the target program file; and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file. According to the scheme, the edition of program compiling can be determined by identifying the type of the uploaded original program file, then the program file to be compiled can be compiled, a set of compiling environment does not need to be set up, and the efficiency of program file compiling is high.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic view of a scenario of a compiling method of a program file according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for compiling a program file according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating an overall use of an extension of a compiling method for a program file according to an embodiment of the present application;
FIG. 4 is a flowchart of an implementation of a method for compiling a program file according to an embodiment of the present application;
FIG. 5 is a diagram of a compiling platform of a compiling method for a program file according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a difference of a compiling method of a program file according to an embodiment of the present application;
FIG. 7 is a diagram of another compiling platform of a compiling method for a program file according to an embodiment of the present application;
fig. 8 is a technical architecture diagram of a compiling method of a program file provided in an embodiment of the present application;
FIG. 9 is a block chain system according to an embodiment of the present disclosure;
FIG. 10 is another flowchart of a method for compiling a program file according to an embodiment of the present application;
fig. 11 is a device diagram of a compiling method of a program file according to an embodiment of the present application;
FIG. 12 is a diagram of another apparatus for a method for compiling a program file according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a compiling method and device of a program file and a computer readable storage medium. Specifically, the embodiment of the present application provides a compiling apparatus for a program file suitable for a computer device. The computer device may be a terminal or a server, the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like. The terminal may be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and the like. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
Referring to fig. 1, taking a computer device as an example of a server, the server may receive an original program file uploaded by a terminal and identify a type of the original program file; when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system; converting the original program file into a target program file with a target syntax structure based on the interface code file type; generating a program file to be compiled based on the object program file; and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
The object program file can be compiled based on a cloud platform to generate a compiled program file, and the cloud platform is also called a cloud computing platform and is used for providing computing, network and storage capabilities based on services of hardware resources and software resources. Cloud computing (cloud computing) is a computing model that distributes computing tasks over a pool of resources formed by a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the "cloud" appear to the user as being infinitely expandable and available at any time, available on demand, expandable at any time, and paid for on-demand.
As a basic capability provider of cloud computing, a cloud computing resource pool (called as an ifas (Infrastructure as a Service) platform for short is established, and multiple types of virtual resources are deployed in the resource pool and are selectively used by external clients.
According to the logic function division, a PaaS (Platform as a Service) layer can be deployed on an IaaS (Infrastructure as a Service) layer, a SaaS (Software as a Service) layer is deployed on the PaaS layer, and the SaaS can be directly deployed on the IaaS. PaaS is a platform on which software runs, such as a database, a web container, etc. SaaS is a variety of business software, such as web portal, sms, and mass texting. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
As can be seen from the above, in the embodiment, the version of program compilation is determined by identifying the type of the uploaded original program file, and then the program file to be compiled can be compiled, so that a set of compiling environment is not required to be set up, and the efficiency of program file compilation is high.
The following are detailed below, and it should be noted that the order of description of the following examples is not intended to limit the preferred order of the examples.
The embodiments of the present application will be described from the perspective of a program file compiling apparatus, which may be specifically integrated in a server.
The embodiment of the application provides a compiling method of a program file, which can be executed by a server or a terminal, and can also be executed by the terminal and the server together; in the embodiment of the present application, the compiling method of the program file is described as an example in which the server executes the compiling method, specifically, the compiling apparatus of the program file integrated in the server executes the compiling method. Referring to fig. 2, a specific flow of the compiling method of the program file may be as follows:
101. and receiving an original program file uploaded by the terminal, and identifying the type of the original program file.
The type of the original program file uploaded by the terminal may be of multiple types, for example, the type of the original program file may be an interface code file type, an extended program file type, another type, or the like.
The different types of original program files have different corresponding compilation versions in the terminal system, and the type identification can be performed on the original program file uploaded by the terminal, and the compilation version is determined according to the identified type, for example, when the file type identification of the original program file obtains that the type of the original program file is an interface code file type, the corresponding interface compilation version can be selected in the terminal system, and when the type of the original program file is an extension program type, the corresponding extension compilation version can be selected in the terminal system, and the corresponding compilation version is selected to compile the program file to obtain a compiled program file.
In an embodiment, in order to obtain a compiled program file, after determining that the type of an original program file uploaded by a terminal is an extended program type, the original program file may be compiled, which is specifically as follows:
when the type of the original program file is an extension program type, determining a corresponding extension compiling version of the original program file in a terminal system;
and compiling the original program file based on the extended compiling version to obtain a compiled extended program file.
For example, taking an original program file as an extended source code as an example for explanation, an overall usage flow of node.js (an open source code capable of running a programming language at a server side, a cross-platform programming language running environment) extension may be as shown in fig. 3, a terminal may upload a developed extended source code to an online extended compiling platform for compiling, and then may push, download, and upload the extended source code to an extended management platform, and a service may be installed by obtaining the extended source code from the extended platform when in use.
The extension may also be called a plug-in, is a dynamic link shared object written in a programming language (C + +), can be loaded into node.js using a function, and is used like a common node.js module, and is mainly used to provide an interface between a programming language (JavaScript) running in node.js and a C/C + + library.
102. And when the type of the original program file is identified to be the interface code file type, determining the corresponding interface compiling version of the original program file in the terminal system.
The compiling version can be selected according to the type of the uploaded original program file, and when the type of the original program file is the type of the interface code file, the corresponding interface compiling version can be selected.
Referring to fig. 4, a server may be obtained, node.js is installed, an online compiling system is deployed on the server, and the server is started, at this time, a website is input in a browser to access a page of the compiling system as shown in fig. 5, a user may upload an original program file of the user, for example, an original program file of an extended program type or an original program file of an interface code file type, and the like, and then may select a compiled version according to the type of the uploaded original program file, click to edit to compile, and then the system may call a compiling interface program, and when the original program file is an extended program file, a Shell script is executed to run the entire compiling process, first a node.js version to be compiled needs to be downloaded, and a temporary environment variable is set at the same time, a compiling command is executed, and whether the compiled file exists is checked, if the compiled program file exists, whether the compiled program file is available is checked, the final system can regularly check the final state of the compilation, if the state is not returned after a certain time, the compilation is considered to be failed, the compilation result is finally returned to store the compilation result, and a user can directly download the compiled program file on a website.
103. And converting the original program file into a target program file with a target syntax structure based on the interface code file type.
For example, as shown in fig. 4, when the type of the uploaded original program file is the type of the interface program file, a version to be compiled in a web page may be selected as an interface compilation version, then a program compilation interface is called, a code-walking automatic generation logic is called, the original program file is read, and the read original program file is analyzed based on an Abstract Syntax Tree (AST) to generate the object program file with an object syntax structure.
The abstract Syntax tree or Syntax tree for short (Syntax tree) is an abstract representation of a source code Syntax structure, the Syntax structure which becomes a language is represented in a tree form, and each node on the tree represents a structure in the source code.
In one embodiment, in order to convert the original program file into the target original program file with the target syntax structure, the original program file may be subjected to a cutting process, for example, the step of converting the original program file into the target program file with the target syntax structure based on the interface code file type may include:
based on the interface code file type, cutting the original program file according to a preset rule to obtain a cut array;
the array is converted into a target program file of a target syntax structure.
104. And generating a program file to be compiled based on the object program file.
The target program file can be processed to generate a program file to be compiled, and the program to be compiled can be compiled to obtain a required compiled program file after being compiled.
In an embodiment, in order to obtain the program file to be compiled, the specific step "generating the program file to be compiled based on the object program file" may include:
analyzing the target program file to obtain analyzed attribute data information;
and integrating the attribute data information to generate a program file to be compiled.
The method name, the parameter type and the like in the target program file can be analyzed, and then the information is integrated to generate the program file to be compiled.
In an embodiment, the step "integrating the attribute data information to generate a to-be-compiled program file" may include:
acquiring a skeleton code corresponding to the analyzed attribute data information;
and merging the attribute data information and the skeleton code to generate a program file to be compiled.
For example, a corresponding interface template skeleton code, such as an N-api (interface, i.e., an interface for developing a C + + Native module)/Nan (Native Abstraction for node. js, i.e., a node. js Native template Abstraction interface) may be obtained, and then, the analyzed attribute data information and the template skeleton code are merged, so as to finally generate a program file to be compiled.
105. And compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
The compiling is to change a high-level language into a binary language which can be recognized by a computer, the computer only recognizes 1 and 0, and the compiler changes a familiar language into a binary language, for example, the compiler changes a program file to be compiled into a binary program file. For example, a compiler can divide the work process of translating a source program into a target program into five stages: lexical analysis, syntax analysis, semantic checking and intermediate code generation, code optimization, and object code generation. The method mainly comprises the steps of performing lexical analysis and syntactic analysis, namely source program analysis, finding grammatical errors in the analysis process, and giving prompt information.
In an embodiment, the step of compiling the program file to be compiled based on the interface compilation version to obtain a compiled program file may include:
receiving a compiling instruction;
setting a temporary compiling environment parameter based on the interface compiling version to obtain a temporary compiling environment parameter;
and compiling the program file to be compiled according to the compiling instruction and the temporary compiling environment parameter to obtain a compiled program file.
For example, referring to fig. 6, in the embodiment of the present application, manual workshop development may be changed into development implemented by system automation, a compiled version may be selected, a compiled program file may be obtained, and the operation is simpler than before, as shown in fig. 7, a program file cloud compiling platform is accessed in a browser, a user may upload a program file of the user, then select a node.
In an embodiment, in order to ensure that the compiled program file downloaded by the terminal is available, the final state of the compilation may be periodically checked, for example, the following steps may be included:
detecting the state of the compiled program file to obtain a detection result;
receiving a compiled program file acquisition request sent by a terminal;
and sending the compiled program file to the terminal based on the detection result and the compiled program file acquisition request.
For example, checking the compiled program file to check whether the compiled program file exists, if so, checking whether the compiled program file is available, and finally, regularly checking the final state of the compilation, and if not, returning the state for a certain time, considering that the compilation fails, wherein the final compilation state has the following conditions:
Figure BDA0002356134890000091
referring to fig. 8, in some function implementation layers of the main online compiling platform, plug-in modules (addons) are mainly program files uploaded by a user, such as original program files; a software program (Controller, which is a software program running on an independent server, can be realized by various languages, and can run on different operating systems) module mainly changes application programs of some World Wide Web (Web) services provided by the outside into interfaces (api); the program language storage type module (Auto C/C + + module) is a logic implementation for generating a C/C + + interface file and extending a node; a built shell module is used for downloading a node file, setting a temporary environment variable, executing a compiling command and generating an expanded compressed file in the process of executing online compiling; the View control (View) module is the api interface that requests web services via http. And one Server Side Render (SSR) is realized to provide web services for the online compiling platform.
The Server Side rendering (Server Side Render) can be realized by using development languages such as computer programming languages (Java, php) and the like, and with the continuous progress of node.
In one embodiment, the compiled program file may be stored in a blockchain to facilitate subsequent extraction and storage of information, as shown in fig. 9, the computer device may be a node in a distributed system, wherein, the distributed system can be a blockchain system, the blockchain system can be a distributed system formed by connecting a plurality of nodes in a network communication mode, Peer-To-Peer (P2P, Peer To Peer) networks can be formed among the nodes, any type of computer equipment, such as servers, terminals and other electronic equipment can become one node in the blockchain system by joining the Peer-To-Peer network, the Block chain comprises a series of blocks (blocks) which are mutually connected according to the generated chronological order, new blocks cannot be removed once being added into the Block chain, and recorded data submitted by nodes in the Block chain system are recorded in the blocks.
As can be seen from the above, in the embodiment, the version of program compilation is determined by identifying the type of the uploaded original program file, and then the program file to be compiled can be compiled, so that a set of compiling environment is not required to be set up, and the efficiency of program file compilation is high.
Based on the above description, the compiling method of the program file of the present application will be further described below by way of example.
In the embodiments of the present application, a compiler of a program file is integrated in a server as an example. Referring to fig. 10, a specific flow of a compiling method of a program file may be as follows:
201. and the server receives the original program file uploaded by the terminal and identifies the type of the original program file.
For example, the server may identify an original program file uploaded by the terminal, determine that the original program file is in an extended compiled version as shown in fig. 5 when the type of the original program file is identified as an extended program type, and then may click the compiling control to compile the original program file to obtain a compiled program file. When the type of the identified original program file is the interface code file type, the selected compiled version is different.
202. When the type of the original program file is identified to be the type of the interface code file, the server determines the corresponding interface compiling version of the original program file in the terminal system.
For example, referring to fig. 4, when it is recognized that the type of the original program file is an interface code file type, a version that needs to be compiled is selected as an interface compilation version in a web page of the cloud platform, then a program compilation interface is called, a code automatic generation logic is run, the original program file is read, the read original program file is analyzed based on an Abstract Syntax Tree (AST), and an object program file with an object Syntax structure is generated.
203. Based on the interface code file type, the server converts the original program file into an object program file of an object syntax structure.
For example, the server may convert an original program file into a Tree-structured target program file based on an Abstract Syntax Tree (AST).
The abstract syntax tree does not depend on concrete grammar and language details, and after an original program file is converted into the AST, a plurality of operations can be performed on the AST, and the operations can realize various functions. An abstract syntax tree is a tree representation of the abstract syntax structure of the source code, and each node on the tree represents a structure in the source code, which is abstract because the abstract syntax tree does not represent every detail of the real syntax, for example, the nesting brackets are hidden in the structure of the tree and are not represented in the form of nodes. The abstract syntax tree does not depend on the syntax of the source language, that is, the context adopted in the syntax analysis stage has no grammar, because when writing text, the grammar is often equivalently converted (eliminating recursion, backtracking, ambiguity and the like), which introduces some redundant components into the grammar analysis, causes adverse effects on subsequent stages, and even makes the combined stages become chaotic, therefore, many compilers often construct the syntax analysis tree independently, and establish a clear interface for the front end and the back end, and the abstract syntax tree has wide application in many fields, such as browsers, intelligent editors, compilers and the like.
When the type of the original program file is an interface code file type, the original program file can be analyzed based on the AST, the original program file can be cut according to a preset rule to obtain a cut array, and the array is assembled and converted into a target program file with a tree structure.
For example, when the original program file is analyzed based on AST to generate a target program file with a tree-shaped syntax structure, the original program file may be read first, then the original program file is cut according to a predetermined rule, and blank characters, comments, and the like are removed, finally the entire original program file is divided into a near array list to obtain an array, when the original program file is analyzed lexically, a code may be read by one letter, so it is visually called as scans (scans), when a space, an operator, or a special symbol is encountered, a word is considered to have been completed, and finally the array analyzed lexically is converted into a form of a tree-shaped structure to obtain the target program file, and at the same time, a syntax may be verified, and if the syntax has an error, a syntax error is thrown.
204. Based on the object program file, the server generates a program file to be compiled.
For example, the method name, the parameter name, the method return type, the parameter type, and the like of the target program file may be analyzed and stored in the memory, then a corresponding interface template framework, for example, an N-api (interface, i.e., an interface for developing a C + + Native module)/Nan (Native Abstraction for node. js, Native Abstraction abstract interface of node. js) may be obtained, and then the method name, the parameter name, the method return type, the parameter type, and the like stored in the memory may be merged with the framework code in the interface template framework to generate the program file to be compiled.
The skeleton code refers to a code which can be used by writing common methods in the code and modifying the code according to requirements when in use.
205. And compiling the program file to be compiled by the server based on the interface compiling version to obtain a compiled program file.
When a compiling instruction is received, temporary compiling environment parameters can be set based on the interface compiling version, different compiling versions may need to adjust some compiling environment parameters to obtain the temporary compiling environment parameters, and finally, the original program file is compiled according to the compiling instruction and the temporary compiling environment parameters to obtain a compiled program file.
In order to ensure that the compiled program file downloaded by the terminal is available, the state of the compiled program file may be detected after the original program file is compiled, and the following situations may occur in the final state: not compiled; in compiling; if the compiling fails, the compiling state is returned; compiling overtime; the compilation is successful. When the state of the compiled program file is detected to be a compiling success state, sending the compiled original program file to the terminal based on receiving a compiled program file acquisition request sent by the terminal, and if the state of the compiled program file is detected to be a non-compiling state; in compiling; if the compiling fails, the compiling state is returned; when the compilation is timed out, the compiled program file can be processed.
As can be seen from the above, in the embodiment, the version of program compilation is determined by identifying the type of the uploaded original program file, and then the program file to be compiled can be compiled, so that a set of compiling environment is not required to be set up, and the efficiency of program file compilation is high.
In order to better implement the above method, correspondingly, an embodiment of the present application further provides a compiling apparatus for a program file, where the compiling apparatus for the program file may be specifically integrated in a server, and referring to fig. 11, the compiling apparatus for the program file may include a receiving unit 301, a first determining unit 302, a converting unit 303, a generating unit 304, and a first compiling unit 305, as follows:
(1) a receiving unit 301;
the receiving unit 301 is configured to receive an original program file uploaded by a terminal, and identify a type of the original program file.
(2) A first determination unit 302;
a first determining unit 302, configured to determine, when the type of the original program file is identified as the interface code file type, a corresponding interface compilation version of the original program file in the terminal system.
(3) A conversion unit 303;
a converting unit 303, configured to convert the original program file into an object program file with an object syntax structure based on the interface code file type.
In one embodiment, the converting unit 303 includes:
a cutting subunit 3031, configured to cut the original program file according to a preset rule based on the interface code file type, to obtain a cut array;
a conversion subunit 3032, configured to convert the array into a target program file of a target syntax structure.
(4) A generation unit 304;
a generating unit 304, configured to generate a program file to be compiled based on the object program file.
In an embodiment, the generating unit 304 includes:
an analysis subunit 3041, configured to analyze the target program file to obtain attribute data information after analysis;
the integrating subunit 3042 is configured to integrate the attribute data information to generate a program file to be compiled.
In an embodiment, the integrating subunit 3042 is further configured to obtain a skeleton code corresponding to the analyzed attribute data information; and merging the attribute data information and the skeleton code to generate a program file to be compiled.
(5) A first compiling unit 305;
the first compiling unit 305 is configured to compile the program file to be compiled based on the interface compilation version to obtain a compiled program file.
In an embodiment, the first compiling unit 305 includes:
a first receiving subunit 3051, configured to receive a compiling instruction;
a setting subunit 3052, configured to set a temporary compiling environment parameter based on the interface compiling version, so as to obtain a temporary compiling environment parameter;
and the compiling subunit 3053, configured to compile the program file to be compiled according to the compiling instruction and the temporary compiling environment parameter, to obtain a compiled program file.
In an embodiment, the compiling subunit 3053 further includes:
a detection subunit 3054, configured to detect a state of the compiled program file, to obtain a detection result;
a second receiving subunit 3055, configured to receive a compiled program file acquisition request sent by the terminal;
a sending subunit 3056, configured to send the compiled program file to the terminal based on the detection result and the compiled program file obtaining request.
In an embodiment, as shown in fig. 12, the compiling apparatus for the program file further includes:
a second determining unit 306, configured to determine, when the type of the original program file is an extended program type, an extended compiled version of the original program file corresponding to the terminal system;
a second compiling unit 307, configured to compile the original program file based on the extended compiled version to obtain a compiled extended program file.
As can be seen from the above, in the compiling apparatus for program files according to the embodiment of the present application, the receiving unit 301 receives an original program file uploaded by a terminal, and identifies the type of the original program file; then, when the type of the original program file is identified as the type of the interface code file, the first determining unit 302 determines the corresponding interface compilation version of the original program file in the terminal system; converting, by the converting unit 303, the original program file into an object program file of an object syntax structure based on the interface code file type; generating, by the generating unit 304, a program file to be compiled based on the object program file; the first compiling unit 305 compiles the program file to be compiled based on the interface compiling version to obtain a compiled program file. According to the scheme, the edition of program compiling can be determined by identifying the type of the uploaded original program file, then the program file to be compiled can be compiled, a set of compiling environment does not need to be set up, and the efficiency of program file compiling is high.
In addition, an embodiment of the present application further provides a computer device, where the computer device may be a server or a terminal, and as shown in fig. 13, a schematic structural diagram of the computer device according to the embodiment of the present application is shown, specifically:
the computer device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 13 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby monitoring the computer device as a whole. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The computer device further comprises a power supply 403 for supplying power to the various components, and preferably, the power supply 403 is logically connected to the processor 401 via a power management system, so that functions of managing charging, discharging, and power consumption are implemented via the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The computer device may also include an input unit 404, the input unit 404 being operable to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the computer device loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
receiving an original program file uploaded by a terminal, and identifying the type of the original program file; when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system; converting the original program file into a target program file with a target syntax structure based on the interface code file type; generating a program file to be compiled based on the object program file; and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
For the above embodiments, reference may be made to the foregoing embodiments, and details are not described herein.
In one embodiment, as shown in fig. 9, the computer device may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication form. The nodes may form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computer device, such as a server, a terminal, and other electronic devices, may become a node in the blockchain system by joining the Peer-To-Peer network.
Therefore, the embodiment can determine the version of program compiling by identifying the type of the uploaded original program file, and then compile the program file to be compiled, so that a set of compiling environment is not required to be set up, and the efficiency of compiling the program file is high.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the compiling methods of the program files provided in the present application. For example, the instructions may perform the steps of:
receiving an original program file uploaded by a terminal, and identifying the type of the original program file; when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system; converting the original program file into a target program file with a target syntax structure based on the interface code file type; generating a program file to be compiled based on the object program file; and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
The above detailed implementation of each operation can refer to the foregoing embodiments, and is not described herein again.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium can execute the steps in any method for compiling a program file provided in the embodiment of the present application, the beneficial effects that can be achieved by any method for compiling a program file provided in the embodiment of the present application can be achieved, which are detailed in the foregoing embodiments and will not be described again here.
The above details are provided for a method, an apparatus and a computer-readable storage medium for compiling a program file provided in the embodiments of the present application, and a specific example is applied in the present application to explain the principles and embodiments of the present application, and the description of the above embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for compiling a program file, comprising:
receiving an original program file uploaded by a terminal, and identifying the type of the original program file;
when the type of the original program file is identified to be an interface code file type, determining a corresponding interface compiling version of the original program file in a terminal system;
converting the original program file into a target program file of a target syntax structure based on the interface code file type;
generating a program file to be compiled based on the target program file;
and compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
2. The method of claim 1, wherein generating a program file to be compiled based on the object program file comprises:
analyzing the target program file to obtain analyzed attribute data information;
and integrating the attribute data information to generate a program file to be compiled.
3. The method of claim 2, wherein integrating the attribute data information to generate a program file to be compiled comprises:
acquiring a skeleton code corresponding to the analyzed attribute data information;
and merging the attribute data information and the skeleton code to generate a program file to be compiled.
4. The method of claim 1, wherein converting the original program file into an object program file of an object syntax structure based on the interface code file type comprises:
based on the interface code file type, cutting the original program file according to a preset rule to obtain a cut array;
and converting the array into a target program file of a target syntax structure.
5. The method of claim 1, wherein compiling the program file to be compiled based on the compiled version to obtain a compiled program file comprises:
receiving a compiling instruction;
setting temporary compiling environment parameters based on the interface compiling version to obtain temporary compiling environment parameters;
and compiling the program file to be compiled according to the compiling instruction and the temporary compiling environment parameter to obtain a compiled program file.
6. The method according to claim 5, wherein after the program file to be compiled is compiled according to the compiling instruction and the temporary compiling environment parameter to obtain a compiled program file, the method further comprises:
detecting the state of the compiled program file to obtain a detection result;
receiving a compiled program file acquisition request sent by a terminal;
and sending the compiled program file to the terminal based on the detection result and the compiled program file acquisition request.
7. The method of claim 1, wherein after identifying the type of the original program file, the method further comprises:
when the type of the original program file is an extension program type, determining a corresponding extension compiling version of the original program file in a terminal system;
and compiling the original program file based on the extended compiling version to obtain a compiled extended program file.
8. The method of claim 1, further comprising:
and storing the compiled program file into a block chain.
9. An apparatus for compiling a program file, comprising:
the receiving unit is used for receiving an original program file uploaded by a terminal and identifying the type of the original program file;
the first determining unit is used for determining an interface compiling version corresponding to the original program file in a terminal system when the type of the original program file is identified to be an interface code file type;
the conversion unit is used for converting the original program file into a target program file with a target syntax structure based on the interface code file type;
the generating unit is used for generating a program file to be compiled based on the target program file;
and the first compiling unit is used for compiling the program file to be compiled based on the interface compiling version to obtain a compiled program file.
10. A computer-readable storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the steps of the method for compiling a program file according to any one of claims 1 to 8.
CN202010008323.0A 2020-01-06 2020-01-06 Method and apparatus for compiling program file, and computer-readable storage medium Active CN111209005B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010008323.0A CN111209005B (en) 2020-01-06 2020-01-06 Method and apparatus for compiling program file, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010008323.0A CN111209005B (en) 2020-01-06 2020-01-06 Method and apparatus for compiling program file, and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN111209005A true CN111209005A (en) 2020-05-29
CN111209005B CN111209005B (en) 2021-07-23

Family

ID=70789454

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010008323.0A Active CN111209005B (en) 2020-01-06 2020-01-06 Method and apparatus for compiling program file, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN111209005B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269565A (en) * 2020-10-30 2021-01-26 杭州电子科技大学 Container-based edge device operation method, device and system
CN112506519A (en) * 2020-12-15 2021-03-16 Oppo广东移动通信有限公司 Compiling method of application program, mobile terminal and server
CN112596751A (en) * 2020-12-29 2021-04-02 Oppo广东移动通信有限公司 Compiling method, terminal, server and storage medium of application program installation package
CN112650502A (en) * 2020-12-31 2021-04-13 广州方硅信息技术有限公司 Batch processing task processing method and device, computer equipment and storage medium
CN112822193A (en) * 2021-01-05 2021-05-18 网易(杭州)网络有限公司 Application communication method, device, equipment and storage medium
CN112882718A (en) * 2021-02-26 2021-06-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN113110873A (en) * 2021-05-10 2021-07-13 中国建设银行股份有限公司 Method and apparatus for unifying system coding specifications
CN113127001A (en) * 2021-04-28 2021-07-16 上海米哈游璃月科技有限公司 Code compiling process monitoring method, device, equipment and medium
CN113742008A (en) * 2021-09-13 2021-12-03 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN116069304A (en) * 2023-04-06 2023-05-05 紫光同芯微电子有限公司 Program data generation method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101216776A (en) * 2008-01-15 2008-07-09 中兴通讯股份有限公司 Method and system for automatically creating translation and compiling environment
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
US20140189664A1 (en) * 2009-10-20 2014-07-03 Russell WAYNE Guenthner METHOD FOR ENABLING COMPILATION OF A COBOL SOURCE PROGRAM UTILIZING A TWO-STAGE COMPILATION PROCESS, THE COBOL SOURCE PROGRAM INCLUDING A MIX OF COBOL, C++ or JAVA STATEMENTS, AND OPTIONAL OPENMP DIRECTIVES
CN105700934A (en) * 2016-02-19 2016-06-22 陕西瑞亚智能技术有限公司 Intelligent compiling method and intelligent compiling system
CN107766048A (en) * 2017-10-23 2018-03-06 山东浪潮通软信息科技有限公司 A kind of pagecompile method and device
CN109918081A (en) * 2019-03-01 2019-06-21 中安智联未来有限公司 A kind of Compilation Method and compiler
CN109976748A (en) * 2019-02-28 2019-07-05 南京南瑞继保电气有限公司 A kind of program processing method, terminal, server and computer storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101216776A (en) * 2008-01-15 2008-07-09 中兴通讯股份有限公司 Method and system for automatically creating translation and compiling environment
US20140189664A1 (en) * 2009-10-20 2014-07-03 Russell WAYNE Guenthner METHOD FOR ENABLING COMPILATION OF A COBOL SOURCE PROGRAM UTILIZING A TWO-STAGE COMPILATION PROCESS, THE COBOL SOURCE PROGRAM INCLUDING A MIX OF COBOL, C++ or JAVA STATEMENTS, AND OPTIONAL OPENMP DIRECTIVES
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
CN105700934A (en) * 2016-02-19 2016-06-22 陕西瑞亚智能技术有限公司 Intelligent compiling method and intelligent compiling system
CN107766048A (en) * 2017-10-23 2018-03-06 山东浪潮通软信息科技有限公司 A kind of pagecompile method and device
CN109976748A (en) * 2019-02-28 2019-07-05 南京南瑞继保电气有限公司 A kind of program processing method, terminal, server and computer storage medium
CN109918081A (en) * 2019-03-01 2019-06-21 中安智联未来有限公司 A kind of Compilation Method and compiler

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269565A (en) * 2020-10-30 2021-01-26 杭州电子科技大学 Container-based edge device operation method, device and system
CN112506519A (en) * 2020-12-15 2021-03-16 Oppo广东移动通信有限公司 Compiling method of application program, mobile terminal and server
CN112596751A (en) * 2020-12-29 2021-04-02 Oppo广东移动通信有限公司 Compiling method, terminal, server and storage medium of application program installation package
CN112596751B (en) * 2020-12-29 2024-05-17 Oppo广东移动通信有限公司 Compiling method, terminal, server and storage medium of application program installation package
CN112650502A (en) * 2020-12-31 2021-04-13 广州方硅信息技术有限公司 Batch processing task processing method and device, computer equipment and storage medium
CN112822193A (en) * 2021-01-05 2021-05-18 网易(杭州)网络有限公司 Application communication method, device, equipment and storage medium
CN112882718B (en) * 2021-02-26 2024-03-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN112882718A (en) * 2021-02-26 2021-06-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN113127001A (en) * 2021-04-28 2021-07-16 上海米哈游璃月科技有限公司 Code compiling process monitoring method, device, equipment and medium
CN113127001B (en) * 2021-04-28 2024-03-08 上海米哈游璃月科技有限公司 Method, device, equipment and medium for monitoring code compiling process
CN113110873A (en) * 2021-05-10 2021-07-13 中国建设银行股份有限公司 Method and apparatus for unifying system coding specifications
CN113742008B (en) * 2021-09-13 2024-04-02 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN113742008A (en) * 2021-09-13 2021-12-03 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN116069304A (en) * 2023-04-06 2023-05-05 紫光同芯微电子有限公司 Program data generation method and device

Also Published As

Publication number Publication date
CN111209005B (en) 2021-07-23

Similar Documents

Publication Publication Date Title
CN111209005B (en) Method and apparatus for compiling program file, and computer-readable storage medium
CN106547527B (en) JavaScript file construction method and device
US20060265469A1 (en) XML based scripting framework, and methods of providing automated interactions with remote systems
CN111399840B (en) Module development method and device
JP2018530070A (en) System and method for building, optimizing and implementing a platform on a cloud-based computing environment
EP2510433B1 (en) Canonicalized versions of reuse candidates in graphical state diagrams
CN110673923A (en) XWIKI system configuration method, system and computer equipment
CN114077534B (en) Test case generation method, device and computer readable storage medium
CN112035443B (en) Big data execution method, system, equipment and storage medium based on Linux platform
CN115169810A (en) Artificial intelligence system construction method and device for power grid regulation
CN113778445A (en) Cross-platform component generation method and device, electronic equipment and storage medium
CN110362792B (en) Method and device for converting RN file into applet file and conversion equipment
CN111767217A (en) JS unit test case generation method and device
US10810022B2 (en) Executable configuration template language
CN109388406A (en) Convert method and device, the storage medium, electronic device of java code
CN113360156B (en) IOS compiling method and related equipment
CN115202663A (en) Data processing method, device and storage medium
CN113377342B (en) Project construction method and device, electronic equipment and storage medium
CN113515303A (en) Project transformation method, device and equipment
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
CN110362317B (en) Code conversion method, device and storage medium
CN115794253A (en) Application integration method and device, electronic equipment and computer readable storage medium
CN112148392A (en) Function call chain acquisition method and device and storage medium
CN113297081B (en) Execution method and device of continuous integrated pipeline
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant