Skip to content

Commit 77abac0

Browse files
author
jantje
committed
#1126 subdir.mk starts to look like something
Changing a header file does not trigger the needed builds
1 parent 565b873 commit 77abac0

File tree

7 files changed

+588
-1280
lines changed

7 files changed

+588
-1280
lines changed

io.sloeber.core/plugin.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
dependencyContentType="org.eclipse.cdt.core.cxxHeader"
187187
id="io.sloeber.compiler.cpp.sketch.input"
188188
name="%inputType.CPP.name"
189-
primaryInput="true"
189+
primaryInput="false"
190190
sourceContentType="org.eclipse.cdt.core.cxxSource">
191191
</inputType>
192192
<outputType
@@ -234,7 +234,7 @@
234234
id="io.sloeber.compiler.c.sketch.input"
235235
multipleOfType="false"
236236
name="%inputType.C.name"
237-
primaryInput="true"
237+
primaryInput="false"
238238
sourceContentType="org.eclipse.cdt.core.cSource">
239239
</inputType>
240240
<outputType
@@ -281,7 +281,7 @@
281281
dependencyContentType="org.eclipse.cdt.core.cxxHeader"
282282
id="io.sloeber.compiler.S.sketch.input"
283283
name="%inputType.Asembly.name"
284-
primaryInput="true"
284+
primaryInput="false"
285285
sourceContentType="org.eclipse.cdt.core.asmSource">
286286
</inputType>
287287
<outputType

io.sloeber.core/src/io/sloeber/managedBuild/Internal/ArduinoGnuMakefileGenerator.java

+26-21
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
280280
// dependency files
281281
/** Collection of Containers which contribute source files to the build */
282282
private Collection<IContainer> subdirList;
283-
private IPath topBuildDir;
283+
private IFile topBuildDir;
284284
final HashMap<String, List<IPath>> buildSrcVars = new HashMap<>();
285285
final HashMap<String, List<IPath>> buildOutVars = new HashMap<>();
286286
final HashMap<String, ArduinoGnuDependencyGroupInfo> buildDepVars = new HashMap<>();
@@ -348,7 +348,7 @@ public void initialize(IProject project, IManagedBuildInfo info, IProgressMonito
348348
builder = config.getEditableBuilder();
349349
initToolInfos();
350350
// set the top build dir path
351-
topBuildDir = project.getFolder(info.getConfigurationName()).getFullPath();
351+
topBuildDir = project.getFile(info.getConfigurationName());
352352
}
353353

