Alien-Libtensorflow

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

						return ();
					}

					return $bucket_item;
				});
				return {
					type => 'list',
					list => $list,
				};
			}

			return $fetched;
		});
		plugin Download => (
			version => $re,
			prefer  => 1,
		);

		plugin 'Extract' => $data->{bucket_format};

		patch [
			sub {
				my ($build) = @_;
				my $lib_dir = 'lib';
				# This is because ExtUtils::Install uses File::Copy::copy()
				# which does not handle symlinks (it copies the
				# contents of what the symlinks point to).
				$build->log("Only keep one copy of library, no symlinks");
				for my $lib ( map { exists $_->{$^O} ? $_->{$^O} : () } \%os_dynamic_lib, \%other_os_dynamic_lib ) {
					my $lib_symlink = File::Spec->catfile($lib_dir, $lib );
					next unless -l $lib_symlink;
					$build->log( "Processing $lib" );

					my $lib_file = $lib_symlink;
					$lib_file = File::Spec->rel2abs(readlink $lib_file, $lib_dir) while -l $lib_file;

					unlink $lib_symlink;
					File::Copy::move($lib_file , $lib_symlink);
				}

				my @symlinks;
				find(sub { push @symlinks, $File::Find::name if -l }, $lib_dir);
				unlink @symlinks;
			},
		];

		plugin 'Build::Copy';
		meta->after_hook( build => sub {
			my($build) = @_;
			$build->runtime_prop->{'style'} = 'binary';
			$build->runtime_prop->{'device_type'} = $device_type;
		});

		gather sub {
			my($build) = @_;
			my $prefix = $build->runtime_prop->{prefix};

			my $include_path = File::Spec->catfile($prefix, qw(include));
			my $lib_path = File::Spec->catfile($prefix, qw(lib));

			my $cflags = "-I$include_path";
			my @ldlibs = "-ltensorflow";
			my $libs = join " ", "-L$lib_path", @ldlibs;

			$build->runtime_prop->{cflags}  = $cflags;
			$build->runtime_prop->{libs}    = $libs;
		};
	} else {
		requires 'Alien::Bazel';
		plugin 'Download::GitHub' => (
			github_user => 'tensorflow',
			github_repo => 'tensorflow',
		);

		build [
			sub {
				my ($build) = @_;
				$build->install_prop->{libtensorflow_dynlib} = $os_dynamic_lib{$^O};
			},
			[
				qw(bazel build),
				'--verbose_failures',
				( $ALIEN_LIBTENSORFLOW_FROM_SOURCE_BUILD_TYPE eq 'debug' ? q(--config=dbg) : () ),
				'//tensorflow:%{.install.libtensorflow_dynlib}'
			],
			'%{make_path} %{.install.stage}/lib',
			"%{cp} bazel-bin/tensorflow/%{.install.libtensorflow_dynlib} %{.install.stage}/lib",
		];
		meta->after_hook( build => sub {
			my($build) = @_;
			$build->runtime_prop->{'style'} = 'source';
			$build->runtime_prop->{'build_type'} = $ALIEN_LIBTENSORFLOW_FROM_SOURCE_BUILD_TYPE;
		});
	}
};



( run in 0.547 second using v1.01-cache-2.11-cpan-f0fbb3f571b )