Source file backup method, electronic device and medium suitable for multi-step compilation
By obtaining the full path and modification time of the source file, determining whether a backup is needed, and generating the latest backup path, the problem of inaccurate recording of source code file content in multi-step compilation is solved, achieving fast and accurate recording of compilation results.
Patent Information
- Application Number
- CN202511378915.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-25
AI Technical Summary
In multi-step compilation processes, existing technologies struggle to accurately and quickly record the contents of the source code files corresponding to the compilation results, leading to result mismatch issues.
By obtaining the full path of the source file, the last modification time, and the compiled result file, comparing the current source file with the source file in the latest backup path, determining whether a backup is needed, generating the latest backup path, and recording the source file backup path, the accuracy of each compilation result is ensured.
With minimal memory consumption, it accurately and quickly records the contents of the source code file corresponding to the compilation results of multi-step compilation, avoiding result mismatch issues.
Smart Images

Figure CN120872695B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of EDA design, and particularly relates to a source file backup method suitable for multi-step compilation, an electronic device and a medium. BACKGROUND
[0002] In the field of Electronic Design Automation (EDA), the source code written by a designer needs to be compiled before a corresponding design structure can be correctly generated, so that the next simulation and verification process can be performed. In order to improve the reusability, speed and compatibility of the compilation content, the compiler usually supports multi-step compilation, that is, the entire design content is reasonably divided into multiple subsets, and each subset is compiled, and then the results of multiple compilations are organized into a complete process, so that a completed and compiled database is output for post-simulation processing. The above process is multi-step compilation.
[0003] In the process of multi-step compilation, each compilation is generally based on a file level, that is, a single compilation is based on a certain file or a few files for operation to generate corresponding result data. However, in the process of multi-step compilation, if a user first compiles a file A to output a corresponding first result, then modifies the content of the file A, and then compiles the file A again to output a corresponding second result. Finally, when organizing the results of multiple compilations, the data of the first result and the second result are used at the same time. Since the source code file of the first result has been modified, when the first result is mapped to the source file, a series of result mismatch problems will be caused. Therefore, how to accurately and quickly record the source code file content corresponding to the compilation result under multi-step compilation becomes a technical problem to be solved. SUMMARY
[0004] The present application aims to provide a source file backup method suitable for multi-step compilation, an electronic device and a medium, which can accurately and quickly record the source code file content corresponding to the compilation result under multi-step compilation.
[0005] According to a first aspect of the present application, a source file backup method suitable for multi-step compilation is provided, comprising:
[0006] Step S1, obtaining F n a corresponding full path FP n and F n a source file last modification time MT corresponding to a current single-step compilation operation and F n a compilation result saving file LB corresponding to the current single-step compilation operation and F n for the nth source file participating in multi-step compilation, the value range of n is 1 to N, and N is the total number of source files participating in multi-step compilation;
[0007] Step S2, comparison F n the current source file and the source file under the latest backup path CP of F n If the same, directly set F n The source file backup path BP corresponding to the current single-step compilation operation is equal to CP, otherwise, F n Backup the current source file to the backup storage path to generate the latest backup path CP, and then set F n The source file backup path BP corresponding to the current single-step compilation operation is equal to CP, and return to step S1.
[0008] According to the second aspect of the present application, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected with the at least one processor; wherein the memory stores instructions executed by the at least one processor, and the instructions are configured to execute the method according to the first aspect of the present application.
[0009] According to the third aspect of the present application, a computer readable storage medium is provided, which stores computer executable instructions, and the computer executable instructions are configured to execute the method according to the first aspect of the present application.
[0010] Compared with the prior art, the present application has obvious advantages and beneficial effects. By means of the above technical scheme, the source file backup method, electronic device and medium suitable for multi-step compilation provided by the present application can achieve considerable technical progress and practicality, and have wide industrial utilization value, and at least have the following beneficial effects:
[0011] In the process of performing single-step compilation on each file involved in multi-step compilation, the present application determines whether backup is needed by judging whether the file has been modified compared with the file under the latest backup path, and determines the source file backup path corresponding to each file under single-step compilation. The present application can accurately and quickly record the source code file content corresponding to the compilation result under multi-step compilation with very little memory expenditure. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0013] Figure 1 The source file backup method flowchart suitable for multi-step compilation provided by the embodiment of the present application. DETAILED DESCRIPTION
[0014] With reference to the drawings and the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts are within the scope of the present application.
[0015] The embodiment of the present application provides a source file backup method suitable for multi-step compilation, as shown in the following formula (1) : Figure 1
[0016] Step S1, obtaining F n corresponding full path FP n and F n corresponding source file last modification time MT and F n corresponding compilation result saving file LB, F n is the nth source file participating in the multi-step compilation, and n is in the range of 1 to N, and N is the total number of source files participating in the multi-step compilation.
[0017] It should be noted that F n refers to any one source file participating in the multi-step compilation, and the value of n does not limit the order of participating in the multi-step compilation. The same source file F n In the multi-step compilation, there can be multiple different compilation result saving files LB, and the compilation result saving file is a compilation library. One LB can be generated based on one source file F n or multiple different source files F n compilation. The same source file F n In the multi-step compilation process, it can be modified, that is, when the same source file participates in the compilation of different compilation result saving files, it can correspond to different versions of the source file. When the same source file participates in the compilation of different compilation result saving files multiple times, it can also correspond to different versions of the source file.
[0018] As an example, the method further comprises:
[0019] Step S10, modifying F n under FP n , updating F n corresponding source file last modification time MT.
[0020] Through step S10, F n corresponding full path FP n always saves the latest file, and the corresponding last modification time MT is saved. When F n needs to participate in the compilation, F n Corresponding full path FP n Get F below n The last modified time (MT) of the source file corresponding to the current single-step compilation operation is available. n The corresponding full path refers to the path that uniquely determines F. n The path to the corresponding source file location.
[0021] As an example, the source file is a chip design source file; it is understood that the source file is not limited to chip design source files.
[0022] Step S2, compare with F n The current source file and F n If the source files in the latest backup path CP are the same, then directly set F. n The backup path of the source files corresponding to the current single-step compilation operation is BP equal to CP; otherwise, it is F. n The current source file is backed up to the backup storage path, the latest backup path CP is generated, and then F is set. n If the backup path BP of the source file corresponding to the current single-step compilation operation is equal to CP, return to step S1.
[0023] It should be noted that step S2 can record each F n The backup path is specified for each compilation step, allowing for accurate identification of the corresponding file version. It's understood that a backup operation is only performed and a corresponding backup path (CP) is generated if the latest version of the source file is confirmed to be involved in the single-step compilation operation. Furthermore, all compilation steps using this version of the source file will be performed using the backup path (F). n The corresponding backup paths are all reused as this backup path.
[0024] As one embodiment, step S2 includes:
[0025] Step S21: Obtain F from the current intermediate data save file n The corresponding usage record set {UD1} n UD2 n ,...,UD i n ,...,UD f(n) n}, UD i n For F n The corresponding nth usage record, UD i n ={FP n BP i n ,MT i n ,LBi n}, BP i n For UD i n The corresponding source file backup path, MT i n For UD i n The corresponding source file's last modified time, LB i n For UD i n The corresponding compilation results are saved in a file, and each UD is initially set. i n In the untraversed state, the intermediate record parameter LR is initially set to empty.
[0026] The intermediate data storage file is used to store the usage records of the file during the multi-step compilation process, and all F n The corresponding usage records can be stored in the same intermediate data storage file, or they can be stored separately for each F. n Configure the corresponding intermediate data save file. Preferably, all F n The corresponding usage records can be stored in the same intermediate data storage file. It is understandable that when F... n When performing a single-step compilation operation for the first time, {UD1 n UD2 n ,...,UD i n ,...,UD f(n) n} is set to empty.
[0027] Step S22, if {UD1 n UD2 n ,...,UD i n ,...,UD f(n) n There are untraversed UDs in} i n If the condition is met, proceed to step S23; otherwise, proceed to step S30.
[0028] Step S23: Obtain an untraversed UD i n Set as the current pending record (CR).
[0029] Step S24: If the compilation result file in CR is the same as that in LB, then proceed to step S25; otherwise, proceed to step S26.
[0030] It should be noted that for the same source file and LB combination, there is at most one record in the intermediate data saving file, and the record that is always kept is the record based on the latest use of the file and LB combination.
[0031] Step S25, delete the CR in {UD1 n , UD2 n ,..., UD i n ,..., UD f(n) n}, and return to step S22.
[0032] Step S26, if the current LR is empty, execute step S28, otherwise, execute step S27.
[0033] Step S27, if the last modification time of the source file in the CR is greater than the last modification time of the source file in the LR, execute step S28, otherwise, execute step S29.
[0034] Step S28, set LR = CR, and execute step S29.
[0035] Step S29, mark the CR in {UD1 n , UD2 n ,..., UD i n ,..., UD f(n) n} as having been traversed, and return to step S22.
[0036] Step S30, if the current LR is empty, execute step S33, otherwise, execute step S31.
[0037] Step S31, if the last modification time of the source file in the LR is less than MT, execute step S33, otherwise, execute step S32.
[0038] Step S32, determine the source file backup path corresponding to the current LR as the latest backup path CP, and set F n The source file backup path BP corresponding to the current execution of the single-step compilation operation is equal to CP, and execute step S34.
[0039] It can be understood that the UD i n in the current LR is always the UD i n with the latest modification time.
[0040] Step S33, set F nthe current source file backup to the backup storage path, generate the corresponding latest backup path CP, and then set the F n The source file backup path BP corresponding to the current single-step compilation operation is equal to CP.
[0041] Through the above judgment, only when it is determined that the F n The source file corresponding to the current single-step compilation operation is modified compared to the F n The latest backup path, the current F n Backup to the backup folder, generate the corresponding latest backup path CP, set the source file backup path BP corresponding to the current single-step compilation operation equal to CP, otherwise, set the source file backup path BP corresponding to the current single-step compilation operation equal to the latest backup path of the F n The latest backup path, which can accurately and quickly record the source code file content corresponding to the compilation result under multi-step compilation with very little memory expenditure.
[0042] Step S34, generate the F n The use record {FP n , BP, MT, LB} corresponding to the current single-step compilation operation is stored in the intermediate data saving file, and the step S1 is returned.
[0043] It should be noted that the F n The use record {FP n , BP, MT, LB} corresponding to the current single-step compilation operation generated in step S34 is stored in the intermediate data saving file for subsequent judgment.
[0044] As an embodiment, the method further comprises:
[0045] Step S3, if all F n Perform single-step compilation, then combine all the compilation result saving files LB into a to-be-processed file.
[0046] Step S4, convert the to-be-processed file into an executable file.
[0047] It should be noted that the existing multi-step compilation tool implements steps S3 and S4 in a manner falling within the protection scope of the present application.
[0048] As an embodiment, the method further comprises:
[0049] Step S5, based on the executable file, simulation is performed to generate a simulation result.
[0050] It should be noted that the existing simulation implements step S5 in a manner falling within the protection scope of the present application.
[0051] Step S6, determining the target F based on the simulation result n and the target LB.
[0052] Wherein, the target F to be debugged can be determined based on the simulation result n and the target LB. n The corresponding target LB.
[0053] Step S7, querying the intermediate data saving file based on the target F n and the target LB to determine the corresponding target source file backup path.
[0054] Step S8, performing a debugging operation based on the source file under the target source file backup path.
[0055] It should be noted that the present embodiment has accurately and clearly recorded the corresponding file backup path of each group of F n and LB before simulation, so the target source file backup path can be determined by querying the intermediate data saving file based on the target F n and the target LB, and the source file under the target source file backup path can be accurately and quickly located based on the target source file backup path, so that the result mismatch problem does not occur. The corresponding debugging operation can be performed based on the source file under the target source file backup path, and the specific debugging operation is not limited and can be performed according to the specific application requirement.
[0056] In the process of performing single-step compilation on each file involved in multi-step compilation, whether the file is modified compared with the latest backup path is determined to determine whether backup is needed, and the source file backup path under single-step compilation corresponding to each file is determined, so that the present application can accurately and quickly record the source code file content corresponding to the compilation result under multi-step compilation with little memory expenditure.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for describing specific embodiments only and is not intended to be limiting. As used in this description, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0058] It should be noted that some example embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts depict the steps in sequential order, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps can be re-arranged. A process can be terminated when its operations are completed, but could also occur over longer periods of time. Processes might also have additional steps not included in the figure. A process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0059] The embodiment of the present application further provides an electronic device, comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executed by the at least one processor, and the instructions are arranged to execute the method of the embodiment of the present application.
[0060] The embodiment of the present application further provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are used for executing the method of the embodiment of the present application.
[0061] The above is only the preferred embodiment of the present application, and does not limit the present application in any form. Although the present application has been disclosed as above with the preferred embodiment, it is not intended to limit the present application. Any person skilled in the art can make some changes or modifications to the above disclosed technical contents to obtain equivalent embodiments with equivalent changes, without departing from the technical solution of the present application. Any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application still belong to the scope of the technical solution of the present application.
Claims
1. A source file backup method suitable for multi-step compilation, characterized by, Comprising: Step S1, obtaining F n Corresponding full path FP n And F n The last modification time MT of the source file corresponding to the current single-step compilation operation and F n The compilation result saving file LB corresponding to the current single-step compilation operation and F n For the nth source file participating in multi-step compilation, n ranges from 1 to N, and N is the total number of source files participating in multi-step compilation; Step S2, compare F n the current source file and the source file under the latest backup path CP of F n , if same, directly set F n the source file backup path BP corresponding to the current single-step compilation operation is equal to CP, otherwise, backup F n the current source file to the backup storage path to generate the latest backup path CP, and then set F n the source file backup path BP corresponding to the current single-step compilation operation is equal to CP, return to step S1; The step S2 comprises: Step S21: Obtain F from the current intermediate data save file n The corresponding usage record set {UD1} n UD2 n ,...,UD i n ,...,UD f(n) n }, UD i n For F n The corresponding i-th usage record, UD i n ={FP n BP i n ,MT i n ,LB i n }, BP i n For UD i n The corresponding source file backup path, MT i n For UD i n The corresponding source file's last modified time, LB i n For UD i n The corresponding compilation results are saved in a file, and each UD is initially set. i n In the untraversed state, the intermediate record parameter LR is initially set to empty; Step S22, if {UD1 n UD2 n ,...,UD i n ,...,UD f(n) n There are untraversed UDs in} i n If the result is positive, proceed to step S23; otherwise, proceed to step S30. Step S23, obtaining an untraversed UD i n is set as the current to-be-processed use record CR; Step S24, if the compiling result save file in the CR is same as the LB, step S25 is executed, otherwise, step S26 is executed; Step S25, delete the CR in {UD1 n ,UD2 n ,...,UD i n ,...,UD f(n) n}, return to step S22; Step S26, if the current LR is empty, step S28 is executed, otherwise, step S27 is executed; Step S27, if the source file last modification time in the CR is greater than the source file last modification time in the LR, step S28 is executed, otherwise, step S29 is executed; Step S28, setting LR=CR, step S29 is executed; Step S29, mark the CR in {UD1 n ,UD2 n ,...,UD i n ,...,UD f(n) n} as traversed state, and return to step S22; Step S30, if the current LR is empty, step S33 is executed, otherwise, step S31 is executed; Step S31, if the source file last modification time in the LR is less than the MT, step S33 is executed, otherwise, step S32 is executed; Step S32, determine the source file backup path corresponding to the current LR as the latest backup path CP, set F n If the source file backup path BP corresponding to the current single-step compilation operation is equal to CP, execute step S34. Step S33, backup the current source file F n to the backup storage path, generate the corresponding latest backup path CP, and then set F n The source file backup path BP corresponding to the current single-step compilation operation is equal to CP; Step S34, Generate F n The usage record {FP} corresponding to the current single-step compilation operation n Store BP,MT,LB} in an intermediate data save file and return to step S1.
2. The method of claim 1, wherein, The method further comprises: Step S10, in FP n F is modified below n F is updated n corresponding source file last modification time MT.
3. The method of claim 1, wherein, The method further comprises: Step S3, if all F n are executed by the multi-step compilation, all the compilation results are saved in the file LB to be combined into a to-be-processed file. Step S4, converting the to-be-processed file into an executable file.
4. The method of claim 3, wherein, The method further comprises: Step S5, performing simulation based on the executable file to generate a simulation result; Step S6, determining the target F based on the simulation result n and the target LB; Step S7, based on the target F n and the target LB query the intermediate data save file to determine the corresponding target source file backup path; Step S8, performing a debugging operation based on the source file under the target source file backup path.
5. The method of claim 1, wherein, The source file is a chip design source file.
6. An electronic device, comprising: Comprising: At least one processor; And a memory in communication connection with the at least one processor; Wherein, the memory stores instructions executed by the at least one processor, the instructions are set to execute the method of any one of the preceding claims 1-5.
7. A computer-readable storage medium, characterized in that, Computer executable instructions are stored, and the computer executable instructions are used to execute the method of any one of the preceding claims 1-5.
Citation Information
Patent Citations
Software source code processing method and device as well as electronic equipment
CN105630569A
Management method of compiling tasks and management device for compiling tasks
CN105912379A