@@ -916,7 +916,11 @@ func (s *Session) BuildFiles(filenames []string, pkgObj string, cwd string) erro
916916 })
917917 }
918918
919- archive , err := s .BuildAndCompileProject (pkg )
919+ parsed , err := s .BuildPackage (pkg )
920+ if err != nil {
921+ return err
922+ }
923+ archive , err := s .CompilePackage (parsed )
920924 if err != nil {
921925 return err
922926 }
@@ -1053,32 +1057,18 @@ func (s *Session) CompilePackage(pkg *ParsedPackage) (*compiler.Archive, error)
10531057 return archive , nil
10541058}
10551059
1056- // BuildAndCompileProject builds and compiles a package.
1057- //
1058- // The package should be the entry point (main or tests) for a project.
1059- // This should not be called recursively because it expects all the dependencies
1060- // to be built prior to any part being compiled.
1061- func (s * Session ) BuildAndCompileProject (pkg * PackageData ) (* compiler.Archive , error ) {
1062- parsed , err := s .BuildPackage (pkg )
1063- if err != nil {
1064- return nil , err
1065- }
1066- return s .CompilePackage (parsed )
1067- }
1068-
10691060// ImportResolverFor returns a function which returns a compiled package archive
10701061// given an import path.
10711062func (s * Session ) ImportResolverFor (srcDir string ) func (string ) (* compiler.Archive , error ) {
10721063 return func (path string ) (* compiler.Archive , error ) {
10731064 if archive , ok := s .UpToDateArchives [path ]; ok {
10741065 return archive , nil
10751066 }
1076- _ , parser , err := s . buildImportPathWithSrcDir ( path , srcDir )
1077- if err != nil {
1078- return nil , err
1067+ // If the archive doesn't already exist, compile the parsed package.
1068+ if parsed , ok := s . ParsedPackages [ path ]; ok {
1069+ return s . CompilePackage ( parsed )
10791070 }
1080-
1081- return s .CompilePackage (parser )
1071+ return nil , fmt .Errorf (`parsed package for %q not found` , path )
10821072 }
10831073}
10841074
0 commit comments