Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
go plugin: cross-compilation support #1253
Closed
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
8427940
Cross-compilation support for the Go plugin
kalikiana 4c27600
Enable CGO and add cross build libc dependencies
kalikiana e887f17
Have repo verify the cross-compilation setup
kalikiana fbf2222
Set arch-specific PKG_CONFIG_PATH
kalikiana f938208
Add build-packages to cross-compiling deps test
kalikiana c112d77
Avoid too long lines that make flake8 unhappy
kalikiana e7b0033
Explicit -ldflags doesn't seem to be needed
kalikiana 15f3428
Consolidate multi-arch diagnostics
kalikiana 72e0559
Tweak the phrasing of the multi-arch diagnostics
kalikiana a8b4fe6
Add missing space in deb/ arch format
kalikiana bdd02a3
Add integration test for cross-compiling Go
kalikiana 735ad27
Skip cross compiling test on non-amd64
kalikiana 4f79c25
Drop irrelevant icon from go-cgo test snap
kalikiana ad2622f
Setup multi-arch automatically instead of an error
kalikiana fb6da86
Move scenarios before the test
kalikiana 41b3ddf
Adjust expected error messages for missing packages
kalikiana dbc22b2
Reduce complexity of buntu.install_build_packages
kalikiana 8466e13
Use apt-get build-dep to figure out build packages
kalikiana e6b6af9
Expect cross-build dependencies with :native suffix
kalikiana 49c1d8e
Handle errors in apt-get build-dep
kalikiana 593cf0a
_setup_multi_arch returns True if package in cache
kalikiana 5e5a806
Consistent decoding in check_output
kalikiana 684a68d
Mock apt-get build-dep output
kalikiana fbebdf3
Unit test multi-arch build-deps
kalikiana ced39df
Test arch and sources being added if needed
kalikiana 6646c07
Also mock and test apt-get update (errors)
kalikiana 46c7658
Correct versioned package format and unit test
kalikiana c0bcf1d
Add doc strings to new _deb class methods
kalikiana 9ac9b02
Clearer variable name sources_arch{,_file}
kalikiana c798332
Conditionally set and unit test GOARM
kalikiana 1907551
Use dedent for apt-get build-dept output templates
kalikiana 107691b
Wrapped apt-get build-dep output over multiple lines
kalikiana 374f6e0
Merge branch 'master' into go-cross
kalikiana 1e8dd11
Call dpkg --add-architecture before apt-get build-dep
kalikiana e3a3aaa
Test and mock apt-get build-dep with no new packages
kalikiana a3fd5f8
Use os.path.join instead of + to join paths
kalikiana dc4fe6a
Use check_output rather than os.devnull
kalikiana ca8e4fe
Don't explicitly log stdout from check_output
kalikiana 4f28756
Set system PKG_CONFIG_PATH in project_loader
kalikiana 58f6805
Split out class method _ensure_package_format
kalikiana cd45c8a
Move _get_build_deps below install_build_packages
kalikiana c9bc3b4
Move _binary_name method below build
kalikiana 00634b4
Adjust FakeAptGetBuildDep and expected calls
kalikiana 57921fa
Make get_pkg_name_parts aware of the architecture
kalikiana
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,44 @@ | ||
| +// -*- Mode: Go; indent-tabs-mode: t -*- | ||
| + | ||
| +/* | ||
| + * Copyright (C) 2017 Canonical Ltd | ||
| + * | ||
| + * This program is free software: you can redistribute it and/or modify | ||
| + * it under the terms of the GNU General Public License version 3 as | ||
| + * published by the Free Software Foundation. | ||
| + * | ||
| + * This program is distributed in the hope that it will be useful, | ||
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| + * GNU General Public License for more details. | ||
| + * | ||
| + * You should have received a copy of the GNU General Public License | ||
| + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| + * | ||
| + */ | ||
| + | ||
| +package main | ||
| + | ||
| +/* | ||
| +#cgo pkg-config: glib-2.0 | ||
| +#cgo LDFLAGS: -lm | ||
| +#include <math.h> | ||
| +#include <glib.h> | ||
| + | ||
| +*/ | ||
| +import "C" | ||
| + | ||
| +import ( | ||
| + "fmt" | ||
| + "os/user" | ||
| +) | ||
| + | ||
| +func main() { | ||
| + u, err := user.Current() | ||
| + if err != nil { | ||
| + panic(err) | ||
| + } | ||
| + fmt.Println("user according to go:", u.Username) | ||
| + fmt.Println("user according to glib:", C.GoString((*C.char)(C.g_get_user_name()))) | ||
| + fmt.Println("more or less 1:", C.sin(3.14/2)) | ||
| +} |
| @@ -0,0 +1,14 @@ | ||
| +name: go-cgo | ||
| +version: 0.1 | ||
| +summary: A go project using libraries written in C. | ||
| +description: | | ||
| + This is a basic go snap that uses cgo to access C APIs. | ||
| + The name of the binary will be that of the directory containing it, | ||
| + just like it is seen when using `go build` or `go install`. | ||
| +confinement: strict | ||
| + | ||
| +parts: | ||
| + go-cgo: | ||
| + plugin: go | ||
| + source: . | ||
| + build-packages: [libglib2.0-dev] |
Oops, something went wrong.