-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtravis_cpp_tutorial.lyx
15655 lines (10469 loc) · 238 KB
/
travis_cpp_tutorial.lyx
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{pgf}
\usetikzlibrary{arrows,automata}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures false
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Title
Travis C++ tutorial
\end_layout
\begin_layout Author
Richèl Bilderbeek
\end_layout
\begin_layout Standard
\align center
\begin_inset Graphics
filename images/CppLogo.jpg
lyxscale 50
width 50text%
\end_inset
\begin_inset Graphics
filename docs/images/TravisCIBig.png
lyxscale 50
width 28text%
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents
\end_inset
\end_layout
\begin_layout Section
Introduction
\end_layout
\begin_layout Standard
This is a Travis C++ tutorial, version 0.2.
\end_layout
\begin_layout Subsection
License
\end_layout
\begin_layout Standard
This tutorial is licensed under Creative Commons license 4.0.
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\align center
\begin_inset Graphics
filename docs/images/CC-BY-SA_icon.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Creative Commons license 4.0
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
All C++ code is licensed under GPL 3.0.
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\align center
\begin_inset Graphics
filename images/gplv3.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
GPL 3.0
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Subsection
Continuous integration
\end_layout
\begin_layout Standard
Collaboration can be scary: the other(s)
\begin_inset Foot
status open
\begin_layout Plain Layout
if not you
\end_layout
\end_inset
may break the project worked on.
The project can be of any type, not only programming, but also collaborative
writing.
\end_layout
\begin_layout Standard
A good first step ensuring a pleasant experience is to use a version control
system.
A version control system keeps track of the changes in the project and
allows for looking back in the project history when something has been
broken.
\end_layout
\begin_layout Standard
The next step is to use an online version control repository, which makes
the code easily accessible for all contributors.
The online version control repository may also offer additional collaborative
tools, like a place where to submit bug reports, define project milestones
and allowing external people to submit requests, bug reports or patches.
\end_layout
\begin_layout Standard
Up until here, it is possible to submit a change that breaks the build.
\end_layout
\begin_layout Standard
A continuous integration tools checks what is submitted to the project and
possibly rejects it when it does not satisfy the tests and/or requirements
of the project.
Instead of manually proofreading and/or testing the submission and mailing
the contributor his/her addition is rejected is cumbersome at least.
A continuous integration tool will do this for you.
\end_layout
\begin_layout Standard
Now, if someone changes you project, you can rest assured that his/her submissio
n does not break the project.
Enjoy!
\end_layout
\begin_layout Subsection
Tutorial style
\end_layout
\begin_layout Standard
This tutorial is aimed at the beginner.
\end_layout
\begin_layout Paragraph
Introduction of new terms and tools
\end_layout
\begin_layout Standard
All terms and tools are introduced shortly once, by a 'What is' paragraph.
This allows a beginner to have a general idea about what the term/tool
is, without going in-depth.
Also, this allows for those more knowledgeable to skim the paragraph.
\end_layout
\begin_layout Paragraph
Repetitiveness
\end_layout
\begin_layout Standard
To allow skimming, most chapters follow the same structure.
Sometimes the exact same wording is used.
This is counteracted by referring to earlier chapters.
\end_layout
\begin_layout Paragraph
From Travis to source
\end_layout
\begin_layout Standard
Every build, I start from Travis CI its point of view: 'What do I have to
do?'.
Usually Travis CI has to call at least one build bash script.
After describing the Travis file, I will show those build files.
Those build files usually invoke Qt Creator project files, which in turn
combine source files to executables.
It may feel that the best is saved for last, but I'd disagree: this is
a Travis tutorial.
I also think it makes up for a better narrative, to go from big to small.
\end_layout
\begin_layout Subsection
This tutorial
\end_layout
\begin_layout Standard
This tutorial is available online at
\begin_inset Flex URL
status collapsed
\begin_layout Plain Layout
https://github.com/richelbilderbeek/travis_cpp_tutorial
\end_layout
\end_inset
.
Of course, it is checked by Travis that:
\end_layout
\begin_layout Itemize
all the setups described work
\end_layout
\begin_layout Itemize
this document can be converted to PDF.
For this, it needs the files from all of these setups
\end_layout
\begin_layout Subsection
Acknowledgements
\end_layout
\begin_layout Standard
These people contributed to this tutorial:
\end_layout
\begin_layout Itemize
Kevin Ushey, for getting Rcpp11 and C++11 to work
\end_layout
\begin_layout Subsection
Collaboration
\end_layout
\begin_layout Standard
I welcome collaboration for this tutorial, especially in getting the scripts
as clean as possible.
If you want to help scraping off some lines, I will be happy to make you
a collaborator of some GitHubs.
\end_layout
\begin_layout Subsection
Feedback
\end_layout
\begin_layout Standard
This tutorial is not intended to be perfect yet.
For that, I need help and feedback from the community.
All referenced feedback is welcome, as well as any constructive feedback.
\end_layout
\begin_layout Section
Setting up the basic build
\end_layout
\begin_layout Standard
The basic build is more than just a collection of files.
It needs to be set up.
This chapter shows how to do so.
\end_layout
\begin_layout Itemize
Create a GitHub online
\end_layout
\begin_layout Itemize
Bring the git repository to your local computer
\end_layout
\begin_layout Itemize
Create a Qt Creator project
\end_layout
\begin_layout Itemize
Create the build bash scripts
\end_layout
\begin_layout Subsection
Create a GitHub online
\end_layout
\begin_layout Paragraph
What is GitHub?
\begin_inset Index idx
status open
\begin_layout Plain Layout
GitHub
\end_layout
\end_inset
\end_layout
\begin_layout Standard
GitHub is a site that creates websites around projects.
It is said to host these projects.
Each project contains at least one, but usually multiple files.
These files can be put on your own hard disc, USB stick, or other storage
devices.
They could also be put at a central place, which is called a repository,
so potentially others can also access these.
GitHub is such a file repository.
GitHub also keeps track of the history of the project, which is also called
version control.
GitHub uses git as a version control software.
In short: GitHub hosts git repositories.
\end_layout
\begin_layout Standard
\end_layout
\begin_layout Standard
Figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-homepage"
\end_inset
shows the GitHub homepage,
\begin_inset Flex URL
status collapsed
\begin_layout Plain Layout
https://github.com
\end_layout
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Graphics
filename images/GitHubHomepage.png
lyxscale 50
width 100text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
The GitHub homepage,
\begin_inset Flex URL
status collapsed
\begin_layout Plain Layout
https://github.com
\end_layout
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:GitHub-homepage"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Paragraph
Register
\begin_inset Index idx
status open
\begin_layout Plain Layout
GitHub, registration
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Before you can create a new repository, you must register.
Registration is free for open source projects, with an unlimited
\begin_inset Foot
status open
\begin_layout Plain Layout
the maximum I have observed is a person that has 350 repositories
\end_layout
\end_inset
amount of public repositories.
\end_layout
\begin_layout Standard
From the GitHub homepage,
\begin_inset Flex URL
status collapsed
\begin_layout Plain Layout
https://github.com
\end_layout
\end_inset
(see figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-homepage"
\end_inset
), click the top right button labeled 'Sign up'.
This will take you to the 'Join GitHub' page (see figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-join"
\end_inset
).
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Graphics
filename images/GitHubJoin.png
lyxscale 50
width 100text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
The join GitHub page
\begin_inset CommandInset label
LatexCommand label
name "fig:GitHub-join"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Filling this in should be as easy.
After filling this in, you are taken to your GitHub profile page (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-profile"
\end_inset
).
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Graphics
filename images/GitHubProfile.png
lyxscale 50
width 100text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
A GitHub profile page
\begin_inset CommandInset label
LatexCommand label
name "fig:GitHub-profile"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Paragraph
Creating a repository
\begin_inset Index idx
status open
\begin_layout Plain Layout
GitHub, creating a repository
\end_layout
\end_inset
\end_layout
\begin_layout Standard
From your GitHub profile page (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-profile"
\end_inset
), click on the plus ('Create new ...') at the top right, then click 'New repositor
y' (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-create-repository"
\end_inset
).
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Graphics
filename images/GitHubCreateRepository.png
lyxscale 50
width 100text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Create a GitHub repository
\begin_inset CommandInset label
LatexCommand label
name "fig:GitHub-create-repository"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Do check 'Initialize this repository with a README', add a .gitignore with
'C++' and add a licence like 'GPL 3.0'.
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Graphics
filename images/GitHubCreatedRepository.png
lyxscale 50
width 100text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Created a GitHub repository
\begin_inset CommandInset label
LatexCommand label
name "fig:GitHub-created-repository"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
You have now created your own online version controlled repository (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:GitHub-created-repository"
\end_inset
)!
\end_layout
\begin_layout Subsection
Bring the git repository to your local computer
\end_layout
\begin_layout Paragraph
What is git?
\begin_inset Index idx
status open
\begin_layout Plain Layout
git
\end_layout
\end_inset
\end_layout
\begin_layout Standard
git is a version control system.
It allows you keep a history of a file its content in time.
It is the more convenient alternative of making copies before each modification.
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm, semithick
]
\end_layout
\begin_layout Plain Layout
\backslash
tikzstyle{every state}=[]
\end_layout
\begin_layout Plain Layout
\backslash
node[state] (A) {main.cpp};
\end_layout
\begin_layout Plain Layout
\backslash
node[state] (B) [right of=A] {main.cpp};
\end_layout
\begin_layout Plain Layout
\backslash
node[state] (C) [right of=B] {main.cpp};
\end_layout
\begin_layout Plain Layout
\backslash
path (A) edge [bend left] node {revision 1} (B)
\end_layout
\begin_layout Plain Layout
(B) edge [bend left] node {revision 2} (C)
\end_layout
\begin_layout Plain Layout
;
\end_layout
\begin_layout Plain Layout
\backslash
end{tikzpicture}
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Multiple versions of main.cpp.
git allows to always go back to each version of main
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
status open
\begin_layout Plain Layout
\align center
\begin_inset Graphics
filename images/Git-Logo-2Color.png
lyxscale 10
width 25text%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
git logo
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Paragraph
Using git
\end_layout
\begin_layout Standard
Go to the terminal and type the following line to download your repository:
\end_layout
\begin_layout Standard
\begin_inset listings
inline false
status open
\begin_layout Plain Layout
git clone https://github.com/[your_name]/[your_repository]
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Replace '[your_name]' and '[your_repository]' by your GitHub username and
the repository name.
A new folder called '[your_repository]' is created where you should work
in.
For example, to download this tutorial its repository to a folder called
'travis_cpp_tutorial':
\end_layout
\begin_layout Standard
\begin_inset listings
inline false
status open