A method, device, equipment and storage medium for reusing multi-project code files

By creating total project modules and project modules in BIOS multi-project development, and setting priority editing rights, priority compilation rights and file mapping methods, the problems of poor compatibility between different projects and large workload when updating code bases are solved, and rapid porting and efficient development of multiple projects are achieved.

CN115756451BActive Publication Date: 2025-06-06INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211625550.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-16
Publication Date
2025-06-06
Estimated Expiration
2042-12-16

AI Technical Summary

Technical Problem

In the multi-project development of BIOS, it is difficult for the existing technology to achieve compatibility between different projects, and when the code base is updated, the code modification parts related to the multi-project need to be copied and pasted again, resulting in a large amount of workload and affecting rapid porting.

Method used

By creating total project modules and project modules in the code base, setting file priority editing rights, priority compilation rights and file mapping methods, specifying files to specific project modules, and defining mutex variables to distinguish projects. When a project is rebuilt or a code base is updated, a specific modification method is used to change the project name, program, and mapped directory location.

Benefits of technology

It achieves compatibility between different projects, reduces the workload during code base updates, improves the rapid portability of multiple projects, avoids excessive memory and hard disk space, and improves development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115756451B_ABST
    Figure CN115756451B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of project code development, and specifically provides a method, device, equipment, and storage medium for reusing multi-project code files. The method includes the following steps: creating a general project module in a code library, and creating project modules under the general project module as needed; assigning files to specific project modules by setting allocation file priority editing rights, priority compilation rights, and file mapping methods for files that need to be written into the project; defining mutually exclusive variables to distinguish different projects; when rebuilding a project, creating a new project module under the general project module, copying all files in the project module to be rebuilt to the new project module, and changing the project name, program, and mapping directory location according to the requirements of the project name of the new project module through a specific modification method. Different projects present different modification contents, which avoids the problem of code change confusion caused by multiple projects modifying a file at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of project code development, and in particular to a method, device, equipment and storage medium for reusing multi-project code files. Background Art

[0002] In BIOS multi-project development, mature code bases are used to develop for different project requirements. Usually, different modifications are made to the same code location. In this case, how to effectively write the code to achieve compatibility between different projects, and to implement a set of code bases to adapt to different projects, and when updating the code base, the project-related codes can be ported together. These are the challenges faced by BIOS firmware developers.

[0003] The BIOS industry has the following common technical solutions. The first one uses different project names to determine the project name at the corresponding code location, and then makes project-related modifications to achieve different program modifications for multiple projects. This method is widely used in the industry and has good compatibility in implementing multi-project development with the same set of code. However, the problem is that when the code base needs to be updated, the code modification parts related to multiple projects have to be copied and pasted again and compared. If there are many files changed in different projects, involving kernel files, peripheral module files, etc., the corresponding workload will also increase greatly, which is not conducive to the rapid transplantation of multiple projects. ; The second method is to copy the files of the same code base again, rename them to another project name, and then modify the code location related to the project; the advantage of this method is that each project is independently developed and maintained. This method is very convenient for companies with frequent changes and many projects. It can avoid the modification of multiple projects in the same file, which causes project modification confusion; but the problem is that the more projects there are, the higher the labor cost of maintenance, the lower the code reuse rate, the larger the code space occupied, and when multiple projects are opened with UEFI development tools, the memory occupied is obvious, which affects the compilation speed and thus the development efficiency. Summary of the invention

[0004] With regard to the two methods mentioned above, the first method has a high code reuse rate, but the code library update leads to low portability, which is not conducive to the rapid transplantation of multiple projects; the second method has a low code reuse rate, the code occupies a large space, and when multiple projects are opened at the same time, it occupies memory resources, etc., affecting the development and compilation efficiency; these problems encountered in the current BIOS project development, the present invention provides a method, device, equipment, and storage medium for reusing multi-project code files.

[0005] In a first aspect, the technical solution of the present invention provides a method for reusing code files in multiple projects, comprising the following steps:

[0006] Create a general project module in the code base, and create project modules under the general project module as needed;

[0007] For files that need to be coded for a project, assign files to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; at the same time, define mutually exclusive variables to distinguish different projects;

[0008] When the project is rebuilt, a new project module is created under the main project module, all files in the project module to be rebuilt are copied to the new project module, and the project name, program, and mapping directory location are changed according to the requirements of the project name of the new project module through specific modification methods in the places where the statements related to the project name to be rebuilt are located;

