mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 08:30:47 -09:00
package/pkg-hare.mk: new infrastructure
Signed-off-by: Francois Perrad <francois.perrad.86@gmail.com> [Julien: split long lines] Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
committed by
Julien Olivain
parent
72ff2ad88d
commit
44d3843234
@@ -1203,6 +1203,7 @@ F: package/lzlib/
|
||||
F: package/moarvm/
|
||||
F: package/opendoas/
|
||||
F: package/perl*
|
||||
F: package/pkg-hare.mk
|
||||
F: package/pkg-perl.mk
|
||||
F: package/pkg-luarocks.mk
|
||||
F: package/quickjs/
|
||||
|
||||
87
docs/manual/adding-packages-hare.adoc
Normal file
87
docs/manual/adding-packages-hare.adoc
Normal file
@@ -0,0 +1,87 @@
|
||||
// -*- mode:doc; -*-
|
||||
// vim: set syntax=asciidoc:
|
||||
|
||||
=== Infrastructure for Hare packages
|
||||
|
||||
[[hare-package-tutorial]]
|
||||
|
||||
==== +hare-package+ tutorial
|
||||
|
||||
The +Config.in+ file of Hare-based package 'hare-foo' should contain:
|
||||
|
||||
----
|
||||
01: config BR2_PACKAGE_HARE_FOO
|
||||
02: bool "hare-foo"
|
||||
03: depends on BR2_PACKAGE_HOST_HARE_TARGET_ARCH_SUPPORTS
|
||||
04: select BR2_PACKAGE_HOST_HARE
|
||||
05: help
|
||||
06: This is a comment that explains what foo is.
|
||||
07:
|
||||
08: https://foosoftware.org/foo/
|
||||
----
|
||||
|
||||
And the +.mk+ file for this package should contain:
|
||||
|
||||
----
|
||||
01: ################################################################################
|
||||
02: #
|
||||
03: # hare-foo
|
||||
04: #
|
||||
05: ################################################################################
|
||||
06:
|
||||
07: HARE_FOO_VERSION = 0.42.0
|
||||
08: HARE_FOO_SITE = https://git.sr.ht/~sircmpwn/hare-foo
|
||||
09: HARE_FOO_SITE_METHOD = git
|
||||
10: HARE_FOO_LICENSE = MPL-2.0
|
||||
11: HARE_FOO_LICENSE_FILES = COPYING
|
||||
12: HARE_FOO_INSTALL_STAGING = YES
|
||||
13:
|
||||
14: $(eval $(hare-package))
|
||||
----
|
||||
|
||||
The Makefile starts with the definition of the standard variables for
|
||||
package declaration (lines 7 to 12).
|
||||
|
||||
Finally, on line 14, we invoke the +hare-package+
|
||||
macro that generates all the Makefile rules that actually allows the
|
||||
package to be built.
|
||||
|
||||
[[hare-package-reference]]
|
||||
|
||||
==== +hare-package+ reference
|
||||
|
||||
As a policy, packages that provide Hare modules should all be
|
||||
named +hare-<something>+ in Buildroot.
|
||||
|
||||
In their +Config.in+ file, packages using the +hare-package+
|
||||
infrastructure should depend on +BR2_PACKAGE_HOST_HARE_TARGET_ARCH_SUPPORTS+
|
||||
because Buildroot will automatically add a dependency on +host-hare+
|
||||
to such packages.
|
||||
|
||||
The main macro of the Hare package infrastructure is +hare-package+:
|
||||
like +generic-package+ it works by defining a number of variables providing
|
||||
metadata information about the package, and then calling the +hare-package+
|
||||
macro.
|
||||
|
||||
Just like the generic infrastructure, the Hare infrastructure works
|
||||
by defining a number of variables before calling the +hare-package+
|
||||
macro.
|
||||
|
||||
All the package metadata information variables that exist in the
|
||||
xref:generic-package-reference[generic package infrastructure] also
|
||||
exist in the Hare infrastructure.
|
||||
|
||||
This infrastructure expects that the upstream package follows the
|
||||
https://harelang.org/documentation/usage/project-structure.html#makefiles[project structure conventions],
|
||||
because the upstream +Makefile+ is called.
|
||||
|
||||
When the package contains Hare modules (ie. libraries),
|
||||
there are not compiled by this BR package,
|
||||
there are just installed in +$(STAGING_DIR)/usr/src/hare/third-party+,
|
||||
for a future use.
|
||||
|
||||
When the package produces one or more executables,
|
||||
all Hare sources (from this package, from dependent modules,
|
||||
from the Hare stdlib) are compiled and statically linked.
|
||||
If a binding to a native library is used,
|
||||
the link requires the static library, not the shared one.
|
||||
@@ -43,6 +43,8 @@ include::adding-packages-golang.adoc[]
|
||||
|
||||
include::adding-packages-qmake.adoc[]
|
||||
|
||||
include::adding-packages-hare.adoc[]
|
||||
|
||||
include::adding-packages-kernel-module.adoc[]
|
||||
|
||||
include::adding-packages-asciidoc.adoc[]
|
||||
|
||||
@@ -474,3 +474,4 @@ include package/pkg-golang.mk
|
||||
include package/pkg-meson.mk
|
||||
include package/pkg-qmake.mk
|
||||
include package/pkg-cargo.mk
|
||||
include package/pkg-hare.mk
|
||||
|
||||
99
package/pkg-hare.mk
Normal file
99
package/pkg-hare.mk
Normal file
@@ -0,0 +1,99 @@
|
||||
################################################################################
|
||||
# Hare package infrastructure
|
||||
# see https://harelang.org/
|
||||
#
|
||||
# This file implements an infrastructure that eases development of
|
||||
# package .mk files for Hare packages.
|
||||
#
|
||||
# See the Buildroot documentation for details on the usage of this
|
||||
# infrastructure
|
||||
#
|
||||
# In terms of implementation, this Hare infrastructure requires
|
||||
# the .mk file to only specify metadata information about the
|
||||
# package: name, version, etc.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
HARE_RUN_CMD = \
|
||||
PATH=$(BR_PATH) \
|
||||
HAREPATH="$(HOST_DIR)/src/hare/stdlib:$(STAGING_DIR)/usr/src/hare/third-party" \
|
||||
$(HOST_DIR)/bin/hare
|
||||
HARE_ARCH_OPT = -a $(ARCH)
|
||||
HARE_LIBDIR_OPT = -L $(STAGING_DIR)/usr/lib
|
||||
|
||||
################################################################################
|
||||
# inner-hare-package -- defines how the configuration, compilation and
|
||||
# installation of a Hare package should be done, implements a few hooks to
|
||||
# tune the build process and calls the generic package infrastructure to
|
||||
# generate the necessary make targets
|
||||
#
|
||||
# argument 1 is the lowercase package name
|
||||
# argument 2 is the uppercase package name, including a HOST_ prefix
|
||||
# for host packages
|
||||
# argument 3 is the uppercase package name, without the HOST_ prefix
|
||||
# for host packages
|
||||
# argument 4 is the type (target or host)
|
||||
################################################################################
|
||||
|
||||
define inner-hare-package
|
||||
|
||||
$(2)_DEPENDENCIES += host-hare
|
||||
|
||||
#
|
||||
# Build step. Only define it if not already defined by the package .mk
|
||||
# file.
|
||||
#
|
||||
ifndef $(2)_BUILD_CMDS
|
||||
# in perfect world, all project follows the conventions described in
|
||||
# https://harelang.org/documentation/usage/project-structure.html#makefiles
|
||||
# but in real world, the target "all" is not always the default one
|
||||
define $(2)_BUILD_CMDS
|
||||
if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
|
||||
$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" all; \
|
||||
else \
|
||||
$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)"; \
|
||||
fi
|
||||
endef
|
||||
endif
|
||||
|
||||
#
|
||||
# Staging installation step. Only define it if not already defined by
|
||||
# the package .mk file.
|
||||
#
|
||||
ifndef $(2)_INSTALL_STAGING_CMDS
|
||||
define $(2)_INSTALL_STAGING_CMDS
|
||||
$(MAKE) -C $$($(2)_SRCDIR) PREFIX=/usr DESTDIR="$$(STAGING_DIR)" install
|
||||
endef
|
||||
endif
|
||||
|
||||
#
|
||||
# Target installation step. Only define it if not already defined by
|
||||
# the package .mk file.
|
||||
#
|
||||
ifndef $(2)_INSTALL_TARGET_CMDS
|
||||
define $(2)_INSTALL_TARGET_CMDS
|
||||
$(MAKE) -C $$($(2)_SRCDIR) PREFIX=/usr DESTDIR="$$(TARGET_DIR)" install
|
||||
endef
|
||||
endif
|
||||
|
||||
# Call the generic package infrastructure to generate the necessary
|
||||
# make targets
|
||||
$(call inner-generic-package,$(1),$(2),$(3),$(4))
|
||||
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# hare-package -- the target generator macro for Hare packages
|
||||
################################################################################
|
||||
|
||||
hare-package = $(call inner-hare-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
|
||||
|
||||
################################################################################
|
||||
# Cleanup target /usr/src/hare
|
||||
################################################################################
|
||||
|
||||
define HARE_FINALIZE_TARGET
|
||||
rm -rf $(TARGET_DIR)/usr/src/hare
|
||||
endef
|
||||
|
||||
TARGET_FINALIZE_HOOKS += HARE_FINALIZE_TARGET
|
||||
Reference in New Issue
Block a user