7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Ensure deterministic ordering in orcadpcb2 netlist exporter

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18822
This commit is contained in:
JamesJCode 2024-12-19 19:28:55 +00:00
parent e3b0b73ae1
commit c9d74d24f0
2 changed files with 34 additions and 16 deletions
eeschema/netlist_exporters
qa/data/cli/basic_test

View File

@ -23,6 +23,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <vector>
#include <confirm.h>
#include <refdes_utils.h>
@ -64,8 +67,23 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
for( const SCH_SHEET_PATH& sheet : m_schematic->Hierarchy() )
{
// Process symbol attributes
// The rtree returns items in a non-deterministic order (platform-dependent)
// Therefore we need to sort them before outputting to ensure file stability for version
// control and QA comparisons
std::vector<EDA_ITEM*> sheetItems;
for( EDA_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
sheetItems.push_back( item );
auto pred = []( const EDA_ITEM* item1, const EDA_ITEM* item2 )
{
return item1->m_Uuid < item2->m_Uuid;
};
std::sort( sheetItems.begin(), sheetItems.end(), pred );
// Process symbol attributes
for( EDA_ITEM* item : sheetItems )
{
SCH_SYMBOL* symbol = findNextSymbol( item, sheet );

View File

@ -1,7 +1,12 @@
( { EESchema Netlist Version 1.1 created 5/2/2023 8:59:05 PM }
( /eaf8668d-aec7-4209-a3f9-fc7bfb5b931b Resistor_SMD:R_1206_3216Metric R1 10k
( { EESchema Netlist Version 1.1 created 2024-12-19T18:53:31+0000 }
( /203ec3c1-122c-4087-8f6d-2a0dd0b941e6 TestPoint:TestPoint_Pad_3.0x3.0mm J1 Conn_01x01_Pin
( 1 /VCC )
)
( /2a9f5f63-d864-4898-ae3e-539c635e8f2c TestPoint:TestPoint_Pad_3.0x3.0mm J2 Conn_01x01_Pin
( 1 /IN )
)
( /789295bb-2cfb-4a2b-977f-b3831d5aa975 TestPoint:TestPoint_Pad_3.0x3.0mm J4 Conn_01x01_Pin
( 1 GND )
( 2 Net-(U1--) )
)
( /8a4f4d93-4e0c-474b-8535-68c4fef6e828 Capacitor_SMD:C_1206_3216Metric C1 10u
( 1 Net-(U1-+) )
@ -11,22 +16,13 @@
( 1 Net-(U1--) )
( 2 /OUT )
)
( /9efa520e-00e1-47a2-b8dc-bf8e2121d065 TestPoint:TestPoint_Pad_3.0x3.0mm J3 Conn_01x01_Pin
( 1 /OUT )
)
( /2a9f5f63-d864-4898-ae3e-539c635e8f2c TestPoint:TestPoint_Pad_3.0x3.0mm J2 Conn_01x01_Pin
( 1 /IN )
)
( /203ec3c1-122c-4087-8f6d-2a0dd0b941e6 TestPoint:TestPoint_Pad_3.0x3.0mm J1 Conn_01x01_Pin
( 1 /VCC )
)
( /789295bb-2cfb-4a2b-977f-b3831d5aa975 TestPoint:TestPoint_Pad_3.0x3.0mm J4 Conn_01x01_Pin
( 1 GND )
)
( /985a669c-9a7f-4b74-bb4f-9487b164d3aa Resistor_SMD:R_1206_3216Metric R3 10k
( 1 /IN )
( 2 Net-(U1-+) )
)
( /9efa520e-00e1-47a2-b8dc-bf8e2121d065 TestPoint:TestPoint_Pad_3.0x3.0mm J3 Conn_01x01_Pin
( 1 /OUT )
)
( /b8a40376-5e4f-459f-9886-5e9ee83698cf Package_TO_SOT_SMD:SOT-23-5 U1 TLV2371DBV
( 1 /OUT )
( 2 GND )
@ -34,5 +30,9 @@
( 4 Net-(U1--) )
( 5 /VCC )
)
( /eaf8668d-aec7-4209-a3f9-fc7bfb5b931b Resistor_SMD:R_1206_3216Metric R1 10k
( 1 GND )
( 2 Net-(U1--) )
)
)
*