[0009] When the code base needs to be updated, export the main project module and then import the main project module into the new code base.

[0010] As a further limitation of the technical solution of the present invention, when a project is rebuilt, a new project module is created under the main project module, all files in the project module to be rebuilt are copied to the new project module, and the place where the relevant statements of the project name to be rebuilt are placed is modified in a specific way according to the requirements of the project name of the new project module. In the steps of changing the project name, program, and mapping directory location, the project module to be rebuilt is project module A, and the new project module is project module B, specifically including:

[0011] Under the general project module, create project module B, set project name B, copy all files in project module A to project module B, and modify the project name, program, and mapping directory location of the relevant statements of project name A in a specific way according to the requirements of project name B;

[0012] Set up and close the project of project name A to make the project of project name B effective, and define mutually exclusive variables between projects to allow project name B to obtain priority editing and compiling rights for related files. Where project name B needs to change the code, modify the corresponding files.

[0013] As a further limitation of the technical solution of the present invention, the method further includes:

[0014] When you need to export the project code, directly export the created project module, that is, export the corresponding modified file;

[0015] When the code base needs to be updated, export the overall project module, and then import the relevant project code of the overall project module into the new code base.

[0016] As a further limitation of the technical solution of the present invention, for a file that needs to be coded for a project, the file is assigned to a specific project module by setting a file priority editing right, a priority compile right, and a file mapping method, and the file mapping method includes:

[0017] Copy a file to be modified and assign it to a project name directory, so that the source file path is in the original location and the target file to be modified is in the project name.

[0018] As a further limitation of the technical solution of the present invention, for a file that needs to be coded for a project, the step of assigning a file priority editing right, a priority compiling right, and a file mapping method to a specific project module, wherein the priority editing right is set includes:

[0019] Set the mutually exclusive variable j between projects. When the value of j corresponds to a project name, the files of other projects are inactive, that is, only the code in the related files can be written under the project with that project name.

[0020] As a further limitation of the technical solution of the present invention, for a file that needs to be coded for a project, by setting and allocating file priority editing rights, priority compiling rights, and a file mapping method to assign the file to a specific project module, setting the priority compiling rights includes:

[0021] When compiling, the compilation environment will use the project name pointed to by the global variable j to overwrite the files belonging to the project to the location of the source files in the code base through reverse mapping, thereby giving priority to compiling the project.

[0022] As a further limitation of the technical solution of the present invention, in the step of changing the project name, program, and mapping directory location according to the requirements of project name B through a specific modification method, the specific modification method includes:

[0023] Replace the file to be modified by unified operation, and change the directory compilation path where the file is located so that the path where the file is located can be recognized by the compiler; or,

[0024] Through unified replacement, the project name part involved in the original project module is uniformly changed to project name B.

[0025] As a further limitation of the technical solution of the present invention, where the code of project name B needs to be changed, the steps of modifying the corresponding file include:

[0026] When compiling files, the compiler only recognizes the relevant files in project name B. In the pre-compilation environment, according to the priority compilation right feature variable set for project name B, the relevant files under project name B will be copied from the path of project name B to the path of the original code library in a mapped manner, overwriting the original files. When compilation starts, the compiler compiles the files according to their original paths, and the generated target files are the target files that meet project name B.

[0027] In a second aspect, the technical solution of the present invention provides a device for reusing code files of multiple projects, including a creation module, a setting module, a modification execution module and an import and export execution module;

[0028] Create a module, which is used to create a general project module in the code base, and create project modules under the general project module as needed;

[0029] The setting module is used to assign files that need to be coded for the project to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; at the same time, mutually exclusive variables are defined to distinguish different projects;

[0030] Modify the execution module, which is used to create a new project module under the main project module when the project is rebuilt, copy all files in the project module to be rebuilt to the new project module, and change the project name, program, and mapping directory location according to the requirements of the project name of the new project module through a specific modification method in the places where the statements related to the project name to be rebuilt are located;

[0031] The import and export execution module is used to export the overall project module and then import the overall project module into the new code base when the code base needs to be updated.

[0032] As a further limitation of the technical solution of the present invention, the project module to be rebuilt is project module A, and the new project module is project module B.

[0033] Create a module. Under the general project module, create project module B and set the project name to B.

