Skip to content

Commit

Permalink
Merge pull request #19 from aboutcode-org/build-src
Browse files Browse the repository at this point in the history
Build src
  • Loading branch information
JonoYang authored Nov 5, 2024
2 parents d62b372 + b44971d commit 442bc5b
Show file tree
Hide file tree
Showing 23 changed files with 514 additions and 940 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

v0.5.0 (2024-11-05)
-------------------

- Build GoReSym from source instead of vendoring the binary.
- Support building go-inspector for Linux aarch64/arm64 platform.
- Update GoReSym to v3.0.1

v0.4.0 (2024-10-31)
-------------------
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ PYTHON_EXE?=python3
VENV=venv
ACTIVATE?=. ${VENV}/bin/activate;

ARCH := $(shell uname -m)
ifeq ($(ARCH),aarch64)
PLAT_NAME := "manylinux2014_aarch64"
GOARCH := "arm64"
else
PLAT_NAME := "manylinux1_x86_64"
GOARCH := "amd64"
endif

dev:
@echo "-> Configure the development envt."
./configure --dev
Expand All @@ -35,7 +44,7 @@ check:
@echo "-> Run pycodestyle (PEP8) validation"
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,migrations,settings.py,.cache .
@echo "-> Run isort imports ordering validation"
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
@echo "-> Run black validation"
@${ACTIVATE} black --check --check -l 100 src tests setup.py

Expand All @@ -51,4 +60,9 @@ docs:
rm -rf docs/_build/
@${ACTIVATE} sphinx-build docs/ docs/_build/

build:
rm -f src/go_inspector/bin/GoReSym_lin
python setup.py clean --all sdist
GOOS=linux GOARCH=$(GOARCH) python setup.py clean --all bdist_wheel --python-tag py3 --plat-name $(PLAT_NAME)

.PHONY: conf dev check valid black isort clean test docs
19 changes: 12 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ To install and use:

The JSON output will contain various dependencies and symbols found in Go binaries if any.

A Go compiler is required to build go-inspector. Install Go from
https://go.dev/doc/install or from a package manager.

- License: Apache-2.0 AND MIT AND BSD-3-Clause WITH LicenRef-scancode-google-patent-license-golang
- Copyright (c) nexB Inc., AboutCode, Mandiant, The Go Authors, Elliot Chance and others.
- Homepage: https://github.com/aboutcode-org/go-inspector

See the src/go_inspector/bin for detailed license and credits for bundled third-party packages.
See the libsrc/ directory for detailed license and credits for bundled third-party packages.


Development
Expand All @@ -31,6 +33,9 @@ Testing:
- To regen test fixtures: ``SCANCODE_REGEN_TEST_FIXTURES=yes pytest -vvs``
- To update the bundled GoReSym, see src/bin/update.sh

Building:

- Ensure ``make dev`` has been run, then run ``make build``

How to re-generate test binaries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -50,27 +55,27 @@ This project is funded, supported and sponsored by:

- Generous support and contributions from users like you!
- the European Commission NGI programme
- the NLnet Foundation
- the NLnet Foundation
- the Swiss State Secretariat for Education, Research and Innovation (SERI)
- Google, including the Google Summer of Code and the Google Seasons of Doc programmes
- Mercedes-Benz Group
- Microsoft and Microsoft Azure
- AboutCode ASBL
- nexB Inc.
- nexB Inc.



|europa| |dgconnect|
|europa| |dgconnect|

|ngi| |nlnet|
|ngi| |nlnet|

|aboutcode| |nexb|



This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial
support from the European Commission's Next Generation Internet programme, under the aegis of DG
Communications Networks, Content and Technology under grant agreement No 101069594.
Communications Networks, Content and Technology under grant agreement No 101069594.

|ngizeroentrust| https://nlnet.nl/project/Back2source/

Expand All @@ -84,7 +89,7 @@ Communications Networks, Content and Technology under grant agreement No 1010929

This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial
support from the European Commission's Next Generation Internet programme, under the aegis of DG
Communications Networks, Content and Technology under grant agreement No 101069594.
Communications Networks, Content and Technology under grant agreement No 101069594.

|ngizeroentrust| https://nlnet.nl/project/purl2all/

Expand Down
31 changes: 31 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
#

set -e

base_name=GoReSym-3.0.1
GOOS=linux

if [ $(uname -m) == 'aarch64' ]; then
GOARCH="arm64"
else
GOARCH="amd64"
fi

cd lib-src/

rm -rf $base_name
tar -xf $base_name.tar.gz

cd $base_name/

echo Build GoReSym
go build && mv GoReSym GoReSym_lin
strip GoReSym_lin
cp GoReSym_lin ../../src/go_inspector/bin/
cd ..
echo Done building GoReSym

rm -rf $base_name/
Binary file added lib-src/GoReSym-3.0.1.tar.gz
Binary file not shown.
8 changes: 8 additions & 0 deletions lib-src/GoReSym-3.0.1.tar.gz.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
about_resource: GoReSym-3.0.1.tar.gz
name: GoReSym
version: 3.0.1
download_url: https://github.com/mandiant/GoReSym/archive/refs/tags/v3.0.1.tar.gz
package_url: pkg:github/mandiant/[email protected]
copyright: Copyright (c) 2022 MANDIANT
license_expression: mit
license_text_file: GoReSym_lin.LICENSE
21 changes: 21 additions & 0 deletions lib-src/GoReSym-3.0.1.tar.gz.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 MANDIANT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 26 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
#!/usr/bin/env python

import subprocess
from distutils.command.build import build as distutils_build
from distutils.errors import LibError

import setuptools
from setuptools.command.develop import develop as setuptools_develop


def run_native_build():
exitcode, output = subprocess.getstatusoutput(["./build.sh"])
print(output)
if exitcode:
raise LibError("Unable to build native")


class BuildNative(distutils_build):
def run(self):
self.execute(run_native_build, (), msg="Building native code")
distutils_build.run(self)


class DevelopNative(setuptools_develop):
def run(self):
self.execute(run_native_build, (), msg="Building develop native code")
setuptools_develop.run(self)


if __name__ == "__main__":
setuptools.setup()
setuptools.setup(cmdclass={"build": BuildNative, "develop": DevelopNative})
1 change: 0 additions & 1 deletion src/go_inspector/bin/GoReSym.zip.sums

This file was deleted.

Binary file modified src/go_inspector/bin/GoReSym_lin
Binary file not shown.
10 changes: 4 additions & 6 deletions src/go_inspector/bin/GoReSym_lin.ABOUT
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
about_resource: GoReSym_lin
name: goresym
version: 011fc7d5c9c2362871dfe88a1295a43ee6b4d273
download_url: https://github.com/pombredanne/GoReSym/archive/011fc7d5c9c2362871dfe88a1295a43ee6b4d273.zip
package_url: pkg:github/pombredanne/GoReSym@011fc7d5c9c2362871dfe88a1295a43ee6b4d273
name: GoReSym
version: 3.0.1
package_url: pkg:github/mandiant/[email protected]
copyright: Copyright (c) 2022 MANDIANT
license_expression: mit
license_text_file: GoReSym_lin.LICENSE
notes: this is a patched version until https://github.com/mandiant/GoReSym/pull/60 is accepted
and merged.
notes: this is built from the source files contained in the go-inspector/lib-src directory
2 changes: 1 addition & 1 deletion src/go_inspector/bin/GoReSym_lin.LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
Loading

0 comments on commit 442bc5b

Please sign in to comment.