@@ -71,7 +71,7 @@ public ProcessingItem[] getProcessingItems(@NotNull final CompileContext context
71
71
72
72
try {
73
73
if (ocamlContext .isStandaloneCompile ()) {
74
- ocamlModules .addAll (collectItemsForStandaloneCompile (context , items , isDebugMode ));
74
+ ocamlModules .addAll (collectItemsForStandaloneCompile (context , items ));
75
75
}
76
76
else {
77
77
final OCamlModule mainOCamlModule = getMainOCamlModule (ocamlContext );
@@ -85,26 +85,32 @@ public ProcessingItem[] getProcessingItems(@NotNull final CompileContext context
85
85
return new ProcessingItem [0 ];
86
86
}
87
87
88
+ final boolean isRebuild = context .isRebuild ();
88
89
final LocalFileSystem fileSystem = LocalFileSystem .getInstance ();
89
90
for (final OCamlModule ocamlModule : ocamlModules ) {
90
- processFile (fileSystem .findFileByIoFile (ocamlModule .getInterfaceFile ()), items , isDebugMode );
91
- processFile (fileSystem .findFileByIoFile (ocamlModule .getImplementationFile ()), items , isDebugMode );
91
+ processFile (fileSystem .findFileByIoFile (ocamlModule .getInterfaceFile ()), ocamlModule . getCompiledInterfaceFile (), items , isDebugMode , isRebuild );
92
+ processFile (fileSystem .findFileByIoFile (ocamlModule .getImplementationFile ()), ocamlModule . getCompiledImplementationFile (), items , isDebugMode , isRebuild );
92
93
}
93
94
94
95
return items .toArray (new ProcessingItem [items .size ()]);
95
96
}
96
97
97
- private void processFile (@ Nullable final VirtualFile file , @ NotNull final ArrayList <ProcessingItem > items , final boolean isDebugMode ) {
98
+ private void processFile (@ Nullable final VirtualFile file ,
99
+ @ NotNull final File compiledFile ,
100
+ @ NotNull final ArrayList <ProcessingItem > items ,
101
+ final boolean isDebugMode ,
102
+ final boolean isRebuild ) {
98
103
if (file != null ) {
99
- items .add (createProcessingItem (file , isDebugMode ));
104
+ items .add (createProcessingItem (file , compiledFile , isDebugMode , isRebuild ));
100
105
}
101
106
}
102
107
103
108
@ NotNull
104
109
private List <OCamlModule > collectItemsForStandaloneCompile (@ NotNull final CompileContext context ,
105
- @ NotNull final ArrayList <ProcessingItem > items ,
106
- final boolean isDebugMode ) throws CyclicDependencyException {
110
+ @ NotNull final ArrayList <ProcessingItem > items
111
+ ) throws CyclicDependencyException {
107
112
final Project project = context .getProject ();
113
+ final ProjectFileIndex projectFileIndex = ProjectRootManager .getInstance (project ).getFileIndex ();
108
114
final Set <OCamlModule > ocamlModules = new HashSet <OCamlModule >();
109
115
final Module [] modules = ModuleManager .getInstance (project ).getModules ();
110
116
for (final Module module : modules ) {
@@ -119,7 +125,8 @@ private List<OCamlModule> collectItemsForStandaloneCompile(@NotNull final Compil
119
125
ocamlModules .add (ocamlModule );
120
126
}
121
127
else {
122
- items .add (createProcessingItem (file , isDebugMode ));
128
+ final File destDir = OCamlFileUtil .getCompiledDir (projectFileIndex , file .getParent ());
129
+ items .add (createProcessingItem (file , new File (destDir , file .getName ()), false , false ));
123
130
}
124
131
}
125
132
}
@@ -146,7 +153,6 @@ public ProcessingItem[] process(@NotNull final CompileContext context, @NotNull
146
153
final ArrayList <ProcessingItem > processedItems = new ArrayList <ProcessingItem >();
147
154
final ProjectFileIndex fileIndex = ProjectRootManager .getInstance (context .getProject ()).getFileIndex ();
148
155
final OCamlCompileContext ocamlContext = OCamlCompileContext .createOn (context );
149
- final boolean isDebugMode = ocamlContext .isDebugMode ();
150
156
151
157
for (final ProcessingItem item : items ) {
152
158
processedCount ++;
@@ -196,13 +202,10 @@ private boolean compile(@NotNull final VirtualFile file,
196
202
cmd .addParameter ("-c" );
197
203
198
204
final Set <String > addedPaths = new HashSet <String >();
205
+ addPath (cmd , addedPaths , destDir .getPath ());
199
206
for (final OCamlModule dependency : ocamlModule .collectExactDependencies ()) {
200
207
final String path = OCamlFileUtil .getCompiledDir (fileIndex , dependency .getSourcesDir ()).getPath ();
201
- if (!addedPaths .contains (path )) {
202
- cmd .addParameter ("-I" );
203
- cmd .addParameter (path );
204
- }
205
- addedPaths .add (path );
208
+ addPath (cmd , addedPaths , path );
206
209
}
207
210
208
211
cmd .addParameter ("-o" );
@@ -232,6 +235,14 @@ private boolean compile(@NotNull final VirtualFile file,
232
235
return true ;
233
236
}
234
237
238
+ private void addPath (@ NotNull final GeneralCommandLine cmd , @ NotNull final Set <String > addedPaths , @ NotNull final String path ) {
239
+ if (!addedPaths .contains (path )) {
240
+ cmd .addParameter ("-I" );
241
+ cmd .addParameter (path );
242
+ }
243
+ addedPaths .add (path );
244
+ }
245
+
235
246
@ NotNull
236
247
public ValidityState createValidityState (@ NotNull final DataInput in ) throws IOException {
237
248
return OCamlValidityState .load (in );
@@ -285,25 +296,4 @@ public VirtualFile compute() {
285
296
286
297
return destDir [0 ];
287
298
}
288
-
289
- @ NotNull
290
- private ProcessingItem createProcessingItem (@ NotNull final VirtualFile file , final boolean isDebugMode ) {
291
- return new ProcessingItem () {
292
- @ NotNull
293
- public VirtualFile getFile () {
294
- return file ;
295
- }
296
-
297
- @ NotNull
298
- public ValidityState getValidityState () {
299
- final TimestampValidityState timestampValidityState = new TimestampValidityState (file .getTimeStamp ());
300
- if (OCamlFileUtil .isOCamlSourceFile (file )) {
301
- return new OCamlValidityState (timestampValidityState , isDebugMode );
302
- }
303
- else {
304
- return timestampValidityState ;
305
- }
306
- }
307
- };
308
- }
309
299
}
0 commit comments