[0034] Modify the execution module, copy all files in project module A to project module B, and change the project name, program, and mapping directory location of project name A related statements through specific modification methods according to the needs of project name B; set up and close the project of project name A to make the project of project name B effective, and define mutually exclusive variables between projects to allow project name B to obtain priority editing and compiling rights for related files, and modify the corresponding files where project name B needs to change the code.

[0035] As a further limitation of the technical solution of the present invention, the import and export execution module is specifically used to directly export the created project module when the project code needs to be exported, that is, to realize the export of the corresponding modified file; when the code library needs to be updated, the total project module is exported, and then the relevant project code of the total project module is imported into the new code library.

[0036] It should be noted that the file mapping method includes: copying a file to be modified, assigning it to a project name directory, forming a relationship in which the source file path is in the original location and the target file to be modified is under the project name.

[0037] The priority editing right includes: setting the mutually exclusive variable j between projects. When the value of j corresponds to a project name, the files of other projects are inactive, that is, only under the project with that project name can the code in the related files be written.

[0038] Priority compilation rights include: when compiling, the compilation environment will use the project name pointed to by the global variable j to overwrite the files belonging to the project to the location of the source files in the code base through reverse mapping, thereby achieving priority compilation of the project.

[0039] Specific modification methods include: replacing the file to be modified through a unified operation, changing the directory compilation path where the file is located, so that the path where the file is located can be recognized by the compiler; or, through a unified replacement method, changing the project name part involved in the original project module to a unified name B.

[0040] Modify the execution module, which is specifically used for file compilation. The compiler only recognizes the relevant files in project name B. In the pre-compilation environment, according to the priority compilation right feature variable set for project name B, the relevant files under project name B will be copied from the path of project name B to the path of the original code library in a mapped manner, overwriting the original files. When compilation starts, the compiler compiles the files according to their original paths, and the generated target files are the target files that meet project name B.

[0041] In a third aspect, the technical solution of the present invention further provides an electronic device, the electronic device comprising:

[0042] at least one processor; and,

[0043] a memory communicatively connected to the at least one processor; wherein,

[0044] The memory stores computer program instructions that can be executed by at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to perform the method for reusing multi-project code files as described in the first aspect.

[0045] In a fourth aspect, the technical solution of the present invention further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method for reusing multi-project code files as described in the first aspect.

[0046] It can be seen from the above technical solutions that the present invention has the following advantages: 1. It better solves the problem of code reuse; 2. It can avoid the system slowness caused by memory, CPU and resource occupation caused by opening multiple project projects at the same time; 3. It can effectively solve the project management chaos problem caused by multiple projects modifying one file or multiple files at the same time; 4. It is easier to modularly import and export engineering project modules, and has strong portability.

[0047] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect.

[0048] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0050] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.

[0051] Figure 2 is a schematic block diagram of an apparatus according to an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0053] like Figure 1 As shown, an embodiment of the present invention provides a method for reusing multi-project code files, comprising the following steps:

[0054] Step 1: Create a general project module in the code base, and create project modules under the general project module as needed;

[0055] Step 2: For the files that need to be coded in the project, assign the files to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; at the same time, define mutually exclusive variables to distinguish different projects;

[0056] Step 3: When the project is rebuilt, a new project module is created under the main project module, and all files in the project module to be rebuilt are copied to the new project module. In the places where the statements related to the project name to be rebuilt are located, the project name, program, and mapping directory location are changed according to the requirements of the project name of the new project module through specific modification methods;

[0057] Step 4: When the code base needs to be updated, export the overall project module and then import the overall project module into the new code base.

[0058] In the code base, a general project module is created, and project modules are created under the general project module as needed; for files that need to be written in specific projects, the files are assigned to specific project modules by setting priority selection methods; at the same time, mutually exclusive variables are defined to distinguish different projects. When the file is assigned to different project modules, the defined mutually exclusive variables specify that the corresponding file can be edited and compiled under the specific project module; this method realizes the reuse of the overall codebase, and there is no need to repeatedly copy the code base and rebuild other projects; thereby saving hard disk space, as well as memory usage and slow compilation speed problems caused by opening multiple projects at the same time; since the modified files present different modified contents according to different projects, this avoids the problem of code change confusion that may be caused by multiple projects modifying a file at the same time in the traditional way; when the code base needs to be updated, it is only necessary to export the previous general project module and then import the module into the new code base to realize the migration of multiple project files, thereby realizing the modularization of the BIOS project.

