From 79bdd3f79a59a0edc724039f624e875ae718caf0 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 13 Sep 2021 01:16:02 +0200 Subject: picolibc: add include directory to build artefact This is really just a preparatory commit for musl support. The idea is to store not just the archive file (.a) but also an include directory. This is optional for picolibc but required for musl, so the main purpose of this commit is the refactor needed for this change. --- builder/ar.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'builder/ar.go') diff --git a/builder/ar.go b/builder/ar.go index ee8ba0706..aee6f00ce 100644 --- a/builder/ar.go +++ b/builder/ar.go @@ -18,17 +18,12 @@ import ( // given as a parameter. It is equivalent to the following command: // // ar -rcs -func makeArchive(archivePath string, objs []string) error { +func makeArchive(arfile *os.File, objs []string) error { // Open the archive file. - arfile, err := os.Create(archivePath) - if err != nil { - return err - } - defer arfile.Close() arwriter := ar.NewWriter(arfile) - err = arwriter.WriteGlobalHeader() + err := arwriter.WriteGlobalHeader() if err != nil { - return &os.PathError{Op: "write ar header", Path: archivePath, Err: err} + return &os.PathError{Op: "write ar header", Path: arfile.Name(), Err: err} } // Open all object files and read the symbols for the symbol table. @@ -133,7 +128,7 @@ func makeArchive(archivePath string, objs []string) error { return err } if int64(int32(offset)) != offset { - return errors.New("large archives (4GB+) not supported: " + archivePath) + return errors.New("large archives (4GB+) not supported: " + arfile.Name()) } objfiles[i].archiveOffset = int32(offset) @@ -160,7 +155,7 @@ func makeArchive(archivePath string, objs []string) error { return err } if n != st.Size() { - return errors.New("file modified during ar creation: " + archivePath) + return errors.New("file modified during ar creation: " + arfile.Name()) } // File is not needed anymore. -- cgit v1.2.3