From d078f6dc10eb265a5d88cd96adf86173d6d3ba2e Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Thu, 2 Sep 2021 03:14:47 -0500 Subject: Make adapters and internals complient with new directory structure --- adapters/gtest/templating.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'adapters/gtest/templating.go') diff --git a/adapters/gtest/templating.go b/adapters/gtest/templating.go index c49f170..a9a3b07 100644 --- a/adapters/gtest/templating.go +++ b/adapters/gtest/templating.go @@ -80,5 +80,3 @@ include(GoogleTest) FetchContent_MakeAvailable(googletest) `)) } - - -- cgit v1.2.3 From 151d516e68f5d43aa2d0c5ff462752d640b6a614 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sun, 5 Sep 2021 00:37:23 -0500 Subject: Refactor gtest adapter to fit new pipeline --- adapters/gtest/templating.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'adapters/gtest/templating.go') diff --git a/adapters/gtest/templating.go b/adapters/gtest/templating.go index a9a3b07..57532fa 100644 --- a/adapters/gtest/templating.go +++ b/adapters/gtest/templating.go @@ -8,12 +8,12 @@ import ( ) type cmakeUnit struct { - Cname string + ExeNm string File string Srcs string }; -func genCmake(out string, units []cmakeUnit) { +func generateCmakeScript(out string, units []cmakeUnit) { file, err := os.OpenFile(out, os.O_RDWR | os.O_CREATE, 0644) defer func () { err := file.Close() @@ -33,27 +33,29 @@ func genCmake(out string, units []cmakeUnit) { for _, unit := range units { if err := tmpl.Execute(file, unit); err != nil { - log.Fatalf("Failed to generate unit %s: %v", unit.Cname, err); + log.Fatalf("Failed to generate unit %s: %v", unit.ExeNm, err); } } } +// TODO: Add comments func unitTemplate() *template.Template { tmpl, err := template.New("gtest_unit").Parse(` + add_executable( - "{{.Cname}}" + "{{.ExeNm}}" "{{.File}}" {{.Srcs}} ) target_link_libraries( - "{{.Cname}}" + "{{.ExeNm}}" gtest_main ) gtest_discover_tests( - "{{.Cname}}" + "{{.ExeNm}}" ) `) -- cgit v1.2.3 From 4cc29e50d59daf445f4152d10f9f41cb1828f702 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sun, 5 Sep 2021 01:00:12 -0500 Subject: Remove pointers and cleanup templating, add version info --- adapters/gtest/templating.go | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'adapters/gtest/templating.go') diff --git a/adapters/gtest/templating.go b/adapters/gtest/templating.go index 57532fa..41c54c1 100644 --- a/adapters/gtest/templating.go +++ b/adapters/gtest/templating.go @@ -3,8 +3,9 @@ package gtest import ( "io" "log" - "text/template" "os" + "golang.flu0r1ne.net/planr" + "text/template" ) type cmakeUnit struct { @@ -27,7 +28,7 @@ func generateCmakeScript(out string, units []cmakeUnit) { log.Fatalf("Could not open CMakeFile (%s)\n%v", out, err) } - writeBoiler(file) + writeCmakeBoilerplate(file) tmpl := unitTemplate() @@ -43,6 +44,10 @@ func generateCmakeScript(out string, units []cmakeUnit) { func unitTemplate() *template.Template { tmpl, err := template.New("gtest_unit").Parse(` +################################################ + +## {{.ExeNm}} + add_executable( "{{.ExeNm}}" "{{.File}}" @@ -60,14 +65,30 @@ gtest_discover_tests( `) if err != nil { - log.Fatalf("Cannot load Gtest Unit Template %v", err) + log.Fatalf("Cannot load Gtest unit template %v", err) } return tmpl } -func writeBoiler(w io.Writer) { - w.Write([]byte(` +const GOOGLE_TEST_URL = "https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip" + +func writeCmakeBoilerplate(w io.Writer) { + tmpl := boilderTemplate() + + tmpl.Execute(w, struct { + Url string + Version string + }{ + Url: GOOGLE_TEST_URL, + Version: planr.VERSION, + }) +} + +func boilderTemplate() *template.Template { + tmpl, err := template.New("gtest_boilerplate").Parse(` +# AUTOMATICALLY GENERATED BY PLANR VERSION {{.Version}} + cmake_minimum_required (VERSION 3.1.0) project(PlanRGtestAdapter) @@ -75,10 +96,16 @@ project(PlanRGtestAdapter) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + URL {{.Url}} ) include(GoogleTest) FetchContent_MakeAvailable(googletest) -`)) +`) + + if err != nil { + log.Fatalf("Cannot load Gtest Cmake boilerplate") + } + + return tmpl } -- cgit v1.2.3