[0059] An embodiment of the present invention provides a method for reusing code files of multiple projects, comprising the following steps:

[0060] S1: In the existing code base, create a general project module and a project module A. In the project, set the project name ProjectA, set the priority editing and priority compiling rights for the relevant files to be modified, and map them to the directory of the project module A;

[0061] S2: Create a project module B under the main project module, with the project name ProjectB. Copy all files in project module A to project module B. Modify the relevant statements of project name ProjectA in a specific way and change the name, program, and mapping directory location of ProjectB according to the requirements of ProjectB.

[0062] S3: Turn off the switch of ProjectA to make ProjectB effective, and define mutually exclusive variables between projects to allow ProjectB to obtain priority editing and compiling rights for related files. Modify the corresponding files where ProjectB needs to change the code;

[0063] S4: When you need to export or import ProjectB code, you can directly export the created project module B to export the corresponding modified files, and then import the project code into the new code base in the same way. Here, the previous modified records of Project B are still replaced in the new code base, which facilitates the migration of project modules.

[0064] It should be noted that when it is necessary to export the project code, the created project module is directly exported, that is, the corresponding modified file is exported; when the code library needs to be updated, the total project module is exported, and then the relevant project code of the total project module is imported into the new code library.

[0065] It should be noted that the file priority editing right and file priority compiling right in step S1, the file mapping method is as follows:

[0066] File mapping means that in the development tool, a copy of the file to be modified is assigned to the projectA directory, forming a relationship in which the source file path is in the original location and the target file to be modified is under ProjectA;

[0067] Priority editing means setting a mutually exclusive variable j between projects in the development environment. When the value of j corresponds to projectA, the files of other projects are inactive, and you can write code in related files under projectA.

[0068] Priority compilation means that when compiling, the compilation environment will reversely map the files belonging to the project to the location of the source files in the code base according to the project directory pointed to by the global variable j, such as ProjectA, to achieve priority compilation of the project.

[0069] In step S2, in which the project name, program, and mapping directory location are changed according to the requirements of project name B by a specific modification method, the specific modification method includes:

[0070] (1) The file to be modified is replaced by a unified operation to change the directory compilation path where the file is located so that the path where the file is located can be recognized by the compiler; (2) Through a unified replacement method, the project name part involved in the original project module is uniformly changed to project name B.

[0071] In step S3, because ProjectA is not effective, during compilation, the compiler only recognizes the relevant files in ProjectB. In the pre-compilation environment, the relevant files under ProjectB will be copied from the path of projectB to the path of the original code library according to the way they are mapped, according to the setting priority compilation right characteristic variable of ProjectB, overwriting the original files. When the compilation starts, the compiler only needs to compile the files according to their original paths, and the generated target files are the target files that meet projectB. This enables changes to the same files and codes at the same location between different projects; and the projects do not interfere with each other; in the same UEFI development environment, you can open a set of code to view the changes related to different projects; it does not take up much memory and hard disk space.

[0072] like Figure 2 As shown, an embodiment of the present invention provides a device for reusing code files of multiple projects, including a creation module, a setting module, a modification execution module and an import and export execution module;

[0073] Create a module, which is used to create a general project module in the code base, and create project modules under the general project module as needed;

[0074] The setting module is used to assign files that need to be coded for the project to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; at the same time, mutually exclusive variables are defined to distinguish different projects;

[0075] Modify the execution module, which is used to create a new project module under the main project module when the project is rebuilt, copy all files in the project module to be rebuilt to the new project module, and change the project name, program, and mapping directory location according to the requirements of the project name of the new project module through a specific modification method in the places where the statements related to the project name to be rebuilt are located;

[0076] The import and export execution module is used to export the overall project module and then import the overall project module into the new code base when the code base needs to be updated.

[0077] It should be noted that the project module to be rebuilt is project module A, and the new project module is project module B. Create a module, create project module B under the general project module, and set the project name to B;

[0078] Modify the execution module, copy all files in project module A to project module B, and change the project name, program, and mapping directory location of project name A related statements through specific modification methods according to the needs of project name B; set up and close the project of project name A to make the project of project name B effective, and define mutually exclusive variables between projects to allow project name B to obtain priority editing and compiling rights for related files, and modify the corresponding files where project name B needs to change the code.

