Skip to content

Commit fe4310e

Browse files
committed
fix: account for space to underscore conversion
1 parent 0f2cc04 commit fe4310e

File tree

3 files changed

+384
-5
lines changed

3 files changed

+384
-5
lines changed

example/example 3.usp

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*******************************************************************************************
2+
Compiler Directives
3+
(Uncomment and declare compiler directives as needed)
4+
*******************************************************************************************/
5+
// #ENABLE_DYNAMIC
6+
// #SYMBOL_NAME
7+
// #HINT ""
8+
// #DEFINE_CONSTANT
9+
// #CATEGORY
10+
#PRINT_TO_TRACE
11+
// #DIGITAL_EXPAND
12+
// #ANALOG_SERIAL_EXPAND
13+
// #OUTPUT_SHIFT
14+
// #HELP_PDF_FILE ""
15+
#DEFAULT_VOLATILE
16+
#ENABLE_STACK_CHECKING
17+
#ENABLE_TRACE
18+
#ENCODING_ASCII
19+
// #ENCODING_UTF16
20+
// #ENCODING_INHERIT_FROM_PARENT
21+
// #ENCODING_INHERIT_FROM_PROGRAM
22+
/*
23+
#HELP_BEGIN
24+
(add additional lines of help lines)
25+
#HELP_END
26+
*/
27+
28+
/*******************************************************************************************
29+
Include Libraries
30+
(Uncomment and include additional libraries as needed)
31+
*******************************************************************************************/
32+
// #CRESTRON_LIBRARY ""
33+
// #USER_LIBRARY ""
34+
35+
/*******************************************************************************************
36+
DIGITAL, ANALOG and SERIAL INPUTS and OUTPUTS
37+
(Uncomment and declare inputs and outputs as needed)
38+
*******************************************************************************************/
39+
// DIGITAL_INPUT
40+
// ANALOG_INPUT
41+
// STRING_INPUT
42+
// BUFFER_INPUT
43+
44+
// DIGITAL_OUTPUT
45+
// ANALOG_OUTPUT
46+
// STRING_OUTPUT
47+
48+
/*******************************************************************************************
49+
SOCKETS
50+
(Uncomment and define socket definitions as needed)
51+
*******************************************************************************************/
52+
// TCP_CLIENT
53+
// TCP_SERVER
54+
// UDP_SOCKET
55+
56+
/*******************************************************************************************
57+
Parameters
58+
(Uncomment and declare parameters as needed)
59+
*******************************************************************************************/
60+
// INTEGER_PARAMETER
61+
// SIGNED_INTEGER_PARAMETER
62+
// LONG_INTEGER_PARAMETER
63+
// SIGNED_LONG_INTEGER_PARAMETER
64+
// STRING_PARAMETER
65+
66+
/*******************************************************************************************
67+
Parameter Properties
68+
(Uncomment and declare parameter properties as needed)
69+
*******************************************************************************************/
70+
/*
71+
#BEGIN_PARAMETER_PROPERTIES parameter_variable, parameter_variable, ...
72+
// propValidUnits = // unitString or unitDecimal|unitHex|unitPercent|unitCharacter|unitTime|unitTicks;
73+
// propDefaultUnit = // unitString, unitDecimal, unitHex, unitPercent, unitCharacter, unitTime or unitTicks;
74+
// propBounds = lower_bound , upper_bound;
75+
// propDefaultValue = ; // or, propDefaultValue = "";
76+
// propList = // { "value" , "label" } , { "value" , "label" } , ... ;
77+
// propShortDescription = "status_bar_hint_text";
78+
// #BEGIN_PROP_FULL_DESCRIPTION line_1... line_2... line_n #END_PROP_FULL_DESCRIPTION
79+
// #BEGIN_PROP_NOTES line_1... line_2... line_n #END_PROP_NOTES
80+
#END_PARAMETER_PROPERTIES
81+
*/
82+
83+
/*******************************************************************************************
84+
Structure Definitions
85+
(Uncomment and define structure definitions as needed)
86+
Note: Be sure to initialize all declared STRING variables as needed
87+
For example, in Function Main: struct.myString = "";
88+
*******************************************************************************************/
89+
/*
90+
STRUCTURE MyStruct1
91+
{
92+
};
93+
94+
MyStruct1 struct;
95+
*/
96+
97+
/*******************************************************************************************
98+
Global Variables
99+
(Uncomment and declare global variables as needed)
100+
Note: Be sure to initialize all declared STRING variables as needed
101+
For example, in Function Main: myString = "";
102+
*******************************************************************************************/
103+
// INTEGER
104+
// LONG_INTEGER
105+
// SIGNED_INTEGER
106+
// SIGNED_LONG_INTEGER
107+
// STRING
108+
109+
/*******************************************************************************************
110+
Functions
111+
(Add any additional functions here)
112+
Note: Functions must be physically placed before the location in
113+
the code that calls them.
114+
*******************************************************************************************/
115+
116+
117+
/*******************************************************************************************
118+
Event Handlers
119+
(Uncomment and declare additional event handlers as needed)
120+
*******************************************************************************************/
121+
122+
123+
/*******************************************************************************************
124+
Main()
125+
Uncomment and place one-time startup code here
126+
(This code will get called when the system starts up)
127+
*******************************************************************************************/
128+
Function Main() {
129+
print("Hello, Example 2!\n");
130+
}