354354
/**
@@ -364,11 +364,12 @@ private void callDependencyPostProcessors(IResourceInfo rcInfo, ToolInfoHolder h
364364
IPath absolutePath = new Path(
365365
EFSExtensionManager.getDefault().getPathFromURI(depFile.getLocationURI()));
366366
// Convert to build directory relative
367-
IPath depPath = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), absolutePath);
367+
IPath depPath = ManagedBuildManager.calculateRelativePath(getTopBuildDir().getFullPath(), absolutePath);
368368
for (int i = 0; i < postProcessors.length; i++) {
369369
IManagedDependencyGenerator2 depGen = postProcessors[i];
370370
if (depGen != null) {
371-
depGen.postProcessDependencyFile(depPath, config, h.buildTools[i], getTopBuildDir());
371+
depGen.postProcessDependencyFile(depPath, config, h.buildTools[i],
372+
getTopBuildDir().getFullPath());
372373
}
373374
}
374375
}
@@ -475,7 +476,7 @@ public boolean visit(PathSettingsContainer container) {
475476
continue;
476477
DepInfo di = (DepInfo) cr.getValue();
477478
ToolInfoHolder h = ToolInfoHolder.getToolInfo(this, projectRelativePath);
478-
IPath buildRelativePath = topBuildDir.append(projectRelativePath);
479+
IPath buildRelativePath = topBuildDir.getFullPath().append(projectRelativePath);
479480
IFolder buildFolder = root.getFolder(buildRelativePath);
480481
if (buildFolder == null)
481482
continue;
@@ -544,11 +545,12 @@ public MultiStatus generateMakefiles(IResourceDelta delta) throws CoreException
544545
return status;
545546
}
546547
// Make sure the build directory is available
547-
topBuildDir = createDirectory(project, config.getName());
548+
topBuildDir = project.getFile(config.getName());
549+
createDirectory(project, config.getName());
548550
checkCancel();
549551
// Make sure that there is a makefile containing all the folders
550552
// participating
551-
IPath srcsFilePath = topBuildDir.append(SRCSFILE_NAME);
553+
IPath srcsFilePath = topBuildDir.getFullPath().append(SRCSFILE_NAME);
552554
IFile srcsFileHandle = createFile(srcsFilePath);
553555
buildSrcVars.clear();
554556
buildOutVars.clear();
@@ -616,7 +618,7 @@ public MultiStatus generateMakefiles(IResourceDelta delta) throws CoreException
616618
calculateToolInputsOutputs();
617619
checkCancel();
618620
// Re-create the top-level makefile
619-
IPath makefilePath = topBuildDir.append(MAKEFILE_NAME);
621+
IPath makefilePath = topBuildDir.getFullPath().append(MAKEFILE_NAME);
620622
IFile makefileHandle = createFile(makefilePath);
621623
myTopMakeFileGenerator.populateTopMakefile(makefileHandle, false);
622624
checkCancel();
@@ -651,7 +653,7 @@ public MultiStatus generateMakefiles(IResourceDelta delta) throws CoreException
651653
@Override
652654
public IPath getBuildWorkingDir() {
653655
if (topBuildDir != null) {
654-
return topBuildDir.removeFirstSegments(1);
656+
return topBuildDir.getFullPath().removeFirstSegments(1);
655657
}
656658
return null;
657659
}
@@ -720,7 +722,7 @@ public boolean visit(PathSettingsContainer container) {
720722
IResourceInfo rcInfo = config.getResourceInfo(container.getPath(), false);
721723
for (IPath path : getDependencyMakefiles(h)) {
722724
// The path to search for the dependency makefile
723-
IPath relDepFilePath = topBuildDir.append(path);
725+
IPath relDepFilePath = topBuildDir.getFullPath().append(path);
724726
IFile depFile = root.getFile(relDepFilePath);
725727
if (depFile == null || !depFile.isAccessible())
726728
continue;
@@ -765,10 +767,11 @@ public MultiStatus regenerateMakefiles() throws CoreException {
765767
return status;
766768
}
767769
// Create the top-level directory for the build output
768-
topBuildDir = createDirectory(project, config.getName());
770+
topBuildDir = project.getFile(config.getName());
771+
createDirectory(project, config.getName());
769772
checkCancel();
770773
// Get the list of subdirectories
771-
IPath srcsFilePath = topBuildDir.append(SRCSFILE_NAME);
774+
IPath srcsFilePath = topBuildDir.getFullPath().append(SRCSFILE_NAME);
772775
IFile srcsFileHandle = createFile(srcsFilePath);
773776
buildSrcVars.clear();
774777
buildOutVars.clear();
@@ -793,13 +796,13 @@ public MultiStatus regenerateMakefiles() throws CoreException {
793796
calculateToolInputsOutputs();
794797
checkCancel();
795798
// Create the top-level makefile
796-
IPath makefilePath = topBuildDir.append(MAKEFILE_NAME);
799+
IPath makefilePath = topBuildDir.getFullPath().append(MAKEFILE_NAME);
797800
IFile makefileHandle = createFile(makefilePath);
798801
myTopMakeFileGenerator.populateTopMakefile(makefileHandle, true);
799802
// JABA SLOEBER create the size.awk file
800803
ICConfigurationDescription confDesc = ManagedBuildManager.getDescriptionForConfiguration(config);
801804
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
802-
IFile sizeAwkFile1 = root.getFile(topBuildDir.append("size.awk"));
805+
IFile sizeAwkFile1 = root.getFile(topBuildDir.getFullPath().append("size.awk"));
803806
File sizeAwkFile = sizeAwkFile1.getLocation().toFile();
804807
String regex = Common.getBuildEnvironmentVariable(confDesc, "recipe.size.regex", EMPTY);
805808
String awkContent = "/" + regex + "/ {arduino_size += $2 }\n";
@@ -825,7 +828,7 @@ public MultiStatus regenerateMakefiles() throws CoreException {
825828
// END JABA SLOEBER create the size.awk file
826829
checkCancel();
827830
// Now finish up by adding all the object files
828-
IPath objFilePath = topBuildDir.append(OBJECTS_MAKFILE);
831+
IPath objFilePath = topBuildDir.getLocation().append(OBJECTS_MAKFILE);
829832
IFile objsFileHandle = createFile(objFilePath);
830833
populateObjectsMakefile(objsFileHandle);
831834
checkCancel();
@@ -1290,8 +1293,9 @@ private void deleteBuildTarget(IResource deletedFile) {
12901293

12911294
private IPath inFullPathFromOutFullPath(IPath path) {
12921295
IPath inPath = null;
1293-
if (topBuildDir.isPrefixOf(path)) {
1294-
inPath = path.removeFirstSegments(topBuildDir.segmentCount());
1296+
IPath topBuildPath = topBuildDir.getFullPath();
1297+
if (topBuildPath.isPrefixOf(path)) {
1298+
inPath = path.removeFirstSegments(topBuildPath.segmentCount());
12951299
inPath = project.getFullPath().append(path);
12961300
}
12971301
return inPath;
@@ -1323,7 +1327,8 @@ private void deleteDepFile(IResource deletedFile) {
13231327
if (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND) {
13241328
depFilePaths = new IPath[1];
13251329
IPath absolutePath = deletedFile.getLocation();
1326-
depFilePaths[0] = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), absolutePath);
1330+
depFilePaths[0] = ManagedBuildManager.calculateRelativePath(getTopBuildDir().getFullPath(),
1331+
absolutePath);
13271332
depFilePaths[0] = depFilePaths[0].removeFileExtension().addFileExtension(DEP_EXT);
13281333
} else if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS
13291334
|| calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) {
@@ -1497,8 +1502,8 @@ protected void updateMonitor(String msg) {
14971502
/**
14981503
* Return the configuration's top build directory as an absolute path
14991504
*/
1500-
public IPath getTopBuildDir() {
1501-
return getPathForResource(project).append(getBuildWorkingDir());
1505+
public IFile getTopBuildDir() {
1506+
return topBuildDir;
15021507
}
15031508

15041509
@Override
@@ -1551,7 +1556,7 @@ public void initialize(int buildKind, IConfiguration cfg, IBuilder builder, IPro
15511556
this.builder = builder;
15521557
initToolInfos();
15531558
// set the top build dir path
1554-
topBuildDir = project.getFolder(cfg.getName()).getFullPath();
1559+
topBuildDir = project.getFile(cfg.getName());
15551560
srcEntries = config.getSourceEntries();
15561561
if (srcEntries.length == 0) {
15571562
srcEntries = new ICSourceEntry[] {

io.sloeber.core/src/io/sloeber/managedBuild/Internal/ArduinoManagedBuildGnuToolInfo.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,8 @@ public boolean calculateInputs(ArduinoGnuMakefileGenerator makeGen, IConfigurati
394394
if (addlResource != null) {
395395
IPath addlPath = addlResource.getLocation();
396396
if (addlPath != null) {
397-
path = ManagedBuildManager
398-
.calculateRelativePath(makeGen.getTopBuildDir(), addlPath)
399-
.toOSString();
397+
path = ManagedBuildManager.calculateRelativePath(
398+
makeGen.getTopBuildDir().getFullPath(), addlPath).toOSString();
400399
}
401400
}
402401
}
@@ -437,7 +436,8 @@ public boolean calculateInputs(ArduinoGnuMakefileGenerator makeGen, IConfigurati
437436
IPath enumPath = enumResource.getLocation();
438437
if (enumPath != null) {
439438
paths[j] = ManagedBuildManager
440-
.calculateRelativePath(makeGen.getTopBuildDir(), enumPath).toOSString();
439+
.calculateRelativePath(makeGen.getTopBuildDir().getFullPath(), enumPath)
440+
.toOSString();
441441
}
442442
}
443443
}
@@ -869,8 +869,8 @@ private boolean callDependencyCalculator(ArduinoGnuMakefileGenerator makeGen, IC
869869
// Convert from project relative to
870870
// build directory relative
871871
IPath absolutePath = this.project.getLocation().append(depPaths[j]);
872-
depPaths[j] = ManagedBuildManager
873-
.calculateRelativePath(makeGen.getTopBuildDir(), absolutePath);
872+
depPaths[j] = ManagedBuildManager.calculateRelativePath(
873+
makeGen.getTopBuildDir().getFullPath(), absolutePath);
874874
}
875875
myCommandDependencies.add(depPaths[j].toOSString());
876876
}
@@ -950,9 +950,8 @@ public boolean calculateDependencies(ArduinoGnuMakefileGenerator makeGen, IConfi
950950
if (addlResource != null) {
951951
IPath addlPath = addlResource.getLocation();
952952
if (addlPath != null) {
953-
path = ManagedBuildManager
954-
.calculateRelativePath(makeGen.getTopBuildDir(), addlPath)
955-
.toOSString();
953+
path = ManagedBuildManager.calculateRelativePath(
954+
makeGen.getTopBuildDir().getFullPath(), addlPath).toOSString();
956955
}
957956
}
958957
}

0 commit comments

Comments
 (0)