Browse Source

Merge pull request #10043 from dhewg/pull/meson

ninja/meson
lilik-openwrt-22.03
Rosen Penev 5 years ago
committed by GitHub
parent
commit
d0f3da9f3c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 380 additions and 0 deletions
  1. +56
    -0
      devel/meson/Makefile
  2. +124
    -0
      devel/meson/meson.mk
  3. +25
    -0
      devel/meson/src/openwrt-cross.txt.in
  4. +15
    -0
      devel/meson/src/openwrt-native.txt.in
  5. +77
    -0
      devel/ninja/Makefile
  6. +16
    -0
      devel/ninja/ninja.mk
  7. +37
    -0
      devel/ninja/patches/010-musl.patch
  8. +30
    -0
      devel/ninja/patches/020-uclibc.patch

+ 56
- 0
devel/meson/Makefile View File

@ -0,0 +1,56 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=meson
PKG_VERSION:=0.52.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/mesonbuild/meson/releases/download/$(PKG_VERSION)/
PKG_HASH:=d60f75f0dedcc4fd249dbc7519d6f3ce6df490033d276ef1cf27453ef4938d32
PKG_MAINTAINER:=Andre Heider <a.heider@gmail.com>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=COPYING
HOST_BUILD_DEPENDS:=ninja/host
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ../../lang/python/python3-package.mk
define Host/Configure
endef
define Host/Compile
endef
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib/meson
$(CP) $(HOST_BUILD_DIR)/* $(STAGING_DIR_HOSTPKG)/lib/meson/
endef
define Host/Clean
$(call Host/Clean/Default)
rm -rf $(STAGING_DIR_HOSTPKG)/lib/meson
endef
define Package/meson
SECTION:=devel
CATEGORY:=Development
TITLE:=meson
URL:=https://mesonbuild.com/
DEPENDS:=+ninja +python3-pkg-resources
VARIANT:=python3
endef
define Package/meson/description
Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.
endef
define Package/meson/install
endef
$(eval $(call HostBuild))
$(eval $(call Py3Package,meson))
$(eval $(call BuildPackage,meson))
$(eval $(call BuildPackage,meson-src))

+ 124
- 0
devel/meson/meson.mk View File

@ -0,0 +1,124 @@
# To build your package using meson:
#
# PKG_BUILD_DEPENDS:=meson/host
# include ../../devel/meson/meson.mk
# MESON_ARGS+=-Dfoo -Dbar=baz
#
# To pass additional environment variables to meson:
#
# MESON_VARS+=FOO=bar
#
# Default configure/compile/install targets are provided, but can be
# overwritten if required:
#
# define Build/Configure
# $(call Build/Configure/Meson)
# ...
# endef
#
# same for Build/Compile and Build/Install
#
# Host packages are built in the same fashion, just use these vars instead:
#
# HOST_BUILD_DEPENDS:=meson/host
# MESON_HOST_ARGS+=-Dfoo -Dbar=baz
# MESON_HOST_VARS+=FOO=bar
include $(dir $(lastword $(MAKEFILE_LIST)))/../../devel/ninja/ninja.mk
MESON_DIR:=$(STAGING_DIR_HOSTPKG)/lib/meson
MESON_HOST_BUILD_DIR:=$(HOST_BUILD_DIR)/openwrt-build
MESON_HOST_VARS:=
MESON_HOST_ARGS:=
MESON_BUILD_DIR:=$(PKG_BUILD_DIR)/openwrt-build
MESON_VARS:=
MESON_ARGS:=
define Meson
$(2) $(STAGING_DIR_HOST)/bin/$(PYTHON) $(MESON_DIR)/meson.py $(1)
endef
define Meson/CreateNativeFile
$(STAGING_DIR_HOST)/bin/sed \
-e "s|@CC@|$(HOSTCC)|" \
-e "s|@CXX@|$(HOSTCXX)|" \
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
-e "s|@CFLAGS@|$(foreach FLAG,$(HOST_CFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@CXXFLAGS@|$(foreach FLAG,$(HOST_CXXFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@LDFLAGS@|$(foreach FLAG,$(HOST_LDFLAGS),'$(FLAG)',)|" \
-e "s|@PREFIX@|$(STAGING_DIR_HOSTPKG)|" \
< $(MESON_DIR)/openwrt-native.txt.in \
> $(1)
endef
define Meson/CreateCrossFile
$(STAGING_DIR_HOST)/bin/sed \
-e "s|@CC@|$(TARGET_CC)|" \
-e "s|@CXX@|$(TARGET_CXX)|" \
-e "s|@AR@|$(TARGET_AR)|" \
-e "s|@STRIP@|$(TARGET_CROSS)strip|" \
-e "s|@NM@|$(TARGET_NM)|" \
-e "s|@LD@|$(TARGET_CROSS)ld|" \
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
-e "s|@CFLAGS@|$(foreach FLAG,$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@CXXFLAGS@|$(foreach FLAG,$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@LDFLAGS@|$(foreach FLAG,$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS),'$(FLAG)',)|" \
-e "s|@ARCH@|$(ARCH)|" \
-e "s|@CPU@|$(CONFIG_TARGET_SUBTARGET)|" \
-e "s|@ENDIAN@|$(if $(CONFIG_BIG_ENDIAN),big,little)|" \
< $(MESON_DIR)/openwrt-cross.txt.in \
> $(1)
endef
define Host/Configure/Meson
$(call Meson/CreateNativeFile,$(HOST_BUILD_DIR)/openwrt-native.txt)
$(call Meson, \
--native-file $(HOST_BUILD_DIR)/openwrt-native.txt \
$(MESON_HOST_ARGS) \
$(MESON_HOST_BUILD_DIR) \
$(HOST_BUILD_DIR), \
$(MESON_HOST_VARS))
endef
define Host/Compile/Meson
$(call Ninja,-C $(MESON_HOST_BUILD_DIR),)
endef
define Host/Install/Meson
$(call Ninja,-C $(MESON_HOST_BUILD_DIR) install,)
endef
define Host/Uninstall/Meson
-$(call Ninja,-C $(MESON_HOST_BUILD_DIR) uninstall,)
endef
define Build/Configure/Meson
$(call Meson/CreateNativeFile,$(PKG_BUILD_DIR)/openwrt-native.txt)
$(call Meson/CreateCrossFile,$(PKG_BUILD_DIR)/openwrt-cross.txt)
$(call Meson, \
--buildtype plain \
--native-file $(PKG_BUILD_DIR)/openwrt-native.txt \
--cross-file $(PKG_BUILD_DIR)/openwrt-cross.txt \
$(MESON_ARGS) \
$(MESON_BUILD_DIR) \
$(PKG_BUILD_DIR), \
$(MESON_VARS))
endef
define Build/Compile/Meson
$(call Ninja,-C $(MESON_BUILD_DIR),)
endef
define Build/Install/Meson
$(call Ninja,-C $(MESON_BUILD_DIR) install,DESTDIR="$(PKG_INSTALL_DIR)")
endef
Host/Configure=$(call Host/Configure/Meson)
Host/Compile=$(call Host/Compile/Meson)
Host/Install=$(call Host/Install/Meson)
Host/Uninstall=$(call Host/Uninstall/Meson)
Build/Configure=$(call Build/Configure/Meson)
Build/Compile=$(call Build/Compile/Meson)
Build/Install=$(call Build/Install/Meson)

+ 25
- 0
devel/meson/src/openwrt-cross.txt.in View File

@ -0,0 +1,25 @@
[binaries]
c = '@CC@'
cpp = '@CXX@'
ar = '@AR@'
strip = '@STRIP@'
nm = '@NM@'
ld = '@LD@'
pkgconfig = '@PKGCONFIG@'
[properties]
c_args = [@CFLAGS@]
c_link_args = [@LDFLAGS@]
cpp_args = [@CXXFLAGS@]
cpp_link_args = [@LDFLAGS@]
needs_exe_wrapper = true
[host_machine]
system = 'linux'
cpu_family = '@ARCH@'
cpu = '@CPU@'
endian = '@ENDIAN@'
[paths]
prefix = '/usr'
libdir = 'lib'

+ 15
- 0
devel/meson/src/openwrt-native.txt.in View File

@ -0,0 +1,15 @@
[binaries]
c = '@CC@'
cpp = '@CXX@'
pkgconfig = '@PKGCONFIG@'
[properties]
c_args = [@CFLAGS@]
c_link_args = [@LDFLAGS@]
cpp_args = [@CXXFLAGS@]
cpp_link_args = [@LDFLAGS@]
[paths]
prefix = '@PREFIX@'
sbindir = 'bin'
libdir = 'lib'

+ 77
- 0
devel/ninja/Makefile View File

@ -0,0 +1,77 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ninja
PKG_VERSION:=1.9.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/ninja-build/ninja/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=5d7ec75828f8d3fd1a0c2f31b5b0cea780cdfe1031359228c428c1a48bfcd5b9
PKG_MAINTAINER:=Andre Heider <a.heider@gmail.com>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=COPYING
PKG_BUILD_DEPENDS:=ninja/host
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ./ninja.mk
CONFIGURE_ARGS:=
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
CONFIGURE_ARGS+=--verbose
endif
define Host/Configure
endef
define Host/Compile
cd $(HOST_BUILD_DIR) && \
CXX="$(HOSTCXX)" \
CXXFLAGS="$(HOST_CXXFLAGS) $(HOST_CPPFLAGS)" \
LDFLAGS="$(HOST_LDFLAGS)" \
$(STAGING_DIR_HOST)/bin/$(PYTHON) configure.py --bootstrap $(CONFIGURE_ARGS)
endef
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin
$(INSTALL_BIN) $(HOST_BUILD_DIR)/ninja $(STAGING_DIR_HOSTPKG)/bin/
endef
define Host/Clean
$(call Host/Clean/Default)
rm -f $(STAGING_DIR_HOSTPKG)/bin/ninja
endef
define Package/ninja
SECTION:=devel
CATEGORY:=Development
TITLE:=ninja
URL:=https://ninja-build.org/
DEPENDS:=+libstdcpp
endef
define Package/ninja/description
Ninja is a small build system with a focus on speed. It differs from other build systems in two major respects: it is designed to have its input files generated by a higher-level build system, and it is designed to run builds as fast as possible.
endef
define Package/ninja/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ninja $(1)/usr/bin/
endef
define Build/Configure
cd $(PKG_BUILD_DIR) && \
CXX="$(TARGET_CXX)" \
CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
$(STAGING_DIR_HOST)/bin/$(PYTHON) configure.py $(CONFIGURE_ARGS)
endef
define Build/Compile
$(call Ninja,-C $(PKG_BUILD_DIR),)
endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,ninja))

+ 16
- 0
devel/ninja/ninja.mk View File

@ -0,0 +1,16 @@
# To execute ninja from you package's Makefile:
#
# include ../../devel/ninja/ninja.mk
#
# define Build/Compile
# $(call Ninja,-C $(MY_NINJA_BUILD_DIR),$(MY_NINJA_ENV_VARS))
# endef
NINJA_ARGS:=$(filter -j%,$(filter-out -j,$(MAKEFLAGS)))
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
NINJA_ARGS+=-v
endif
define Ninja
$(2) $(STAGING_DIR_HOSTPKG)/bin/ninja $(NINJA_ARGS) $(1)
endef

+ 37
- 0
devel/ninja/patches/010-musl.patch View File

@ -0,0 +1,37 @@
From 567815df38a2ff54ad7478a90bd75c91e434236a Mon Sep 17 00:00:00 2001
From: makepost <makepost@firemail.cc>
Date: Mon, 24 Dec 2018 03:13:16 +0200
Subject: [PATCH] Use st_mtim if st_mtime is macro, fix #1510
In POSIX.1-2008, sys_stat has a st_mtim member and a st_mtime backward
compatibility macro. Should help avoid hardcoding platform detection.
---
src/disk_interface.cc | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -202,19 +202,13 @@ TimeStamp RealDiskInterface::Stat(const
// that it doesn't exist.
if (st.st_mtime == 0)
return 1;
-#if defined(__APPLE__) && !defined(_POSIX_C_SOURCE)
+#if defined(_AIX)
+ return (int64_t)st.st_mtime * 1000000000LL + st.st_mtime_n;
+#elif defined(__APPLE__)
return ((int64_t)st.st_mtimespec.tv_sec * 1000000000LL +
st.st_mtimespec.tv_nsec);
-#elif (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700 || defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \
- defined(__BIONIC__) || (defined (__SVR4) && defined (__sun)) || defined(__FreeBSD__))
- // For glibc, see "Timestamp files" in the Notes of http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html
- // newlib, uClibc and musl follow the kernel (or Cygwin) headers and define the right macro values above.
- // For bsd, see https://github.com/freebsd/freebsd/blob/master/sys/sys/stat.h and similar
- // For bionic, C and POSIX API is always enabled.
- // For solaris, see https://docs.oracle.com/cd/E88353_01/html/E37841/stat-2.html.
+#elif defined(st_mtime) // A macro, so we're likely on modern POSIX.
return (int64_t)st.st_mtim.tv_sec * 1000000000LL + st.st_mtim.tv_nsec;
-#elif defined(_AIX)
- return (int64_t)st.st_mtime * 1000000000LL + st.st_mtime_n;
#else
return (int64_t)st.st_mtime * 1000000000LL + st.st_mtimensec;
#endif

+ 30
- 0
devel/ninja/patches/020-uclibc.patch View File

@ -0,0 +1,30 @@
From 76abf78aac8c56606fb52ea874873d790b9044da Mon Sep 17 00:00:00 2001
From: "Pawel Hajdan, Jr" <phajdan.jr@chromium.org>
Date: Mon, 2 Jan 2017 10:42:35 +0000
Subject: [PATCH] Fix build with uclibc
Resolves #985
This is based on musl implementation,
http://git.musl-libc.org/cgit/musl/commit/?id=20cbd607759038dca57f84ef7e7b5d44a3088574
(thanks to jbergstroem@ for reference)
---
src/util.cc | 7 +++++++
1 file changed, 7 insertions(+)
--- a/src/util.cc
+++ b/src/util.cc
@@ -572,6 +572,13 @@ double GetLoadAverage() {
return -0.0f;
return 1.0 / (1 << SI_LOAD_SHIFT) * si.loads[0];
}
+#elif defined(__UCLIBC__)
+double GetLoadAverage() {
+ struct sysinfo si;
+ if (sysinfo(&si) != 0)
+ return -0.0f;
+ return 1.0 / (1 << SI_LOAD_SHIFT) * si.loads[0];
+}
#else
double GetLoadAverage() {
double loadavg[3] = { 0.0f, 0.0f, 0.0f };

Loading…
Cancel
Save