Last modified by christoph_lechleitner@iteg_at on 2018-01-03 03.50:49

Show last authors
1 Setting up a portable C++ project still is a pain in the ass, especially if it shall be portable.
2
3 When trying to automate it in some way, we came to the conclusion that a full example in a public subversion repository is a good solutions because it's easy to use for you and easy to maintain for us.
4
5 === {{id name="PBA-cbsbootstrappingofportableC++project-HowTo..."/}}HowTo ... ===
6
7 These are the steps for an ultra fast bootstrapping of a portable project relying on pba-cbs and [[our incarnation of the MinGW cross compilation toolchain>>doc:MINGW64.WebHome]].
8
9 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Preparations"/}}Preparations =====
10
11 You need deb sources for {{code language="none"}}pba{{/code}} ({{code language="none"}}any-pba-1.0{{/code}}) and //distro//{{code language="none"}}-mingw-5{{/code}} (i.e. {{code language="none"}}squeeze-mingw-5{{/code}} or {{code language="none"}}wheezy-mingw-5{{/code}}), see [[https:~~/~~/deb.clazzes.org>>url:https://deb.clazzes.org/||shape="rect"]].
12
13 For starters, You need to install the packages {{code language="none"}}pba-cbs{{/code}} and {{code language="none"}}subversion{{/code}}.
14
15 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Retrievethesceleton"/}}Retrieve the sceleton =====
16
17 Decide for the main name of your app:
18
19 {{code language="none"}}
20 MYAPPNAME="myapp"
21 {{/code}}
22
23 Export our example from public svn:
24
25 {{code language="none"}}
26 # for a flat application project:
27 svn export "https://svn.clazzes.org/svn/pba/trunk/pba-helloworld-portable" $MYAPPNAME
28
29 # for a multi-module multi-program application project:
30 svn export "https://svn.clazzes.org/svn/pba/trunk/pba-hellobigworld-portable" $MYAPPNAME
31  
32 # for a library project:
33 svn export "https://svn.clazzes.org/svn/pba/trunk/pba-hellolib-portable" $MYAPPNAME
34 {{/code}}
35
36 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Renameandsearch'n'replace"/}}Rename and search'n'replace =====
37
38 Rename some stuff and have the inlcude files adapted:
39
40 {{code language="none"}}
41 cd $MYAPPNAME
42  
43 scripts/rename_main_files.sh $MYAPPNAME
44  
45 rm scripts/rename_main_files.sh
46 {{/code}}
47
48 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Optional:Removewindowsstuff"/}}Optional: Remove windows stuff =====
49
50 If you do not want windows binaries, remove it:
51
52 (((
53
54
55 {{code language="none"}}
56 # Variant 1: Remove NSIS installer only. For libraries common despite cross compilation.
57 rm -rf nsis src/*.nsi
58
59 # Variant 2: Remove NSIS installer and mingw-6
60 rm -rf nsis src/*.nsi debian-mingw-6
61
62 # Variant 3: Remove all windows crossbuilding stuff
63 rm -rf nsis src/*.nsi src/include-mingw.mk src/*.rc debian-mingw* build/win*
64 $EDITOR build/Makefile
65 {{/code}}
66
67 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Adaptdebianpackagemetainfos"/}}(% style="color: rgb(112,112,112);" %)Adapt debian package meta infos(%%) =====
68 )))
69
70 Change my name and e-mail to yours and adapt the description:
71
72 {{code language="none"}}
73 $EDITOR debian*/control debian*/changelog $(ls -1 src/*.pc.tmpl src/*.rc src/*.nsi src/*.h 2>/dev/null)
74 {{/code}}
75
76 (% style="color: rgb(51,51,51);" %)Do not forget to change the icon, too!
77
78 ===== {{id name="PBA-cbsbootstrappingofportableC++project-UpdateorremovetheReadMe"/}}Update or remove the ReadMe =====
79
80 At least remove the link to this page ...
81
82 {{code language="none"}}
83 # edit ...
84 $EDITOR doc/ReadMe.txt
85  
86 # ... or remove the file and the reference in debian*/rules
87 rm doc/ReadMe.txt
88 $EDITOR debian*/rules
89 {{/code}}
90
91 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Optional:Activatesvnoranotherrevisioncontrolsystem"/}}(% style="line-height: 1.6666666;" %)Optional: Activate svn or another revision control system(%%) =====
92
93 Now (and before any build activity) is a very good time to put your project under subversion control:
94
95 {{code language="none"}}
96 svn add `pwd`
97 {{/code}}
98
99 You might also want to fill {{code language="none"}}svn:ignore{{/code}} properties of some directories:
100
101 {{code language="none"}}
102 scripts/set_svn_ignore.sh
103 {{/code}}
104
105 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Optional:Installrequiredlibsandbuildthepackage"/}}Optional: Install required libs and build the package =====
106
107 To produce the debian packages, just:
108
109 {{code language="none"}}
110 # this needs sudo privileges
111 pba-builddeps -i
112  
113 pba-build -u
114
115 # or dpkg-build*
116 {{/code}}
117
118 To only build the linux packages or only the windows packages, add {{code language="none"}}-o unix{{/code}} resp. {{code language="none"}}-o mingw{{/code}} to the pba-commands.
119
120 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Optional:CreateWindowsInstallers"/}}Optional: Create Windows Installers =====
121
122 (Re)edit the {{code language="none"}}.nsi{{/code}} script template and replace all instances of "{{code language="none"}}Clazzes.org{{/code}}" with something of your choice:
123
124 {{code language="none"}}
125 $EDITOR src/*.nsi
126 {{/code}}
127
128 Then "make" the {{code language="none"}}nsis{{/code}} directory:
129
130 {{code language="none"}}
131 make -C nsis && ls -ltr nsis/*.exe
132 {{/code}}
133
134 ===== {{id name="PBA-cbsbootstrappingofportableC++project-Optionalmulti-module/multi-programvariant:CreateModules,Programs"/}}Optional multi-module/multi-program variant: Create Modules, Programs =====
135
136 {{code language="none"}}
137 # create module common
138 scripts/create_module.sh common
139  
140 # create program foobar-daemon
141 scripts/create_program.sh foobar-daemon
142 {{/code}}
143
144 == {{id name="PBA-cbsbootstrappingofportableC++project-EclipseHints"/}}Eclipse Hints ==
145
146 To create the Ecplise project, select File, New, Project..., C/C++, Makefile Project with existing code.
147
148 The recommended Build Configurations and their Build directories are:
149
150 {{code language="none"}}
151 # Debug
152 ${ProjDirPath}/build/unix/debug
153  
154 # Release
155 ${ProjDirPath}/build/unix/release
156  
157 # Win32
158 ${ProjDirPath}/build/win32/release
159  
160 # Win64
161 ${ProjDirPath}/build/win64/release
162 {{/code}}