internal/cache/artifacts.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"io"
2525
"os"
2626
"path/filepath"
27+
"strings"
2728
)
2829

2930
// CopyArtifacts copies compiled outputs from a base directory to cache
@@ -225,22 +226,51 @@ func isOutputFile(filename, baseName string) bool {
225226
// isOutputFileForTarget checks if a file belongs to the given source AND target
226227
// For target "34", only matches example1.* (not S2_example1.*)
227228
// For target "234", matches both example1.* and S2_example1.*
229+
//
230+
// Handles the compiler's space-to-underscore conversion:
231+
// - Source: "example 3.usp"
232+
// - .ush/.inf files: "example 3.ush" (spaces kept)
233+
// - .cs/.dll files: "example_3.cs" (spaces→underscores)
234+
// - S2_* files: "S2_example_3.c" (spaces→underscores)
235+
//
236+
// Important: .cs, .dll, .inf files are Series 3/4 specific (no S3_/S4_ prefix)
237+
// For target "2", only match S2_* files (and .ush which is always present)
228238
func isOutputFileForTarget(filename, baseName, target string) bool {
229239
fileBase := filename[:len(filename)-len(filepath.Ext(filename))]
240+
ext := filepath.Ext(filename)
230241

231-
// Direct match: example1.dll, example1.cs, etc.
232-
// These are for Series 3 and 4
233-
if fileBase == baseName {
242+
// Create underscore version of baseName for comparison
243+
// The compiler converts spaces to underscores in certain file types
244+
baseNameWithUnderscore := strings.ReplaceAll(baseName, " ", "_")
245+
246+
// .ush files are always included (generated for all targets)
247+
if ext == ".ush" && (fileBase == baseName || fileBase == baseNameWithUnderscore) {
234248
return true
235249
}
236250

251+
// Direct match: example1.dll, example1.cs, example1.inf, etc. or example_3.dll, example_3.cs
252+
// These are for Series 3 and 4 ONLY (they have no prefix)
253+
// Skip these if target is only Series 2
254+
if fileBase == baseName || fileBase == baseNameWithUnderscore {
255+
// .cs, .dll, .inf are Series 3/4 specific
256+
if ext == ".cs" || ext == ".dll" || ext == ".inf" {
257+
return contains(target, '3') || contains(target, '4')
258+
}
259+
// Other extensions (if any) also belong to Series 3/4
260+
return contains(target, '3') || contains(target, '4')
261+
}
262+
237263
// Target-prefixed match: S2_example1.c, S2_example1.h, S3_example1.*, S4_example1.*
264+
// Also matches: S2_example_3.c when source is "example 3.usp"
238265
if len(fileBase) > 3 && fileBase[0] == 'S' && fileBase[2] == '_' {
239266
// Extract the series number
240267
seriesChar := fileBase[1]
241268

242-
// Extract the base name after prefix
243-
if fileBase[3:] == baseName {
269+
// Extract the base name after prefix (e.g., "example1" from "S2_example1")
270+
nameAfterPrefix := fileBase[3:]
271+
272+
// Check if this matches our base name (with or without underscores)
273+
if nameAfterPrefix == baseName || nameAfterPrefix == baseNameWithUnderscore {
244274
// Check if this series is in the target
245275
// For example, if target="34", we want Series 3 and 4, not Series 2
246276
switch seriesChar {

0 commit comments

Comments
 (0)