[0079] The import and export execution module is specifically used to directly export the created project module when the project code needs to be exported, that is, to realize the export of the corresponding modified files; when the code library needs to be updated, the total project module is exported, and then the relevant project code of the total project module is imported into the new code library.

[0080] It should be noted that the file mapping method includes: copying a file to be modified, assigning it to a project name directory, forming a relationship in which the source file path is in the original location and the target file to be modified is under the project name.

[0081] The priority editing right includes: setting the mutually exclusive variable j between projects. When the value of j corresponds to a project name, the files of other projects are inactive, that is, only under the project with that project name can the code in the related files be written.

[0082] Priority compilation rights include: when compiling, the compilation environment will use the project name pointed to by the global variable j to overwrite the files belonging to the project to the location of the source files in the code base through reverse mapping, thereby achieving priority compilation of the project.

[0083] Specific modification methods include: replacing the file to be modified through a unified operation, changing the directory compilation path where the file is located, so that the path where the file is located can be recognized by the compiler; or, through a unified replacement method, changing the project name part involved in the original project module to a unified name B.

[0084] Modify the execution module, which is specifically used for file compilation. The compiler only recognizes the relevant files in project name B. In the pre-compilation environment, according to the priority compilation right feature variable set for project name B, the relevant files under project name B will be copied from the path of project name B to the path of the original code library in a mapped manner, overwriting the original files. When compilation starts, the compiler compiles the files according to their original paths, and the generated target files are the target files that meet project name B.

[0085] The embodiment of the present invention also provides an electronic device, which includes: a processor, a communication interface, a memory and a bus, wherein the processor, the communication interface and the memory communicate with each other through the bus. The bus can be used for information transmission between the electronic device and the sensor. The processor can call the logic instructions in the memory to execute the following method: Step 1: Create a general project module in the code library, and create a project module under the general project module as needed; Step 2: For the files that need to write code for the project, assign the files to specific project modules by setting the priority editing rights, priority compiling rights and file mapping methods; At the same time, define mutually exclusive variables to distinguish different projects; Step 3: When the project is rebuilt, create a new project module under the general project module, copy all files in the project module to be rebuilt to the new project module, and change the project name, program and mapping directory location according to the requirements of the project name of the new project module by a specific modification method in the places where the statements related to the project name to be rebuilt are located; Step 4: When the code library needs to be updated, export the general project module and import the general project module into the new code library.

[0086] This method achieves the reuse of the overall codebase, without the need to repeatedly copy the codebase and rebuild other projects; thereby saving hard disk space, as well as memory usage and slow compilation speed problems caused by opening multiple projects at the same time; since the modified files present different modifications according to different projects, this avoids the problem of code change confusion that may be caused by multiple projects modifying a file at the same time; when the codebase needs to be updated, it is only necessary to export the previous total project module and then import the module into the new codebase to achieve the migration of multiple project files, thereby realizing the modularization of the BIOS project.

[0087] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0088] The embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable the computer to execute the method provided by the above method embodiment, for example, including: S1: in the existing code library, create a general project module, create a project module A, set the project name ProjectA in the project, set the priority editing and priority compiling rights of the relevant files to be modified, and map them to the directory of the project module A; S2: under the general project module, create a project module B, the project name is ProjectB, copy all files in the project module A to the project module B, and set the project name ProjectA to the directory of the project module B; ojectA related statements, through specific modification methods, according to ProjectB requirements, change ProjectB name, program, mapping directory location; S3: Turn off the ProjectA switch to make ProjectB project effective, and define mutually exclusive variables between projects, so that ProjectB obtains priority editing and compilation rights for related files, and modifies the corresponding files where ProjectB needs to change the code; S4: When it is necessary to export and import ProjectB code, directly export the created project module B to realize the export of the corresponding modified files, and then use the same method to import the project code into the new code base.

