compile.go 885 B

123456789101112131415161718192021222324252627282930313233343536
  1. package commands
  2. import (
  3. "fmt"
  4. . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/common"
  5. . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/gen"
  6. "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/flag"
  7. "github.com/davecgh/go-spew/spew"
  8. )
  9. func compile() (err error) {
  10. var project *Project
  11. fmt.Println("COMPILE WITH SETUP...", *flag.Mode, *flag.BuildProfile, *flag.Out)
  12. // Cria um novo projeto a partir do diretorio atual
  13. if project, err = CreateProject(*flag.Mode); err != nil {
  14. panic(err)
  15. }
  16. project.OutDirectory(*flag.Out)
  17. // Executa a geracao de codigo para o projeto
  18. if err = project.Build(&BuildOptions{
  19. Mode: *flag.BuildProfile,
  20. }); err != nil {
  21. spew.Dump(err)
  22. panic(err)
  23. }
  24. // Salva o json contendo a descricao completa do projeto
  25. if err = project.Save(fmt.Sprintf("%s/project.gen.json", *flag.Out)); err != nil {
  26. panic(err)
  27. }
  28. return
  29. }