forked from Proxmox/proxmox-perl-rs
major build system upgrade
- Add a 'common' symlink inside pve-rs/pmg-rs - Have the `build/` target replace it with a dir and copy `common/src` into it. - Depend on perlmod-bin to generate the perl package files. now pve-rs and pmg-rs can be built directly from within via dpkg-buildpackage Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e885772926
commit
932d602d33
16
Makefile
16
Makefile
@ -1,5 +1,3 @@
|
||||
include defines.mk
|
||||
|
||||
CARGO ?= cargo
|
||||
|
||||
ifeq ($(BUILD_MODE), release)
|
||||
@ -38,17 +36,15 @@ build:
|
||||
mkdir build
|
||||
echo system >build/rust-toolchain
|
||||
cp -a ./Cargo.toml ./build
|
||||
cp -a ./scripts ./build
|
||||
cp -a ./common ./build
|
||||
cp -a ./pve-rs ./build
|
||||
cp -a ./pmg-rs ./build
|
||||
cp -a ./Proxmox ./build
|
||||
cp defines.mk ./build
|
||||
mv ./build/Proxmox ./build/common/pkg
|
||||
# The template.pm is required by the products to produce their Proxmox::Lib
|
||||
mkdir ./build/Proxmox
|
||||
mkdir ./build/Proxmox/Lib
|
||||
cp ./Proxmox/Lib/template.pm ./build/Proxmox/Lib
|
||||
# Replace the symlinks with copies of the common code in pve/pmg:
|
||||
cd build; for i in pve pmg; do \
|
||||
rm ./$$i-rs/common ; \
|
||||
mkdir ./$$i-rs/common ; \
|
||||
cp -R ./common/src ./$$i-rs/common/src ; \
|
||||
done
|
||||
# So the common packages end up in ./build, rather than ./build/common
|
||||
mv ./build/common/pkg ./build/common-pkg
|
||||
|
||||
|
@ -1,75 +0,0 @@
|
||||
package Proxmox::Lib::{{PRODUCT}};
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Proxmox::Lib::{{PRODUCT}} - base module for {{PRODUCT}} rust bindings
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package {{PRODUCT}}::RS::SomeBindings;
|
||||
|
||||
use base 'Proxmox::Lib::{{PRODUCT}}';
|
||||
|
||||
BEGIN { __PACKAGE__->bootstrap(); }
|
||||
|
||||
1;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is the base module of all {{PRODUCT}} bindings.
|
||||
Its job is to ensure the 'lib{{LIBRARY}}.so' library is loaded and provide a 'bootstrap' class
|
||||
method to load the actual code.
|
||||
|
||||
=cut
|
||||
|
||||
use DynaLoader;
|
||||
|
||||
sub library {
|
||||
return '{{LIBRARY}}';
|
||||
}
|
||||
|
||||
# Keep on a single line, modified by testsuite!
|
||||
sub libdirs { return (map "-L$_/auto", @INC); }
|
||||
|
||||
sub load : prototype($) {
|
||||
my ($pkg) = @_;
|
||||
|
||||
my $mod_name = $pkg->library();
|
||||
|
||||
my @dirs = $pkg->libdirs();
|
||||
my $mod_file = DynaLoader::dl_findfile({{DEBUG_LIBPATH}}@dirs, $mod_name);
|
||||
die "failed to locate shared library for $mod_name (lib${mod_name}.so)\n" if !$mod_file;
|
||||
|
||||
my $lib = DynaLoader::dl_load_file($mod_file)
|
||||
or die "failed to load library '$mod_file'\n";
|
||||
|
||||
my $data = ($::{'proxmox-rs-library'} //= {});
|
||||
$data->{$mod_name} = $lib;
|
||||
$data->{-current} //= $lib;
|
||||
$data->{-package} //= $pkg;
|
||||
}
|
||||
|
||||
sub bootstrap {
|
||||
my ($pkg) = @_;
|
||||
|
||||
my $mod_name = $pkg->library();
|
||||
|
||||
my $bootstrap_name = 'boot_' . ($pkg =~ s/::/__/gr);
|
||||
|
||||
my $lib = $::{'proxmox-rs-library'}
|
||||
or die "rust library not available for '{PRODUCT}'\n";
|
||||
$lib = $lib->{$mod_name};
|
||||
|
||||
my $sym = DynaLoader::dl_find_symbol($lib, $bootstrap_name);
|
||||
die "failed to locate '$bootstrap_name'\n" if !defined $sym;
|
||||
my $boot = DynaLoader::dl_install_xsub($bootstrap_name, $sym, "src/FIXME.rs");
|
||||
$boot->();
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
__PACKAGE__->load();
|
||||
__PACKAGE__->bootstrap();
|
||||
init();
|
||||
}
|
||||
|
||||
1;
|
@ -12,9 +12,15 @@ DEB=${PACKAGE}_${DEB_VERSION}_${ARCH}.deb
|
||||
|
||||
DESTDIR=
|
||||
|
||||
PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
|
||||
--lib=- \
|
||||
--lib-tag=proxmox \
|
||||
--lib-package=Proxmox::Lib::Common \
|
||||
--lib-prefix=Proxmox
|
||||
|
||||
# Point to any generated pm file (Proxmox/ dir is already present in this package)
|
||||
Proxmox/RS/CalendarEvent.pm: ../scripts/genpackage.pl
|
||||
perl ../scripts/genpackage.pl Common \
|
||||
Proxmox/RS/CalendarEvent.pm:
|
||||
$(PERLMOD_GENPACKAGE) \
|
||||
Proxmox::RS::APT::Repositories \
|
||||
Proxmox::RS::CalendarEvent \
|
||||
Proxmox::RS::Subscription
|
||||
@ -27,7 +33,6 @@ install: Proxmox/RS/CalendarEvent.pm
|
||||
install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)
|
||||
find PVE \! -type d -print -exec install -Dm644 '{}' $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/{}' ';'
|
||||
find Proxmox \! -type d -print -exec install -Dm644 '{}' $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/{}' ';'
|
||||
rm $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/Proxmox/Lib/template.pm'
|
||||
|
||||
.PHONY: deb
|
||||
deb: $(DEB)
|
||||
|
@ -1 +0,0 @@
|
||||
../scripts
|
@ -1,8 +0,0 @@
|
||||
define package_template
|
||||
sed -r \
|
||||
-e 's/\{\{PRODUCT\}\}/$(1)/g;' \
|
||||
-e 's/\{\{LIBRARY\}\}/$(2)/g;' \
|
||||
-e 's|\{\{DEBUG_LIBPATH\}\}|$(DEBUG_LIBPATH)|g;' \
|
||||
$(3)Proxmox/Lib/template.pm \
|
||||
>Proxmox/Lib/$(1).pm
|
||||
endef
|
@ -1,4 +1,3 @@
|
||||
include ../defines.mk
|
||||
include /usr/share/dpkg/default.mk
|
||||
|
||||
PACKAGE=libpmg-rs-perl
|
||||
@ -17,26 +16,34 @@ DESTDIR=
|
||||
|
||||
PM_DIR := PMG
|
||||
|
||||
ifeq ($(BUILD_MODE), release)
|
||||
CARGO_BUILD_ARGS += --release
|
||||
endif
|
||||
PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
|
||||
--lib=pmg_rs \
|
||||
--lib-tag=proxmox \
|
||||
--lib-package=Proxmox::Lib::PMG \
|
||||
--lib-prefix=PMG
|
||||
|
||||
all: Proxmox/Lib/PMG.pm
|
||||
ifneq ($(BUILD_MODE), skip)
|
||||
cargo build $(CARGO_BUILD_ARGS)
|
||||
endif
|
||||
|
||||
PMG: ../scripts/genpackage.pl
|
||||
perl ../scripts/genpackage.pl PMG \
|
||||
PERLMOD_PACKAGES := \
|
||||
PMG::RS::APT::Repositories \
|
||||
PMG::RS::Acme \
|
||||
PMG::RS::CSR \
|
||||
PMG::RS::OpenId \
|
||||
PMG::RS::TFA
|
||||
|
||||
Proxmox/Lib/PMG.pm: ../Proxmox/Lib/template.pm
|
||||
mkdir -p Proxmox/Lib
|
||||
$(call package_template,PMG,pmg_rs,../)
|
||||
ifeq ($(BUILD_MODE), release)
|
||||
CARGO_BUILD_ARGS += --release
|
||||
TARGET_DIR=release
|
||||
else
|
||||
TARGET_DIR=debug
|
||||
endif
|
||||
|
||||
all:
|
||||
ifneq ($(BUILD_MODE), skip)
|
||||
cargo build $(CARGO_BUILD_ARGS)
|
||||
endif
|
||||
|
||||
PMG: Proxmox/Lib/PMG.pm
|
||||
Proxmox/Lib/PMG.pm:
|
||||
$(PERLMOD_GENPACKAGE) $(PERLMOD_PACKAGES)
|
||||
|
||||
.PHONY: install
|
||||
install: ../target/release/libpmg_rs.so Proxmox/Lib/PMG.pm PMG
|
||||
|
1
pmg-rs/common
Symbolic link
1
pmg-rs/common
Symbolic link
@ -0,0 +1 @@
|
||||
../common
|
@ -5,6 +5,7 @@ Maintainer: Proxmox Support Team <support@proxmox.com>
|
||||
Build-Depends:
|
||||
debhelper (>= 12),
|
||||
dh-cargo (>= 24),
|
||||
perlmod-bin,
|
||||
cargo:native <!nocheck>,
|
||||
rustc:native <!nocheck>,
|
||||
libstd-rust-dev <!nocheck>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#[path = "../../common/src/mod.rs"]
|
||||
#[path = "../common/src/mod.rs"]
|
||||
pub mod common;
|
||||
|
||||
pub mod acme;
|
||||
|
@ -1,4 +1,3 @@
|
||||
include ../defines.mk
|
||||
include /usr/share/dpkg/default.mk
|
||||
|
||||
PACKAGE=libpve-rs-perl
|
||||
@ -18,6 +17,18 @@ DESTDIR=
|
||||
|
||||
PM_DIR := PVE
|
||||
|
||||
PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
|
||||
--lib=pve_rs \
|
||||
--lib-tag=proxmox \
|
||||
--lib-package=Proxmox::Lib::PVE \
|
||||
--lib-prefix=PVE
|
||||
|
||||
PERLMOD_PACKAGES := \
|
||||
PVE::RS::APT::Repositories \
|
||||
PVE::RS::OpenId \
|
||||
PVE::RS::ResourceScheduling::Static \
|
||||
PVE::RS::TFA
|
||||
|
||||
ifeq ($(BUILD_MODE), release)
|
||||
CARGO_BUILD_ARGS += --release
|
||||
TARGET_DIR=release
|
||||
@ -25,7 +36,7 @@ else
|
||||
TARGET_DIR=debug
|
||||
endif
|
||||
|
||||
all: PVE Proxmox/Lib/PVE.pm
|
||||
all: PVE
|
||||
ifneq ($(BUILD_MODE), skip)
|
||||
cargo build $(CARGO_BUILD_ARGS)
|
||||
mkdir -p test/Proxmox/Lib
|
||||
@ -34,16 +45,9 @@ ifneq ($(BUILD_MODE), skip)
|
||||
Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm
|
||||
endif
|
||||
|
||||
PVE: ../scripts/genpackage.pl
|
||||
perl ../scripts/genpackage.pl PVE \
|
||||
PVE::RS::APT::Repositories \
|
||||
PVE::RS::OpenId \
|
||||
PVE::RS::ResourceScheduling::Static \
|
||||
PVE::RS::TFA
|
||||
|
||||
Proxmox/Lib/PVE.pm: ../Proxmox/Lib/template.pm
|
||||
mkdir -p Proxmox/Lib
|
||||
$(call package_template,PVE,pve_rs,../)
|
||||
PVE: Proxmox/Lib/PVE.pm
|
||||
Proxmox/Lib/PVE.pm:
|
||||
$(PERLMOD_GENPACKAGE) $(PERLMOD_PACKAGES)
|
||||
|
||||
check: all
|
||||
$(MAKE) -C test test
|
||||
|
1
pve-rs/common
Symbolic link
1
pve-rs/common
Symbolic link
@ -0,0 +1 @@
|
||||
../common
|
@ -4,6 +4,7 @@ Priority: optional
|
||||
Build-Depends:
|
||||
debhelper (>= 12),
|
||||
dh-cargo (>= 24),
|
||||
perlmod-bin,
|
||||
cargo:native <!nocheck>,
|
||||
rustc:native <!nocheck>,
|
||||
libstd-rust-dev <!nocheck>,
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Rust library for the Proxmox VE code base.
|
||||
|
||||
#[path = "../../common/src/mod.rs"]
|
||||
#[path = "../common/src/mod.rs"]
|
||||
pub mod common;
|
||||
|
||||
pub mod apt;
|
||||
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# Create a perl package given a product and package name.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Path qw(make_path);
|
||||
|
||||
my $product = shift @ARGV or die "missing product name (PVE, PMG or Common)\n";
|
||||
|
||||
die "missing package name\n" if !@ARGV;
|
||||
|
||||
for my $package (@ARGV) {
|
||||
my $path = ($package =~ s@::@/@gr) . ".pm";
|
||||
|
||||
print "Generating $path\n";
|
||||
|
||||
$path =~ m@^(.*)/[^/]+@;
|
||||
make_path($1, { mode => 0755 });
|
||||
|
||||
open(my $fh, '>', $path) or die "failed to open '$path' for writing: $!\n";
|
||||
|
||||
print {$fh} <<"EOF";
|
||||
package $package;
|
||||
use base 'Proxmox::Lib::$product';
|
||||
BEGIN { __PACKAGE__->bootstrap(); }
|
||||
1;
|
||||
EOF
|
||||
|
||||
close($fh);
|
||||
}
|
Loading…
Reference in New Issue
Block a user