[0089] Although the present invention has been described in detail by referring to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A method for reusing code files in multiple projects, It is characterized in that The steps include: Create a general project module in the code base, and create project modules under the general project module as needed; For files that need to be coded in the project, assign the files to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; At the same time, mutually exclusive variables are defined to distinguish different projects; wherein, the file mapping method includes: copying a file to be modified and assigning it to a directory with a project name, so as to form a relationship where the source file path is in the original location and the target file to be modified is under the project name; setting priority editing rights and priority compilation rights includes: setting mutually exclusive variables j between projects, when the value of j corresponds to a project name, the files of other projects are in an inactive state, that is, only under the project with the project name, the code in the related files is written; when compiling, the compilation environment will cover the files belonging to the project with the project name pointed to by the global variable j through reverse mapping to the location of each source file in the code base, so as to realize priority compilation of the project; When the project is rebuilt, a new project module is created under the general project module, all files in the project module to be rebuilt are copied to the new project module, and the project name, program, and mapping directory location are changed in the places where the statements related to the project name to be rebuilt are located according to the requirements of the project name of the new project module through a specific modification method; wherein, the project module to be rebuilt is project module A, and the new project module is project module B. This step specifically includes: under the general project module, create project module B, set project name B, copy all files in project module A to project module B, and change the project name, program, and mapping directory location in the places where the statements related to project name A are located according to the requirements of project name B through a specific modification method; set the project of project name A to be closed, so that the project of project name B can take effect, and define mutually exclusive variables between projects, so that project name B can obtain priority editing and compiling rights for related files, and modify the corresponding files where the code of project name B needs to be changed; When the code base needs to be updated, export the main project module and then import the main project module into the new code base.

2. The method for reusing multi-project code files according to claim 1, It is characterized in that When the code base needs to be updated, the steps to export the overall project module and then import the overall project module into the new code base include: When you need to export the project code, directly export the created project module, that is, export the corresponding modified file; When the code base needs to be updated, export the overall project module, and then import the relevant project code of the overall project module into the new code base.

3. The method for reusing multi-project code files according to claim 2, It is characterized in that In the steps of changing the project name, program, and mapping directory location according to the requirements of project name B through a specific modification method, the specific modification method includes: Replace the file to be modified by unified operation, and change the directory compilation path where the file is located so that the path where the file is located can be recognized by the compiler; or, Through unified replacement, the project name part involved in the original project module is uniformly changed to project name B.

4. The method for reusing multi-project code files according to claim 3, It is characterized in that Where the code of project name B needs to be changed, the steps for modifying the corresponding files include: When compiling files, the compiler only recognizes the relevant files in project name B. In the pre-compilation environment, according to the priority compilation right feature variable set for project name B, the relevant files under project name B will be copied from the path of project name B to the path of the original code library in a mapped manner, overwriting the original files. When compilation starts, the compiler compiles the files according to their original paths, and the generated target files are the target files that meet project name B.

5. A device for reusing code files in multiple projects, It is characterized in that Including creating modules, setting modules, modifying execution modules, and importing and exporting execution modules; Create a module, which is used to create a general project module in the code base, and create project modules under the general project module as needed; The setting module is used to assign files that need to be coded for the project to specific project modules by setting the priority editing rights, priority compiling rights, and file mapping methods; At the same time, mutually exclusive variables are defined to distinguish different projects; wherein, the file mapping method includes: copying a file to be modified and assigning it to a directory with a project name, so as to form a relationship where the source file path is in the original location and the target file to be modified is under the project name; setting priority editing rights and priority compilation rights includes: setting mutually exclusive variables j between projects, when the value of j corresponds to a project name, the files of other projects are in an inactive state, that is, only under the project with the project name, the code in the related files is written; when compiling, the compilation environment will cover the files belonging to the project with the project name pointed to by the global variable j through reverse mapping to the location of each source file in the code base, so as to realize priority compilation of the project; The modification execution module is used to create a new project module under the general project module when the project is rebuilt, copy all files in the project module to be rebuilt to the new project module, and change the project name, program, and mapping directory location of the statements related to the project name to be rebuilt through a specific modification method according to the requirements of the project name of the new project module; wherein, the project module to be rebuilt is project module A, and the new project module is project module B. The modification execution module is specifically used to create project module B under the general project module, set project name B, copy all files in project module A to project module B, and change the project name, program, and mapping directory location of the statements related to project name A through a specific modification method according to the requirements of project name B; set to close the project of project name A, so that the project of project name B takes effect, and define mutually exclusive variables between projects, so that project name B obtains priority editing and compiling rights for related files, and modifies the corresponding files where the code of project name B needs to be changed; The import and export execution module is used to export the overall project module and then import the overall project module into the new code base when the code base needs to be updated.

6. An electronic device, It is characterized in that The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the method for reusing multi-project code files as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method for reusing multi-project code files according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Multiprocessor programming toolkit for design reuse

    CN109240704A

  • Front-end code access detection method and device, equipment and storage medium

    CN112965695A