Gradle 4.2 native cpp debug symbols


(Björn Strömberg) #1

i have a problem i cant seem to figure out, it seems that i do not get my debug symbols for debug buildtype, gradle seems to strip those away?

build.gradle below

apply plugin: "cpp"

task wrapper(type: Wrapper) {
    gradleVersion = '4.2'
}

allprojects {
  buildDir = new File(rootProject.projectDir, "build/" + project.name)
}

model {
  platforms {
    x64 {
        architecture "x86_64"
    }
  }

  buildTypes {
    debug
    release
  }

  binaries {
    all {
      if (buildType == buildTypes.debug) {
        cppCompiler.args "-I/usr/include",  "-g" , "-O0" 
        linker.args "-lboost_chrono", "-lboost_system", "-L/usr/lib"
      }
      else {
        cppCompiler.args "-I/usr/include",  "-O2"
        linker.args "-lboost_chrono", "-lboost_system", "-L/usr/lib"
      }
    }
  }

  components {
    LogCore(NativeLibrarySpec) {
      /* native system dependancys managed with compiler & linker args */
      /* will change this when gradle supports prebuilt libraries in some good way... */
      //lib library: 'boost_chrono',  linkage: 'api'
      //lib library: 'boost_system',  linkage: 'api'

      sources {
        cpp {
          source {
            srcDir  "src"
            include "*.cxx"
          }
          
          exportedHeaders {
            srcDir "inc"
          }
        }
      }
    }
    testLogCore(NativeExecutableSpec)
    {
      sources {
        cpp {
          lib library: "LogCore", linkage: "static"
          source {
            srcDir  "tests"
            include "*.cxx"
          }
        }
      }
    }
  }
}

i would say the executable and library created by the debug buildtype accually should contain debug symbols (-g on arguments above) but they dont according to objdump -h executable or library object

how can i get gradle not to strip debug symbols from debug buildtype?

found something about doNotStrip that android plugin used back with gradle 2…
but i guess the dsl changed a few hundred times since then… hehe…

thanks in advance for help


(Björn Strömberg) #2

no clue what changed, i made a clean and build again, but now i got the debug symbols…

so i guess its a non problem…

does gradle 4.2 cache builds?

cause i waited about 1 hour between last build and clean/build yesterday and since then it works, it builds release without debug symbols and debug with them… before i did only build release spec. so cache is the only logical explanation i can think of…