Skip to content

Commit

Permalink
Merge pull request #356 from LeStarch/fix/template-implementation-paths
Browse files Browse the repository at this point in the history
Fixing implementation include paths
  • Loading branch information
bocchino authored Nov 29, 2023
2 parents 7414644 + 52f7ca8 commit b32aa31
Show file tree
Hide file tree
Showing 40 changed files with 60 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ case class ComponentImplWriter(
private def getCppIncludes: CppDoc.Member = {
val userHeaders = List(
"FpConfig.hpp",
s"${s.getRelativePath(fileName).toString}.hpp"
s.getIncludePath(symbol, fileName).toString
)
linesMember(
addBlankPrefix(userHeaders.sorted.map(CppWriter.headerString).map(line)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ case class ComponentTestImplWriter(

private def getHppIncludes: CppDoc.Member = {
val headers = List(
s"${s.getRelativePath(ComputeCppFiles.FileNames.getComponentGTestBase(name))}.hpp",
s"${s.getRelativePath(ComputeCppFiles.FileNames.getComponentImpl(name))}.hpp"
)
ComputeCppFiles.FileNames.getComponentGTestBase(name),
ComputeCppFiles.FileNames.getComponentImpl(name)
).map(s.getIncludePath(symbol, _))
linesMember(
addBlankPrefix(headers.map(CppWriter.headerString).map(line))
)
Expand Down
22 changes: 13 additions & 9 deletions compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,19 @@ case class CppWriterState(
removeComponentQualifiers(psOpt, out1)
}

/** Write include directives as lines */
/** Get an include path for a symbol and a file name base */
def getIncludePath(
sym: Symbol,
fileNameBase: String
): String = {
val loc = sym.getLoc.tuLocation
val fullPath = loc.getNeighborPath(fileNameBase)
val path = removeLongestPathPrefix(fullPath)
s"${path.toString}.hpp"
}

/** Write include directives for autocoded files */
def writeIncludeDirectives(usedSymbols: Iterable[Symbol]): List[String] = {
def getHeaderStr(file: File.JavaPath) =
CppWriter.headerString(s"${file.toString}.hpp")
def getDirectiveForSymbol(sym: Symbol): Option[String] =
for {
fileName <- sym match {
Expand Down Expand Up @@ -160,12 +169,7 @@ case class CppWriterState(
case _ => None
}
}
yield {
val loc = sym.getLoc.tuLocation
val fullPath = loc.getNeighborPath(fileName)
val path = removeLongestPathPrefix(fullPath)
getHeaderStr(path)
}
yield CppWriter.headerString(getIncludePath(sym, fileName))

usedSymbols.map(getDirectiveForSymbol).filter(_.isDefined).map(_.get).toList
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveAsyncProductPortsOnly component implementation class
// ======================================================================

#include "ActiveAsyncProductPortsOnly.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveAsyncProductPortsOnly.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveAsyncProducts component implementation class
// ======================================================================

#include "ActiveAsyncProducts.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveAsyncProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveCommands component implementation class
// ======================================================================

#include "ActiveCommands.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveCommands.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveEvents component implementation class
// ======================================================================

#include "ActiveEvents.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveEvents.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveGetProducts component implementation class
// ======================================================================

#include "ActiveGetProducts.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveGetProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveGuardedProducts component implementation class
// ======================================================================

#include "ActiveGuardedProducts.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveGuardedProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveParams component implementation class
// ======================================================================

#include "ActiveParams.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveParams.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveSerial component implementation class
// ======================================================================

#include "ActiveSerial.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveSerial.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveSyncProducts component implementation class
// ======================================================================

#include "ActiveSyncProducts.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveSyncProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveTelemetry component implementation class
// ======================================================================

#include "ActiveTelemetry.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveTelemetry.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for ActiveTest component implementation class
// ======================================================================

#include "ActiveTest.hpp"
#include "FpConfig.hpp"
#include "impl/ActiveTest.hpp"

namespace M {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// \brief cpp file for Empty component implementation class
// ======================================================================

#include "Empty.hpp"
#include "FpConfig.hpp"
#include "impl/Empty.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveCommands.hpp"
#include "PassiveCommands.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveEvents.hpp"
#include "PassiveEvents.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveGetProductPortsOnly.hpp"
#include "PassiveGetProductPortsOnly.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveGetProducts.hpp"
#include "PassiveGetProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveGuardedProducts.hpp"
#include "PassiveGuardedProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveParams.hpp"
#include "PassiveParams.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveSerial.hpp"
#include "PassiveSerial.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveSyncProductPortsOnly.hpp"
#include "PassiveSyncProductPortsOnly.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveSyncProducts.hpp"
#include "PassiveSyncProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveTelemetry.hpp"
#include "PassiveTelemetry.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/PassiveTest.hpp"
#include "PassiveTest.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedAsyncProductPortsOnly.hpp"
#include "QueuedAsyncProductPortsOnly.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedAsyncProducts.hpp"
#include "QueuedAsyncProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedCommands.hpp"
#include "QueuedCommands.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedEvents.hpp"
#include "QueuedEvents.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedGetProducts.hpp"
#include "QueuedGetProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedGuardedProducts.hpp"
#include "QueuedGuardedProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedParams.hpp"
#include "QueuedParams.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedSerial.hpp"
#include "QueuedSerial.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedSyncProducts.hpp"
#include "QueuedSyncProducts.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedTelemetry.hpp"
#include "QueuedTelemetry.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "FpConfig.hpp"
#include "impl/QueuedTest.hpp"
#include "QueuedTest.hpp"

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-to-cpp/test/component/impl/check-cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ do
cp $base.template.ref.hpp $base.hpp
cp $base.template.ref.cpp $base.cpp
echo "compiling $base.cpp"
$fprime_gcc -I../../../.. -I.. -c $base.cpp $warning_flags
$fprime_gcc -I../../../.. -c $base.cpp $warning_flags
done
Loading

0 comments on commit b32aa31

Please sign in to comment.