diff options
author | Ayke van Laethem <[email protected]> | 2021-09-13 01:16:02 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-11-04 17:15:38 +0100 |
commit | 79bdd3f79a59a0edc724039f624e875ae718caf0 (patch) | |
tree | 73dd5510cd7eaa23e64b8f91c52e15e20266c29d /builder/ar.go | |
parent | 39ff13fd1a31610f5fe733cb38908c8563643981 (diff) | |
download | tinygo-79bdd3f79a59a0edc724039f624e875ae718caf0.tar.gz tinygo-79bdd3f79a59a0edc724039f624e875ae718caf0.zip |
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.
Diffstat (limited to 'builder/ar.go')
-rw-r--r-- | builder/ar.go | 15 |
1 files changed, 5 insertions, 10 deletions
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 <archivePath> <objs...> -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. |