Compiling method and device, electronic equipment, storage medium and product
By obtaining the configuration information of the target program, determining the language category, and generating compilation commands, the problems of low efficiency and poor applicability of multilingual compilation in existing technologies are solved, and automated multilingual compilation and execution are realized.
Patent Information
- Application Number
- CN202510978911.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-07-16
AI Technical Summary
Existing compilation methods are inefficient and have poor applicability in multi-language compilation scenarios. The local compilation method for the default language is limited, and the compilation operation of switching between multiple plugins is complex.
By obtaining the configuration information of the target program, determining its language category, and using the configuration information to assign values to the configuration parameters of the compilation toolchain, the target compilation command is generated, enabling automatic compilation and execution of target programs of different language categories.
It simplifies the compilation process, improves compilation efficiency and applicability in multilingual environments, and reduces the complexity of user operations.
Smart Images

Figure CN120491976B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of code compilation technology, and in particular to a compilation method, apparatus, electronic device, storage medium, and product. Background Technology
[0002] In existing integrated development environments (IDEs), the compilation function typically only supports a single language or a single platform.
[0003] Existing compilation solutions include the following: 1. Preset language local compilation: Some IDEs lock the languages they support. In this case, users only need to specify the environment directory to debug according to the pre-defined debugging scheme. 2. Multi-plugin switching compilation: To be compatible with more languages, users can install multiple plugins to adapt to different languages and their compilation requirements. This approach usually involves dozens of plugins to meet user needs, thus providing more diverse compilation services.
[0004] The default local compilation method offers a limited range of compilation types, failing to meet diverse compilation needs. Switching between multiple plugins for compilation involves complex configuration steps and is therefore quite challenging for users.
[0005] In summary, existing compilation methods are inefficient and have poor applicability in multi-language compilation scenarios. Summary of the Invention
[0006] This invention provides a compilation method, apparatus, electronic device, storage medium, and product to address the shortcomings of existing compilation methods in multilingual compilation scenarios, such as low efficiency and poor applicability, and to achieve automatic compilation and execution of target programs.
[0007] This invention provides a compilation method, comprising the following steps:
[0008] In response to the instructions to compile and run code, obtain the configuration information of the target program;
[0009] Based on the language information in the configuration information, determine the language category of the target program;
[0010] The compiler toolchain configuration parameters in the compiler command are determined based on the language category, and the corresponding compiler toolchain configuration parameters in the compiler command are assigned values using the configuration information to generate the target compiler command for the target program.
[0011] Execute the target compilation command to compile the target program into an executable program, and then run the executable program.
[0012] According to a compilation method provided by the present invention, the target program is a compiled language or a semi-compiled and semi-interpreted language.
[0013] The compiler toolchain configuration parameters in the compiler command are determined based on the language category, and the corresponding compiler toolchain configuration parameters in the compiler command are assigned values using the configuration information to generate the target compiler command for the target program, including:
[0014] If the target program's language category is a compiled language, then the compilation toolchain configuration parameters in the compilation command are determined to be the first compilation toolchain configuration parameters; the configuration information is used to assign values to the first compilation toolchain configuration parameters to generate the target compilation command for the target program; the first compilation toolchain configuration parameters include the toolchain type, the toolchain root directory, and the header file directory;
[0015] If the target program's language category is a semi-compiled, semi-interpreted language, then the compiler toolchain configuration parameters in the compilation command are determined to be the second compiler toolchain configuration parameters; the configuration information is used to assign values to the second compiler toolchain configuration parameters to generate the target compilation command for the target program; the second compiler toolchain configuration parameters do not include the toolchain type, toolchain root directory, and header file directory.
[0016] According to a compilation method provided by the present invention, if the target program's language category is a compiled language, a target compilation command is executed to compile the target program into an executable program, and the executable program is run, including:
[0017] Make sure the simulator name in the configuration information is empty, then execute the compilation command through the console terminal to compile the target program into an executable program;
[0018] Execute the executable program via the console.
[0019] According to a compilation method provided by the present invention, if the language category of the target program is a semi-compiled and semi-interpreted language, the compilation toolchain configuration parameters in the compilation command are determined to be second compilation toolchain configuration parameters; the second compilation toolchain configuration parameters are assigned values using configuration information to generate the target compilation command for the target program, including:
[0020] If the target program's language category is a semi-compiled and semi-interpreted language, then the compilation type of the target program is determined as either local compilation or non-local compilation based on the simulator name in the configuration information.
[0021] If the compilation type of the target program is local compilation, then the compilation toolchain configuration parameters in the compilation command are determined to be the third compilation toolchain configuration parameters; the configuration information is used to assign values to the third compilation toolchain configuration parameters to generate the target compilation command for the target program; the third compilation toolchain configuration parameters do not include the emulator installation location, emulator name, and system root directory;
[0022] If the compilation type of the target program is non-local compilation, then the compilation toolchain configuration parameters in the compilation command are determined to be the fourth compilation toolchain configuration parameters; the configuration information is used to assign values to the fourth compilation toolchain configuration parameters to generate the target compilation command for the target program; the fourth compilation toolchain configuration parameters include the emulator installation location, emulator name, and system root directory.
[0023] According to a compilation method provided by the present invention, before obtaining the configuration information of the target program, the compilation method further includes:
[0024] Receive configuration information from the target program through a custom interface;
[0025] In response to receiving a storage instruction, the configuration information is stored as a configuration file.
[0026] According to a compilation method provided by the present invention, before obtaining the configuration information of the target program, the compilation method further includes:
[0027] Identify an active text editor, obtain its filename, and output the filename to the console.
[0028] The present invention also provides a compilation apparatus, comprising the following modules:
[0029] The configuration information acquisition module is used to acquire the configuration information of the target program in response to the code compilation and execution instructions;
[0030] The language type determination module is used to determine the language category of the target program based on the language type information in the configuration information;
[0031] The compilation command generation module is used to determine the compilation toolchain configuration parameters in the compilation command according to the language category, and to assign values to the corresponding compilation toolchain configuration parameters in the compilation command using the configuration information, thereby generating the target compilation command for the target program.
[0032] The compilation and execution module is used to execute the target compilation command, compile the target program into an executable program, and run the executable program.
[0033] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the compilation methods described above.
[0034] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the compilation methods described above.
[0035] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the compilation methods described above.
[0036] The compilation method, apparatus, electronic device, storage medium, and product provided by this invention can determine the language category of a target program by obtaining the language type information in the configuration information of the target program; then, based on the language category of the target program, the compilation toolchain configuration parameters in the compilation command corresponding to the target program are assigned values using the configuration information, thereby generating the compilation command corresponding to the target program; thus, by executing the compilation command and running the executable code, the task of compiling target programs of different language categories can be achieved, solving the defects of low efficiency and poor applicability of existing compilation methods in multi-language compilation scenarios. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0038] Figure 1 This is one of the flowcharts of the compilation method provided by the present invention.
[0039] Figure 2 This is the second flowchart of the compilation method provided by the present invention.
[0040] Figure 3 This is the third flowchart of the compilation method provided by this invention.
[0041] Figure 4 This is the fourth flowchart of the compilation method provided by this invention.
[0042] Figure 5 This is a schematic diagram of the structure of the compilation device provided by the present invention.
[0043] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0045] In existing compilation methods, local compilation for a preset language does not meet the needs of multi-language compilation. On the other hand, using a multi-plugin model to support multi-language compilation places high demands on users, makes the compilation process complex, and results in low compilation efficiency.
[0046] The compilation method, apparatus, electronic device, storage medium, and product provided by this invention can determine the language category of a target program by obtaining the language type information in the configuration information of the target program; then, based on the language category of the target program, the compilation toolchain configuration parameters in the compilation command corresponding to the target program are assigned values using the configuration information, thereby generating the compilation command corresponding to the target program; thus, by executing the compilation command and running the executable code, the task of compiling target programs of different language categories can be achieved, solving the defects of low efficiency and poor applicability of existing compilation methods in multi-language compilation scenarios.
[0047] Figure 1 This is one of the flowcharts illustrating the compilation method provided by this invention, such as... Figure 1 As shown, the method includes the following:
[0048] Step 101: In response to the code compilation and execution instructions, obtain the configuration information of the target program;
[0049] In one embodiment, the compile and run code instruction is a common startup instruction in the IDE. Upon receiving the compile and run code instruction, the IDE initiates the compilation task for the target program. Taking an IDE based on the Reduced Instruction Set Computer-V (RISC-V) architecture as an example, its compile and run code instruction can be represented as RISC-V Compile and Run Code.
[0050] In one embodiment, a user can send a compile and run code command to the IDE by clicking the corresponding button in the IDE user interface. The IDE receives and responds to the compile and run code command and starts the compilation task for the target program.
[0051] In one embodiment, configuration information is metadata that must be generated during the conversion of source code into an executable file; it is essential information for compilation. Users can input specific configuration information through relevant operations on the IDE user interface, or through a user settings interface used to collect configuration information. The user settings interface can be pre-built and can provide users with a customizable interface, allowing them to input personalized configuration information according to their compilation needs. The configuration information can also be pre-saved by the user or other users in the form of a configuration file. When needed, the required configuration information can be retrieved simply from the configuration file.
[0052] Step 102: Determine the language category of the target program based on the language information in the configuration information;
[0053] In one embodiment, the configuration information typically includes toolchain executable directory information, debugger installation directory information, debugger name information, compiler custom command information, debug module option information, debug port information, virtual machine debug command information, language information, remote hardware IP information, executable file storage directory information, virtual machine custom command information, virtual machine installation location information, virtual machine name information, system root path information, toolchain type information, compiler name information, middleware command information, emulator installation location information, emulator name information, etc. It should be noted that because different language categories have different compilation requirements, the above configuration information is not required for all compilation tasks.
[0054] Taking compiled languages as an example, because compiled languages are typically compiled into executable code that can run on the target platform in one go, and are directly called by the operating system during execution without the need for an intermediate layer, target programs of compiled language categories usually require configuration information such as toolchain type information, toolchain root directory information, and header file directory information during compilation. Specifically, the toolchain type information specifies the target platform architecture (e.g., ARM, x86), generating executable code compatible with specific hardware. The toolchain root directory information is used to locate the root path of the basic tools that the compiler depends on (such as the linker and assembler), ensuring that toolchain components are called correctly. The header file directory information instructs the compiler on which paths to search for header files referenced by #include directives in the code. It is important to note that, in addition to the above configuration information such as toolchain type information, toolchain root directory information, and header file directory information, target programs of compiled language categories also require compiler name information common to other languages, toolchain executable file directory information, compiler custom command information, system root path information, executable file storage directory information, and system root directory information during compilation.
[0055] Taking semi-compiled and semi-interpreted languages as an example, since these languages first convert the target program into platform-independent intermediate code (such as Java bytecode) instead of directly generating executable code, there is no need to specify the toolchain type during compilation, because the intermediate code does not depend on a specific hardware architecture. Furthermore, since the toolchain is usually bundled with a virtual machine (such as Java) and its path is managed by the virtual machine, there is no need to specify the toolchain root directory. Similarly, the language standard library of semi-compiled and semi-interpreted languages is automatically loaded by the virtual machine, so there is no need to specify the header file directory.
[0056] Taking interpreted languages as an example, since interpreted languages can be executed directly by the interpreter without compilation, this invention does not limit the types of interpreted languages.
[0057] Step 103: Determine the compilation toolchain configuration parameters in the compilation command according to the language category, and use the configuration information to assign values to the corresponding compilation toolchain configuration parameters in the compilation command to generate the target compilation command for the target program;
[0058] In one embodiment, although different language categories correspond to different compilation commands, the compilation commands are all composed of compilation toolchain configuration parameters in a specific format. Therefore, after determining the compilation toolchain configuration parameters in the compilation command according to the language category, the configuration information is used to assign values to the corresponding compilation toolchain configuration parameters in the compilation command, thereby generating the target compilation command for the target program.
[0059] Step 104: Execute the target compilation command to compile the target program into an executable program and run the executable program.
[0060] The compilation method, apparatus, electronic device, storage medium, and product provided by this invention can determine the language category of a target program by obtaining the language type information in the configuration information of the target program; then, based on the language category of the target program, the compilation toolchain configuration parameters in the compilation command corresponding to the target program are assigned values using the configuration information, thereby generating the compilation command corresponding to the target program; thus, by executing the compilation command and running the executable code, the task of compiling target programs of different language categories can be achieved, solving the defects of low efficiency and poor applicability of existing compilation methods in multi-language compilation scenarios.
[0061] In one embodiment, based on the description in step 102, it is known that:
[0062] The target program can be a compiled language or a semi-compiled / semi-interpreted language;
[0063] Correspondingly,
[0064] Depending on the language category of the target program, such as Figure 2 As shown, step 103 may include the following steps:
[0065] Step 201: If the target program's language category is a compiled language, then determine the compilation toolchain configuration parameters in the compilation command as the first compilation toolchain configuration parameters; assign values to the first compilation toolchain configuration parameters using the configuration information, and generate the target compilation command for the target program; the first compilation toolchain configuration parameters include the toolchain type, toolchain root directory, and header file directory;
[0066] In one embodiment, based on the description in step 102, the first compiler toolchain configuration parameters include the compiler name, toolchain executable file directory, toolchain type, compiler custom commands, system root path, header file directory, toolchain root directory, and executable file storage directory. Correspondingly:
[0067] If the toolchain type is not empty, register the "target version parameter", i.e.: --target= {Toolchain type}, if the toolchain type is empty, then register the "target version parameter" as empty;
[0068] If the system root path is not empty, then register the "system root parameter", i.e.: --sysroot= {System root path}, if the system root path is empty, then register "system root parameter" as empty;
[0069] If the header file directory is not empty, then register the "header file parameters", that is: - {header file directory}, if the header file directory is empty, then register "header file parameters" as empty.
[0070] If the toolchain root directory is not empty, register a "toolchain directory parameter", namely: --gcc-toolchain= {Toolchain root directory}, if the toolchain root directory is empty, then register the "Toolchain directory parameter" as empty;
[0071] The final output will look like this: {Toolchain Executable Files Directory} / {Compiler Name} {Compiler Custom Commands} {Target version parameter} {System Root Parameters} {Header file parameters} {Toolchain Directory Parameters} {Directory where executable files are stored} / The target compilation command is {filename}. Note that the filename refers to the filename of the target program located in the open text editor.
[0072] Step 202: If the target program's language category is a semi-compiled and semi-interpreted language, then determine the compiler toolchain configuration parameters in the compilation command as the second compiler toolchain configuration parameters; use the configuration information to assign values to the second compiler toolchain configuration parameters, and generate the target compilation command for the target program; the second compiler toolchain configuration parameters do not include the toolchain type, toolchain root directory, and header file directory.
[0073] In one embodiment, since current semi-compiled / semi-interpreted languages are typically developed based on Java or .NET languages, their default interpreter is the Java or .NET interpreter. In this case, if the emulator name information in the configuration details corresponds to java, jvm, or dotent, the target program is determined to be compiled locally; if the emulator name information in the configuration details does not correspond to java, jvm, or dotent, the target program is determined to be compiled non-locally, i.e., using a virtual platform for simulation. Therefore, when the target program is compiled non-locally, its second compilation toolchain configuration parameters should also include the emulator installation location, emulator name, and system root directory.
[0074] Therefore, when the target program uses a semi-compiled, semi-interpreted language and the compilation method is local compilation, the second compiler toolchain configuration parameters include the compiler name, compiler-defined commands, toolchain executable file directory, and executable file directory. The target compilation command generated after assigning values to the second compiler toolchain configuration parameters using the configuration information looks like this: {Toolchain Executable Files Directory} / {Compiler Name} {Compiler Custom Commands} {Directory where executable files are stored} / {filename}. When the target program uses a semi-compiled, semi-interpreted language and the compilation method is non-local compilation, the second compiler toolchain configuration parameters include the emulator name, system root directory, compiler name, emulator installation location, toolchain executable file directory, executable file storage directory, and compiler-defined commands. The target compilation command generated after assigning values to the second compiler toolchain configuration parameters using the configuration information is as follows: {Emulator installation location} / {emulator name}- {System Root Directory} {Toolchain executable directory} / {Compiler Name} {Compiler Custom Commands} {Directory where executable files are stored} / {file name}.
[0075] The solutions provided in steps 201 to 202, based on determining the language category of the target program, can simplify the configuration of the compilation toolchain configuration parameters in the compilation command, and at the same time automatically assign values to the compilation toolchain configuration parameters in the compilation command using configuration information, further improving compilation efficiency and applicability in multi-language environments.
[0076] Furthermore, based on the description in step 202, such as Figure 3As shown, step 202 may include the following steps:
[0077] Step 301: If the target program's language category is a semi-compiled and semi-interpreted language, then determine whether the target program's compilation type is local compilation or non-local compilation based on the simulator name in the configuration information.
[0078] In one embodiment, since current semi-compiled and semi-interpreted languages are typically developed based on Java or .NET languages, their default interpreter is the Java or .NET interpreter. In this case, if the emulator name in the configuration information corresponds to java, jvm, or dotent, the target program is determined to be compiled locally; if the emulator name in the configuration information does not correspond to java, jvm, or dotent, the target program is determined to be compiled non-locally, i.e., using a virtual platform for simulation.
[0079] Step 302: If the compilation type of the target program is local compilation, then determine that the compilation toolchain configuration parameters in the compilation command are the third compilation toolchain configuration parameters; use the configuration information to assign values to the third compilation toolchain configuration parameters, and generate the target compilation command for the target program;
[0080] In one embodiment, the third compiler toolchain configuration parameters do not include the emulator installation location, emulator name, and system root directory;
[0081] Step 303: If the compilation type of the target program is non-local compilation, then determine that the compilation toolchain configuration parameter in the compilation command is the fourth compilation toolchain configuration parameter; use the configuration information to assign values to the fourth compilation toolchain configuration parameter, and generate the target compilation command for the target program.
[0082] In one embodiment, the fourth compiler toolchain configuration parameters include the emulator installation location, emulator name, and system root directory.
[0083] The solutions provided in steps 301 to 303, based on determining that the language category is a semi-compiled and semi-interpreted language, determine whether the compilation type is local compilation or non-local compilation by the name of the simulator; and then determine the compilation toolchain configuration parameters required for local compilation and non-local compilation, further simplifying the configuration of compilation toolchain configuration parameters in the compilation command and improving compilation efficiency.
[0084] In one embodiment, when the language category is a compiled language, the executable code generated after compiling the target program using the compilation command may run directly in the local development environment, such as running directly on the local computer environment; or it may run on a specified emulator. Therefore, if the target program's language category is a compiled language, then as follows: Figure 4As shown, step 104 may include the following steps:
[0085] Step 401: Ensure that the simulator name in the configuration information is empty, and execute the compilation command through the console terminal to compile the target program into an executable program;
[0086] In one embodiment, if the emulator name is empty, it means that the executable program is executed in the local environment, that is, it can be executed through the console terminal.
[0087] Step 402: Execute the executable program via the console.
[0088] In one embodiment, since step 401 has already completed the compilation of the target program, i.e., generated executable code, the executable code can be executed directly via the console. Alternatively, the executable code can be executed via the console by manually entering commands, such as: {Directory where executable files are stored} / {filename}; that is, execute the executable file located in the directory path where the executable file is located.
[0089] The solution shown in steps 401 to 402 can skip the emulator configuration based on the emulator name and directly execute the executable file through the console, simplifying the execution process and further improving compilation efficiency.
[0090] In one embodiment, in step 104, the execution result of the executable program can be displayed through a terminal window.
[0091] In one embodiment, prior to step 101, the compilation method provided by the present invention further includes:
[0092] Receive configuration information from the target program through a custom interface;
[0093] In response to receiving a storage instruction, the configuration information is stored as a configuration file.
[0094] Among these features, a user settings interface can be built on the IDE to provide a custom interface for users to customize configuration information, so as to adapt to the compilation needs of different users and different languages.
[0095] After entering configuration information through the user settings interface, users can save the configuration information as a configuration file by clicking the save button on the IDE interface or using the save shortcut. When the same configuration information is needed for compilation again, there is no need to manually enter the configuration information; it can be retrieved from the configuration file, further improving compilation efficiency.
[0096] In one embodiment, since users typically open the target program through a text editor when compiling it, in order to avoid errors in the configuration information manually entered by the user, such as incorrect filenames, the IDE will also determine whether an active text editor exists. If it does, the IDE will obtain the filename of the text editor and output the filename to the console.
[0097] Based on this, prior to step 101, the compilation method provided by this invention further includes:
[0098] Identify an active text editor, obtain its filename, and output the filename to the console.
[0099] The compilation apparatus provided by the present invention is described below. The compilation apparatus described below and the compilation method described above can be referred to in correspondence.
[0100] like Figure 5 As shown, the compilation apparatus 500 provided by the present invention includes the following modules:
[0101] The configuration information acquisition module 501 is used to acquire the configuration information of the target program in response to the code compilation and execution instructions;
[0102] The language type determination module 502 is used to determine the language category of the target program based on the language type information in the configuration information;
[0103] The compilation command generation module 503 is used to determine the compilation toolchain configuration parameters in the compilation command according to the language category, and to assign values to the corresponding compilation toolchain configuration parameters in the compilation command using the configuration information to generate the target compilation command for the target program.
[0104] Compile and run module 504, which executes the target compilation command, compiles the target program into an executable program, and runs the executable program.
[0105] In one embodiment, the target program is a compiled language or a semi-compiled / semi-interpreted language;
[0106] Correspondingly, the compilation command generation module 503 is specifically used for:
[0107] If the target program's language category is a compiled language, then the compilation toolchain configuration parameters in the compilation command are determined to be the first compilation toolchain configuration parameters; the configuration information is used to assign values to the first compilation toolchain configuration parameters to generate the target compilation command for the target program; the first compilation toolchain configuration parameters include the toolchain type, the toolchain root directory, and the header file directory;
[0108] If the target program's language category is a semi-compiled, semi-interpreted language, then the compiler toolchain configuration parameters in the compilation command are determined to be the second compiler toolchain configuration parameters; the configuration information is used to assign values to the second compiler toolchain configuration parameters to generate the target compilation command for the target program; the second compiler toolchain configuration parameters do not include the toolchain type, toolchain root directory, and header file directory.
[0109] In one embodiment, if the target program's language type is a compiled language, then the compile and run module 504 is specifically used for:
[0110] Make sure the simulator name in the configuration information is empty, then execute the compilation command through the console terminal to compile the target program into an executable program;
[0111] Execute the executable program via the console.
[0112] In one embodiment, the compilation command generation module 503 is further specifically used for:
[0113] If the target program's language category is a semi-compiled and semi-interpreted language, then the compilation type of the target program is determined as either local compilation or non-local compilation based on the simulator name in the configuration information.
[0114] If the compilation type of the target program is local compilation, then the compilation toolchain configuration parameters in the compilation command are determined to be the third compilation toolchain configuration parameters; the configuration information is used to assign values to the third compilation toolchain configuration parameters to generate the target compilation command for the target program; the third compilation toolchain configuration parameters do not include the emulator installation location, emulator name, and system root directory;
[0115] If the compilation type of the target program is non-local compilation, then the compilation toolchain configuration parameters in the compilation command are determined to be the fourth compilation toolchain configuration parameters; the configuration information is used to assign values to the fourth compilation toolchain configuration parameters to generate the target compilation command for the target program; the fourth compilation toolchain configuration parameters include the emulator installation location, emulator name, and system root directory.
[0116] In one embodiment, the compilation apparatus 500 provided by the present invention further includes a storage module; the storage module is used for:
[0117] Receive configuration information from the target program through a custom interface;
[0118] In response to receiving a storage instruction, the configuration information is stored as a configuration file.
[0119] In one embodiment, the compilation apparatus 500 provided by the present invention further includes a filename output module; the filename output module is used for:
[0120] Identify an active text editor, obtain its filename, and output the filename to the console.
[0121] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include a processor 601, a communications interface 602, a memory 603, and a communication bus 604. The processor 601, communications interface 602, and memory 603 communicate with each other via the communication bus 604. The processor 601 can call logical instructions in the memory 603 to execute a compilation method. This method includes: in response to a code compilation and execution instruction, obtaining configuration information of the target program; determining the language category of the target program based on language type information in the configuration information; determining the compilation toolchain configuration parameters in the compilation command according to the language category, and assigning values to the corresponding compilation toolchain configuration parameters in the compilation command using the configuration information to generate a target compilation command for the target program; executing the target compilation command to compile the target program into an executable program, and running the executable program.
[0122] Furthermore, the logical instructions in the aforementioned memory 603 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0123] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the compilation methods provided by the above methods. The method includes: in response to a code compilation and execution instruction, obtaining configuration information of a target program; determining the language category of the target program based on language type information in the configuration information; determining the compilation toolchain configuration parameters in the compilation command according to the language category, and assigning values to the corresponding compilation toolchain configuration parameters in the compilation command using the configuration information to generate a target compilation command for the target program; executing the target compilation command to compile the target program into an executable program, and running the executable program.
[0124] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the compilation method provided by the above methods. The method includes: in response to a code compilation and execution instruction, obtaining configuration information of a target program; determining the language category of the target program based on language type information in the configuration information; determining the compilation toolchain configuration parameters in the compilation command according to the language category, and assigning values to the corresponding compilation toolchain configuration parameters in the compilation command using the configuration information to generate a target compilation command for the target program; executing the target compilation command to compile the target program into an executable program, and running the executable program.
[0125] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method of compiling, characterized by, The method comprises the following steps: obtaining configuration information of a target program in response to compiling and running code instructions; determining a language category of the target program based on language category information in the configuration information; determining a compilation tool chain configuration parameter in a compilation command according to the language category, and assigning a value to the corresponding compilation tool chain configuration parameter in the compilation command by using the configuration information, to generate a target compilation command of the target program; executing the target compilation command to compile the target program into an executable program, and running the executable program; the language category of the target program is a compiled language or a semi-compiled and semi-interpreted language; the method of determining a compilation tool chain configuration parameter in a compilation command according to the language category, and assigning a value to the corresponding compilation tool chain configuration parameter in the compilation command by using the configuration information, to generate a target compilation command of the target program, comprises the following steps: if the language category of the target program is a compiled language, determining that the compilation tool chain configuration parameter in the compilation command is a first compilation tool chain configuration parameter; assigning a value to the first compilation tool chain configuration parameter by using the configuration information, to generate a target compilation command of the target program; the first compilation tool chain configuration parameter comprises a tool chain type, a tool chain root directory and a header file directory; if the language category of the target program is a semi-compiled and semi-interpreted language, determining that the compilation tool chain configuration parameter in the compilation command is a second compilation tool chain configuration parameter; assigning a value to the second compilation tool chain configuration parameter by using the configuration information, to generate a target compilation command of the target program; the second compilation tool chain configuration parameter does not comprise a tool chain type, a tool chain root directory and a header file directory.
2. The method of claim 1, wherein, if the language category of the target program is a compiled language, the method of executing the target compilation command to compile the target program into an executable program, and running the executable program, comprises the following steps: determining that the emulator name in the configuration information is empty, executing the compilation command through a console terminal to compile the target program into an executable program; executing the executable program through the console.
3. The method of claim 1, wherein, if the language category of the target program is a semi-compiled and semi-interpreted language, the method of determining a compilation tool chain configuration parameter in a compilation command, and assigning a value to the corresponding compilation tool chain configuration parameter in the compilation command by using the configuration information, to generate a target compilation command of the target program, comprises the following steps: if the language category of the target program is a semi-compiled and semi-interpreted language, determining the compilation type of the target program to be local compilation or non-local compilation based on the emulator name in the configuration information; if the compilation type of the target program is local compilation, determining that the compilation tool chain configuration parameter in the compilation command is a third compilation tool chain configuration parameter; assigning a value to the third compilation tool chain configuration parameter by using the configuration information, to generate a target compilation command of the target program; the third compilation tool chain configuration parameter does not comprise an emulator installation position, an emulator name and a system root directory. If the compilation type of the target program is non-native compilation, the compilation tool chain configuration parameter in the compilation command is determined as a fourth compilation tool chain configuration parameter; the configuration information is used to assign values to the fourth compilation tool chain configuration parameter, and a target compilation command of the target program is generated; the fourth compilation tool chain configuration parameter includes an emulator installation location, an emulator name, and a system root directory.
4. The method of claim 1, wherein, Before the configuration information of the target program is acquired, the method further includes: receiving the configuration information of the target program through a self-defined interface; in response to receiving the storage instruction, storing the configuration information as a configuration file.
5. The method of claim 1, wherein, Before the configuration information of the target program is acquired, the method further includes: determining that there is an active text editor, acquiring a file name of the text editor, and outputting the file name to a console.
6. A compiling apparatus characterized by comprising: comprise: a configuration information acquisition module configured to acquire configuration information of a target program in response to a code instruction for compiling and running; a language category determination module configured to determine a language category of the target program based on language category information in the configuration information; a compilation command generation module configured to determine a compilation tool chain configuration parameter in a compilation command according to the language category, and to assign values to the corresponding compilation tool chain configuration parameter in the compilation command using the configuration information, so as to generate a target compilation command of the target program; a compilation and running module configured to execute the target compilation command, compile the target program into an executable program, and run the executable program; the language category of the target program is a compiled language or a semi-compiled and semi-interpreted language; the determination of the compilation tool chain configuration parameter in the compilation command according to the language category, and the assignment of values to the corresponding compilation tool chain configuration parameter in the compilation command using the configuration information, so as to generate the target compilation command of the target program, comprise: if the language category of the target program is a compiled language, the compilation tool chain configuration parameter in the compilation command is determined as a first compilation tool chain configuration parameter; the first compilation tool chain configuration parameter is assigned values using the configuration information, and a target compilation command of the target program is generated; the first compilation tool chain configuration parameter includes a tool chain type, a tool chain root directory, and a header file directory; if the language category of the target program is a semi-compiled and semi-interpreted language, the compilation tool chain configuration parameter in the compilation command is determined as a second compilation tool chain configuration parameter; the second compilation tool chain configuration parameter is assigned values using the configuration information, and a target compilation command of the target program is generated; the second compilation tool chain configuration parameter does not include a tool chain type, a tool chain root directory, and a header file directory.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor executes the computer program to implement the compilation method in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the compilation method in any one of claims 1 to 5.
9. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the compilation method in any one of claims 1 to 5.
Citation Information
Patent Citations
Cross-platform compiling method and device, electronic equipment and storage medium
CN116257250A
Program debugging method and device, electronic equipment and storage medium
CN119669036A