forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.txt
137 lines (106 loc) · 4.77 KB
/
script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
1. Alien Basics
* Teaser
- Greetings
- I can see your dilema already
- You're sitting down tow write a Perl module
- And you have some external dependencies
- Maybe it's a C library
- It could be a rust crate
- Possibly some old Fortran library
- It could even be something new and shiney written in Go
- Either way you need this thing to install from CPAN for your users
- Without causing them any trouble
- You want the dependencies to just work
- What are you going to do?
- I'll tell you what you are going to do,
- You are going to use some Alien Technology Now
- *TAG*
* Define Alien
- [slides]
* Why Alien?
- [slides]
* Alien Flowchart
- [slides]
* Alien Dependency
- [slides]
* Demo: create Alien::libarchive
* We're going to start by installing libffi and libarchive.
* These can be installed as Aliens without the system packages,
* But this will speed things up.
- sudo apt-get update && sudo apt-get install libffi-dev libarchive-dev
* Next we're going to install Task::AlienDev, which will include
* The Alien::Build framework, and a number of development tools
* For creating Aliens.
- cpanm -n Task::AlienDev
* It takes a little time, but
* Our development environment is now ready
## CUT ##
* I realize it is contraversial, but I am going to recommend using Dist::Zilla
* For Alien development.
* This is because the Alien Dist::Zilla plugins handle a number of tricky edge cases
* And will help you avoid common pitfalls.
* You can create Aliens without Dist::Zilla and that is supported by
* The Alien::Build framework
* But for simplicity, I am going to use dzil in this demo.
* We can mint a brand new Alien dist using the dzil new command,
* And the AlienBuild minting profile.
- dzil new -P AlienBuild Alien::libarchive
* This will prompt for the URL to the tarball of the alienized package
+ http://libarchive.org/downloads/libarchive-3.5.2.tar.gz
* The minting plugin will download the tarball from the internet and use it to guess a number of settings
* We're going to mostly use the defaults.
- cd Alien-libarchive
* Now lets take a look at what has been created for us.
- ls
* The main Perl module doesn't contain any of its own code.
* All of the heavy lifting is done in the base class Alien::Base.
- less lib/Alien/libarchive.pm
* The other generated file that is interesting is the alienfile.
* This is a recipe for how to probe or install the alienized package.
* For a well behaved autoconf or cmake project you may not have to make any changes at all.
- less alienfile
* Now lets test our newly minted dist.
- dzil test
* As you can see the Alien was able to find the system libarchive
* And the test script displayed the compiler and linker flags
* We will need a more complete test to ensure that the Alien works with both XS and FFI
my $xs = <<EOF;
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <archive.h>
MODULE = main PACKAGE = main
const char *
archive_version_string()
EOF
xs_ok $xs, with_subtest {
my $version = archive_version_string();
ok $version;
note $version;
};
ffi_ok { symbols => ['archive_version_string'] }, with_subtest {
my($ffi) = @_;
my $get_version = $ffi->function( archive_version_string => [] => 'string' );
my $version = $get_version->();
ok $version;
note $version;
};
* We want to also make sure that it works as a share install
* So we can use the environment variable ALIEN_INSTALL_TYPE to force a share install.
- env ALIEN_INSTALL_TYPE=share dzil test
* This takes a bit longer since we have to build from source,
* But when complete,
* We can see the test script display the compiler and linker flags
* This time using the share location.
* Next time we will cover how you can use your
* Shiny new Alien.
* Conclusion
- Now you are an expert on Perl's Alien Technology
- Tell me what Aliens are you going to write and contribute to CPAN
- Please let us know by commenting in the section below
- If you have any questions about Perl's Awesome Alien Technology
- Please join us on pound native channel on irc.perl.org
- If something goes wrong,
- Don't panic,
- Just open a ticket on our GitHub
- Until next time, I will see you later.