OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [libcdl/] [doc/] [package.sgml] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
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
Package Organization
37
 
38
39
 
40
41
For a package to be usable in the &eCos; component framework it must
42
conform to certain rules imposed by that framework. Packages must be
43
distributed in a form that is understood by the component repository
44
administration tool. There must be a top-level &CDL; script which
45
describes the package to the component framework. There are certain
46
limitations related to how a package gets built, so that the package
47
can still be used in a variety of host environments. In addition to
48
these rules, the component framework provides a number of guidelines.
49
Packages do not have to conform to the guidelines, but sticking to
50
them can simplify certain operations.
51
52
53
This chapter deals with the general organization of a package, for
54
example how to distinguish between private and exported header files.
55
 describes the &CDL; language.
56
 details the build process.
57
58
 
59
60
61
 
62
63
Packages and the Component Repository
64
 
65
66
All &eCos; installations include a component repository. This is a
67
directory structure for all installed packages. The component
68
framework comes with an administration tool that allows new packages
69
or new versions of a package to be installed, old packages to be
70
removed, and so on. The component repository includes a simple
71
database, maintained by the administration tool, which contains
72
details of the various packages.
73
74
 
75
76
77
78
79
80
81
82
 
83
84
Each package has its own little directory hierarchy within the
85
component repository. Keeping several packages in a single directory
86
is illegal. The error, infra and kernel packages all live at the
87
top-level of the repository. For other types of packages there are
88
some pre-defined directories: 
89
class="directory">compat is used for compatibility
90
packages, which implement other interfaces such as &uITRON; or POSIX
91
using native &eCos; calls; hal
92
is used for packages that port &eCos; to different architectures or
93
platforms, and this directory is further organized on a
94
per-architecture basis; io is
95
intended for device drivers; 
96
class="directory">language is used for language support
97
libraries, for example the C library. There are no strict rules
98
defining where new packages should get installed. Obviously if an
99
existing top-level directory such as 
100
class="directory">compat is applicable then the new package
101
should go in there. If a new category is desirable then it is possible
102
to create a new sub-directory in the component repository. For
103
example, an organization planning to release a number of &eCos;
104
packages may want them all to appear below a sub-directory
105
corresponding to the organization's name — in the hope that
106
the name will not change too often. It is possible to add new packages
107
directly to the top-level of the component repository, but this should
108
be avoided.
109
110
 
111
112
The ecos.db file holds the component repository
113
database and is managed by the administration tool. The various
114
configuration tools read in this file when they start-up to obtain
115
information about the various packages that have been installed. When
116
developing a new package it is necessary to add some information to
117
the file, as described in . The
118
templates directory holds
119
various configuration templates.
120
121
 
122
123
124
Earlier releases of &eCos; came with two separate files,
125
targets and packages. The
126
ecos.db database replaces both of these.
127
128
129
 
130
131
132
The current ecos.db database does not yet provide
133
all of the information needed by the component framework. Its format
134
is subject to change in future releases, and the file may be replaced
135
completely if necessary. There are a number of other likely future
136
developments related to the component repository and the database. The
137
way targets are described is subject to change. Sometimes it is
138
desirable for component writers to do their initial development in a
139
directory outside the component repository, but there is no specific
140
support in the framework for that yet.
141
142
143
 
144
145
 
146
147
148
 
149
150
Package Versioning
151
152
Below each package directory there can be one or more version
153
sub-directories, named after the versions. This is a requirement of
154
the component framework: it must be possible for users to install
155
multiple versions of a package and select which one to use for any
156
given application. This has a number of advantages to users: most
157
importantly it allows a single component repository to be shared
158
between multiple users and multiple projects, as required; also it
159
facilitates experiments, for example it is relatively easy to try out
160
the latest version of some package and see if it makes any difference.
161
There is a potential disadvantage in terms of disk space. However
162
since &eCos; packages generally consist of source code intended for
163
small embedded systems, and given typical modern disk sizes, keeping a
164
number of different versions of a package installed will usually be
165
acceptable. The administration tool can be used to remove versions
166
that are no longer required.
167
168
 
169
170
171
172
173
174
175
176
 
177
178
The version current is special. Typically it
179
corresponds to the very latest version of the sources, obtained by
180
anonymous &CVS;. These sources may change frequently, unlike full
181
releases which do not change (or only when patches are produced).
182
Component writers may also want to work on the
183
current version.
184
185
186
All other subdirectories of a package correspond to specific releases
187
of that package. The component framework allows users to select the
188
particular version of a package they want to use, but by default the
189
most recent one will be used. This requires some rules for ordering
190
version numbers, a difficult task because of the wide variety of ways
191
in which versions can be identified.
192
193
 
194
195
196
197
The version current is always considered to be
198
the most recent version.
199
200
201
 
202
203
204
If the first character of both strings are either v
205
or V, these are skipped because it makes little
206
sense to enforce case sensitivity here. Potentially this could result
207
in ambiguity if there are two version directories
208
V1.0 and v1.0, but this will
209
match the confusion experienced by any users of such a package.
210
However if two subsequent releases are called V1.0
211
and v1.1, e.g. because of a minor mix-up when
212
making the distribution file, then the case difference is ignored.
213
214
215
 
216
217
218
Next the two version strings are compared one character at a time.
219
If both strings are currently at a digit then a string to number
220
conversion takes place, and the resulting numbers are compared.
221
For example v10 is a more recent release than
222
v2. If the two numbers are the same then processing
223
continues, so for v2b and v2c
224
the version comparison code would move on to b and
225
c.
226
227
228
 
229
230
231
The characters dot ., hyphen -
232
and underscore _ are treated as equivalent
233
separators, so if one release goes out as v1_1 and
234
the next goes out as v1.2 the separator has no
235
effect.
236
237
238
 
239
240
241
If neither string has yet terminated but the characters are different,
242
ASCII comparison is used. For example V1.1b is
243
more recent than v1.1alpha.
244
245
246
 
247
248
249
If one version string terminates before the other, the current
250
character determines which is the more recent. If the other string is
251
currently at a separator character, for example
252
v1.3.1 and v1.3, then the former
253
is assumed to be a minor release and hence more recent than the
254
latter. If the other string is not at a separator character, for
255
example v1.3beta, then it is treated as an
256
experimental version of the v1.3 release and hence
257
older.
258
259
260
 
261
262
263
There is no special processing of dates, so with two versions
264
ss-20000316 and ss-20001111
265
the numerical values 20001111 and
266
20000316 determine the result: larger values are
267
more recent. It is suggested that the full year be used in such cases
268
rather than a shorthand like 00, to avoid
269
Y2100 problems.
270
271
272
 
273
274
275
There is no limit on how many levels of versioning are used, so
276
there could in theory be a v3.1.4.1.5.9.2.7 release
277
of a package. However this is unlikely to be of benefit to typical
278
users of a package.
279
280
281
 
282
283
 
284
285
The version comparison rules of the component framework may not be
286
suitable for every version numbering scheme in existence, but they
287
should cope with many common cases.
288
289
 
290
291
292
There are some issues still to be resolved before it is possible to
293
combine the current sources available via
294
anonymous &CVS and full releases of &eCos; and additional packages in
295
a single component repository. The first problem relates to the
296
ecos.db database: if a new package is added via
297
the CVS repository then this requires a database update, but the
298
administration tool is bypassed. The second problem arises if an
299
organization chooses to place its component repository under source
300
code control using &CVS;, in which case different directories will
301
belong to different &CVS; servers. These issues will be addressed in a
302
future release.
303
304
305
 
306
307
 
308
309
310
 
311
312
 
313
314
Package Contents and Layout
315
316
A typical package contains the following:
317
318
319
320
321
Some number of source files which will end up in a library. The
322
application code will be linked with this library to produce an
323
executable. Some source files may serve other purposes, for example to
324
provide a linker script.
325
326
327
328
329
Exported header files which define the interface provided by the
330
package.
331
332
333
334
335
On-line documentation, for example reference pages for each exported
336
function.
337
338
339
340
341
Some number of test cases, shipped in source format, allowing users to
342
check that the package is working as expected on their particular
343
hardware and in their specific configuration.
344
345
346
347
348
One or more &CDL; scripts describing the package to the configuration
349
system.
350
351
352
353
354
It is also conventional to have a per-package
355
ChangeLog file used to keep track of changes to
356
that package. This is especially valuable to end users of the package
357
who may not have convenient access to the source code control system
358
used to manage the master copy of the package, and hence cannot find
359
out easily what has changed. Often it can be very useful to the main
360
developers as well.
361
362
363
Any given packages need not contain all of these. It is compulsory to
364
have at least one &CDL; script describing the package, otherwise the
365
component framework would be unable to process it. Some packages may
366
not have any source code: it is possible to have a package that merely
367
defines a common interface which can then be implemented by several
368
other packages, especially in the context of device drivers; however
369
it is still common to have some code in such packages to avoid
370
replicating shareable code in all of the implementation packages.
371
Similarly it is possible to have a package with no exported header
372
files, just source code that implements an existing interface: for
373
example an ethernet device driver might just implement a standard
374
interface and not provide any additional functionality. Packages do
375
not need to come with any on-line documentation, although this may
376
affect how many people will want to use the package. Much the same
377
applies to per-package test cases.
378
379
 
380
381
The component framework has a recommended per-package directory layout
382
which splits the package contents on a functional basis:
383
384
 
385
386
387
388
389
390
391
392
 
393
394
For example, if a package has an 
395
class="directory">include sub-directory then the component
396
framework will assume that all header files in and below that
397
directory are exported header files and will do the right thing at
398
build time. Similarly if there is &doc; property indicating the
399
location of on-line documentation then the component framework will
400
first look in the doc
401
sub-directory.
402
403
 
404
405
This directory layout is just a guideline, it is not enforced by the
406
component framework. For simple packages it often makes more sense to
407
have all of the files in just one directory. For example a package
408
could just contain the files hello.cxx,
409
hello.h, hello.html and
410
hello.cdl. By default
411
hello.h will be treated as an exported header
412
file, although this can be overridden with the 
413
linkend="ref.include-files">&include-files; property. Assuming
414
there is a &doc; property referring to hello.html
415
and there is no doc
416
sub-directory then the tools will search for this file relative to the
417
package's top-level and everything will just work. Much the same
418
applies to hello.cxx and
419
hello.cdl.
420
421
 
422
423
424
Older versions of the &eCos; build system only supported packages that
425
followed the directory structure exactly. Hence certain core packages
426
such as error implement the full directory
427
structure, even though that is a particularly simple package and the
428
full directory structure is inappropriate. Component writers can
429
decide for themselves whether or not the directory structure
430
guidelines are appropriate for their package.
431
432
433
 
434
435
436
 
437
438
Outline of the Build Process
439
440
The full build process is described in , but
441
a summary is appropriate here. A build involves three directory
442
structures:
443
444
 
445
446
447
448
The component repository. This is where all the package source code is
449
held, along with &CDL; scripts, documentation, and so on. For build
450
purposes a component repository is read-only. Application developers
451
will only modify the component repository when installing or removing
452
packages, via the administration tool. Component writers will
453
typically work on just one package in the component repository.
454
455
456
457
458
The build tree. Each configuration has its own build tree, which can
459
be regenerated at any time using the configuration's
460
ecos.ecc savefile. The build tree contains only
461
intermediate files, primarily object files. Once a build is complete
462
the build tree contains no information that is useful for application
463
development and can be wiped, although this would slow down any
464
rebuilds following changes to the configuration.
465
466
467
468
469
The install tree. This is populated during a build, and contains all
470
the files relevant to application development. There will be a
471
lib sub-directory which
472
typically contains libtarget.a, a linker script,
473
start-up code, and so on. There will also be an 
474
class="directory">include sub-directory containing all the
475
header files exported by the various packages. There will also be a
476
include/pkgconf sub-directory
477
containing various configuration header files with
478
#define's for the options. Typically the install
479
tree is created within the build tree, but this is not a requirement.
480
481
482
483
 
484
485
The build process involves the following steps:
486
487
488
489
490
Given a configuration, the component framework is responsible for
491
creating all the directories in the build and install trees. If these
492
trees already exist then the component framework is responsible for
493
any clean-ups that may be necessary, for example if a package has been
494
removed then all related files should be expunged from the build and
495
install trees. The configuration header files will be generated at
496
this time. Depending on the host environment, the component framework
497
will also generate makefiles or some other way of building the various
498
packages. Every time the configuration is modified this step needs to
499
be repeated, to ensure that all option consequences take effect. Care
500
is taken that this will not result in unnecessary rebuilds.
501
502
503
504
At present this step needs to be invoked manually. In a future version
505
the generated makefile may if desired perform this step automatically,
506
using a dependency on the ecos.ecc savefile.
507
508
509
510
511
512
The first step in an actual build is to make sure that the install
513
tree contains all exported header files. All compilations will use
514
the install tree's include
515
directory as one of the places to search for header files.
516
517
518
519
520
All source files relevant to the current configuration get compiled.
521
This involves a set of compiler flags initialized on a per-target
522
basis, with each package being able to modify these flags, and with
523
the ability for the user to override the flags as well. Care has to be
524
taken here to avoid inappropriate target-dependencies in packages that
525
are intended to be portable. The component framework has built-in
526
knowledge of how to handle C, C++ and assembler source files —
527
other languages may be added in future, as and when necessary. The
528
&compile; property is used to
529
list the files that should get compiled. All object files end up in
530
the build tree.
531
532
533
534
535
Once all the object files have been built they are collected into a
536
library, typically libtarget.a, which can then be
537
linked with application code. The library is generated in the install
538
tree.
539
540
541
542
543
The component framework provides support for custom build steps, using
544
the &make-object; and
545
&make; properties. The results of
546
these custom build steps can either be object files that should end up
547
in a library, or other files such as a linker script. It is possible
548
to control the order in which these custom build steps take place, for
549
example it is possible to run a particular build step before any of
550
the compilations happen.
551
552
553
554
 
555
556
 
557
558
559
 
560
561
Configurable Source Code
562
563
All packages should be totally portable to all target hardware (with
564
the obvious exceptions of HAL and device driver packages). They should
565
also be totally bug-free, require the absolute minimum amount of code
566
and data space, be so efficient that cpu time usage is negligible, and
567
provide lots of configuration options so that application developers
568
have full control over the behavior. The configuration options are
569
optional only if a package can meet the requirements of every
570
potential application without any overheads. It is not the purpose of
571
this guide to explain how to achieve all of these requirements.
572
573
574
The &eCos; component framework does have some important implications
575
for the source code: compiler flag dependencies; package interfaces
576
vs. implementations; and how configuration options affect source code.
577
578
 
579
580
Compiler Flag Dependencies
581
582
Wherever possible component writers should avoid dependencies on
583
particular compiler flags. Any such dependencies are likely to impact
584
portability. For example, if one package needs to be built in
585
big-endian mode and another package needs to be built in little-endian
586
mode then usually it will not be possible for application developers
587
to use both packages at the same time; in addition the application
588
developer is no longer given a choice in the matter. It is far better
589
for the package source code to adapt the endianness at compile-time,
590
or possibly at run-time although that will involve code-size
591
overheads.
592
593
594
595
A related issue is that the current support for handling compiler
596
flags in the component framework is still limited and incapable of
597
handling flags at a very fine-grain. The support is likely to be
598
enhanced in future versions of the framework, but there are
599
non-trivial problems to be resolved.
600
601
602
603
 
604
605
Package Interfaces and Implementations
606
607
The component framework provides encapsulation at the package level. A
608
package A has no way of accessing the
609
implementation details of another package B at
610
compile-time. In particular, if there is a private header file
611
somewhere in a package's src
612
sub-directory then this header file is completely invisible to other
613
packages. Any attempts to cheat by using relative pathnames beginning
614
with ../.. are generally doomed
615
to failure because of the presence of package version directories.
616
There are two ways in which one package can affect another: by means
617
of the exported header files, which define a public interface; or via
618
the &CDL; scripts.
619
620
621
This encapsulation is a deliberate aspect of the overall &eCos;
622
component framework design. In most cases it does not cause any
623
problems for component writers. In some cases enforcing a clean
624
separation between interface and implementation details can improve
625
the code. Also it reduces problems when a package gets upgraded:
626
component writers are free to do pretty much anything on the
627
implementation side, including renaming every single source file; care
628
has to be taken only with the exported header files and with the &CDL;
629
data, because those have the potential of impacting other packages.
630
Application code is similarly unable to access package implementation
631
details, only the exported interface.
632
633
634
Very occasionally the inability of one package to see implementation
635
details of another does cause problems. One example occurs in HAL
636
packages, where it may be desirable for the architectural, variant and
637
platform HAL's to share some information that should not be visible to
638
other packages or to application code. This may be addressed in the
639
future by introducing the concept of friend
640
packages, just as a C++ class can have friend
641
functions and classes which are allowed special access to a class
642
internals. It is not yet clear whether such cases are sufficiently
643
frequent to warrant introducing such a facility.
644
645
646
 
647
648
Source Code and Configuration Options
649
650
Configurability usually involves source code that needs to implement
651
different behavior depending on the settings of configuration
652
options. It is possible to write packages where the only consequence
653
associated with various configuration options is to control what gets
654
built, but this approach is limited and does not allow for
655
fine-grained configurability. There are three main ways in which
656
options could affect source code at build time:
657
658
 
659
660
661
662
The component code can be passed through a suitable preprocessor,
663
either an existing one such as 
664
class="software">m4 or a new one specially designed with
665
configurability in mind. The original sources would reside in the
666
component repository and the processed sources would reside in the
667
build tree. These processed sources can then be compiled in the usual
668
way.
669
670
671
This approach has two main advantages. First, it is independent from
672
the programming language used to code the components, provided
673
reasonable precautions are taken to avoid syntax clashes between
674
preprocessor statements and actual code. This would make it easier in
675
future to support languages other than C and C++. Second, configurable
676
code can make use of advanced preprocessing facilities such as loops
677
and recursion. The disadvantage is that component writers would have
678
to learn about a new preprocessor and embed appropriate directives in
679
the code. This makes it much more difficult to turn existing code into
680
components, and it involves extra training costs for the component
681
writers.
682
683
684
685
686
Compiler optimizations can be used to elide code that should not be
687
present, for example:
688
689
690
691
    if (CYGHWR_NUMBER_UARTS > 0) {
692
693
     }
694
695
696
697
If the compiler knows that CYGHWR_NUMBER_UARTS is
698
the constant number 0 then it is a trivial operation to get rid of the
699
unnecessary code. The component framework still has to define this
700
symbol in a way that is acceptable to the compiler, typically by using
701
a const variable or a preprocessor symbol. In some
702
respects this is a clean approach to configurability, but it has
703
limitations. It cannot be used in the declarations of data structures
704
or classes, nor does it provide control over entire functions. In
705
addition it may not be immediately obvious that this code is affected
706
by configuration options, which may make it more difficult to
707
understand.
708
709
710
711
712
Existing language preprocessors can be used. In the case of C or C++
713
this would be the standard C preprocessor, and configurable code would
714
contain a number of #ifdef and
715
#if statements.
716
717
718
#if (CYGHWR_NUMBER_UARTS > 0)
719
720
#endif
721
722
723
This approach has the big advantage that the C preprocessor is a
724
technology that is both well-understood and widely used. There are
725
also disadvantages: it is not directly applicable to components
726
written in other languages such as Java (although it is possible to
727
use the C preprocessor as a stand-alone program); the preprocessing
728
facilities are rather limited, for example there is no looping
729
facility; and some people consider the technology to be ugly. Of
730
course it may be possible to get around the second objection by
731
extending the preprocessor that is used by gcc and g++.
732
733
734
735
 
736
737
The current component framework generates configuration header files
738
with C preprocessor #define's for each option
739
(typically, there various properties which can be used to control
740
this). It is up to component writers to decide whether to use
741
preprocessor #ifdef statements or language
742
constructs such as if. At present there is no
743
support for languages which do not involve the C preprocessor,
744
although such support can be added in future when the need arises.
745
746
 
747
748
 
749
 
750
751
 
752
753
754
 
755
756
Exported Header Files
757
 
758
759
A package's exported header files should specify the interface
760
provided by that package, and avoid any implementation details.
761
However there may be performance or other reasons why implementation
762
details occasionally need to be present in the exported headers.
763
764
 
765
766
767
Not all programming languages have the concept of a header file. In
768
some cases the component framework would need extensions to support
769
packages written in such languages.
770
771
772
 
773
774
Configurability has a number of effects on the way exported header
775
files should be written. There may be configuration options which
776
affect the interface of a package, not just the implementation. It is
777
necessary to worry about nested #include's and how
778
this affects package and application builds. A special case of this
779
relates to whether or not exported header files should
780
#include configuration headers. These configuration
781
headers are exported, but should only be #include'd
782
when necessary.
783
784
 
785
786
Configurable Functionality
787
 
788
789
Many configuration options affect only the implementation of a
790
package, not the interface. However some options will affect the
791
interface as well, which means that the options have to be tested in
792
the exported header files. Some implementation choices, for example
793
whether or not a particular function should be inlined, also need to
794
be tested in the header file because of language limitations.
795
796
797
Consider a configuration option
798
CYGFUN_KERNEL_MUTEX_TIMEDLOCK which controls
799
whether or not a function cyg_mutex_timedlock is
800
provided. The exported kernel header file 
801
class="headerfile">cyg/kernel/kapi.h could contain the
802
following:
803
804
 
805
806
#include <pkgconf/kernel.h>
807
808
#ifdef CYGFUN_KERNEL_MUTEX_TIMEDLOCK
809
extern bool cyg_mutex_timedlock(cyg_mutex_t*);
810
#endif
811
812
 
813
814
This is a correct header file, in that it defines the exact interface
815
provided by the package at all times. However is has a number of
816
implications. First, the header file is now dependent on 
817
class="headerfile">pkgconf/kernel.h, so any changes to
818
kernel configuration options will cause 
819
class="headerfile">cyg/kernel/kapi.h to be out of date, and
820
any source files that use the kernel interface will need rebuilding.
821
This may affect sources in the kernel package, in other packages, and
822
in application source code. Second, if the application makes use of
823
this function somewhere but the application developer has
824
misconfigured the system and disabled this functionality anyway then
825
there will now be a compile-time error when building the application.
826
Note that other packages should not be affected, since they should
827
impose appropriate constraints on
828
CYGFUN_KERNEL_MUTEX_TIMEDLOCK if they use that
829
functionality (although of course some dependencies like this may get
830
missed by component developers).
831
832
833
An alternative approach would be:
834
835
 
836
837
extern bool cyg_mutex_timedlock(cyg_mutex_t*);
838
839
 
840
841
Effectively the header file is now lying about the functionality
842
provided by the package. The first result is that there is no longer a
843
dependency on the kernel configuration header. The second result is
844
that an application file using the timed-lock function will now
845
compile, but the application will fail to link. At this stage the
846
application developer still has to intervene, change the
847
configuration, and rebuild the system. However no application
848
recompilations are necessary, just a relink.
849
850
 
851
852
Theoretically it would be possible for a tool to analyze linker errors
853
and suggest possible configuration changes that would resolve the
854
problem, reducing the burden on the application developer. No such
855
tool is planned in the short term.
856
857
 
858
859
It is up to component writers to decide which of these two approaches
860
should be preferred. Note that it is not always possible to avoid
861
#include'ing a configuration header file in an
862
exported one, for example an option may affect a data structure rather
863
than just the presence or absence of a function. Issues like this will
864
vary from package to package.
865
866
 
867
868
 
869
870
Nested <literal>#include's</literal>
871
872
As a general rule, unnecessary #include's should be
873
avoided. A header file should #include only those
874
header files which are absolutely needed for it to define its
875
interface. Any additional #include's make it more
876
likely that package or application source files become dependent on
877
configuration header files and will get rebuilt unnecessarily when
878
there are minor configuration changes.
879
880
881
 
882
883
Including Configuration Headers
884
885
Exported header files should avoid #include'ing
886
configuration header files unless absolutely necessary, to avoid
887
unnecessary rebuilding of both application code and other packages
888
when there are minor configuration changes. A
889
#include is needed only when a configuration option
890
affects the exported interface, or when it affects some implementation
891
details which is controlled by the header file such as whether or not
892
a particular function gets inlined.
893
894
895
There are a couple of ways in which the problem of unnecessary
896
rebuilding could be addressed. The first would require more
897
intelligent handling of header file dependency handling by the tools
898
(especially the compiler) and the build system. This would require
899
changes to various non-eCos tools. An alternative approach would be to
900
support finer-grained configuration header files, for example there
901
could be a file 
902
class="headerfile">pkgconf/libc/inline.h controlling which
903
functions should be inlined. This could be achieved by some fairly
904
simple extensions to the component framework, but it makes it more
905
difficult to get the package header files and source code correct:
906
a C preprocessor #ifdef directive does not
907
distinguish between a symbol not being defined because the option is
908
disabled, or the symbol not being defined because the appropriate
909
configuration header file has not been #include'd.
910
It is likely that a cross-referencing tool would have to be developed
911
first to catch problems like this, before the component framework
912
could support finer-grained configuration headers.
913
914
915
 
916
917
 
918
919
920
 
921
922
Package Documentation
923
924
On-line package documentation should be in HTML format. The component
925
framework imposes no special limitations: component writers can decide
926
which version of the HTML specification should be followed; they can
927
also decide on how best to cope with the limitations of different
928
browsers. In general it is a good idea to keep things simple.
929
930
931
 
932
933
934
 
935
936
Test Cases
937
938
Packages should normally come with one or more test cases. This allows
939
application developers to verify that a given package works correctly
940
on their particular hardware and in their particular configuration,
941
making it slightly more likely that they will attempt to find bugs in
942
their own code rather than automatically blaming the component
943
writers.
944
945
946
At the time of writing the application developer support for building
947
and running test cases via the component framework is under review and
948
likely to change. Currently each test case should consist of a single
949
C or C++ source file that can be compiled with the package's set of
950
compiler flags and linked like any application program. Each test case
951
should use the testing API defined by the infrastructure. A
952
magically-named calculated configuration option of the form
953
CYGPKG_<PACKAGE-NAME>_TESTS lists the test
954
cases.
955
956
957
 
958
959
960
 
961
962
Host-side Support
963
964
On occasion it would be useful for an &eCos; package to be shipped
965
with host-side support. This could take the form of an additional tool
966
needed to build that package. It could be an application intended to
967
communicate with the target-side package code and display monitoring
968
information. It could be a utility needed for running the package test
969
cases, especially in the case of device drivers. The component
970
framework does not yet provide any such support for host-side
971
software, and there are obvious issues related to portability to the
972
different machines that can be used for hosts. This issue may get
973
addressed in some future release. In some cases custom build steps can
974
be subverted to do things on the host side rather than the target
975
side, but this is not recommended.
976
977
978
 
979
980
 
981
982
 
983
984
985
 
986
987
Making a Package Distribution
988
 
989
990
Developers of new &eCos; packages are advised to distribute their
991
packages in the form of &eCos; package distribution files. Packages
992
distributed in this format may be added to existing &eCos; component
993
repositories in a robust manner using the Package Administration Tool.
994
This chapter describes the format of package distribution files and
995
details how to prepare an eCos package for distribution in this format.
996
997
 
998
999
The &eCos; package distribution file format
1000
 
1001
1002
eCos package distribution files are gzipped GNU tar archives which
1003
contain both the source code for one or more &eCos; packages and a
1004
data file containing package information to be added to the component
1005
repository database. The distribution files are subject to the
1006
following rules:
1007
1008
1009
1010
1011
The data file must be named pkgadd.db and must be
1012
located in the root of the tar archive. It must contain data in a
1013
format suitable for appending to the eCos repository database
1014
(ecos.db). 
1015
describes this data format. Note that a database consistency check is
1016
performed by the &eCos; Administration Tool when
1017
pkgadd.db has been appended to the database. Any
1018
new target entries which refer to unknown packages will be removed at
1019
this stage.
1020
1021
1022
1023
1024
The package source code must be placed in one or more 
1025
class="directory"><package-path>/<version>
1026
directories in the tar archive, where each <package-path>
1027
directory path is specified as the directory attribute of one of the
1028
packages entries in pkgadd.db.
1029
1030
1031
1032
1033
An optional license agreement file named
1034
pkgadd.txt may be placed in the root of the tar
1035
archive. It should contain text with a maximum line length of 79
1036
characters. If this file exists, the contents will be presented to the
1037
user during installation of the package. The &eCos; Package
1038
Administration Tool will then prompt the user with the question
1039
"Do you accept all the terms of the preceding license
1040
agreement?". The user must respond
1041
"yes" to this prompt in order to proceed with
1042
the installation.
1043
1044
1045
1046
1047
Optional template files may be placed in one or more 
1048
class="directory">templates/<template_name>
1049
directories in the tar archive. Note that such template files would be
1050
appropriate only where the packages to be distributed have a complex
1051
dependency relationship with other packages. Typically, a third party
1052
package can be simply added to an eCos configuration based on an
1053
existing core template and the provision of new templates would not be
1054
appropriate.  contains more
1055
information on templates.
1056
1057
1058
1059
1060
The distribution file must be given a .epk (not
1061
.tar.gz) file extension. The
1062
.epk file extension serves to distinguish &eCos;
1063
package distributions files from generic gzipped GNU tar archives. It
1064
also discourages users from attempting to extract the package from the
1065
archive manually. The file browsing dialog of the &eCos; Package
1066
Administration Tool lists only those files which have a
1067
.epk extension.
1068
1069
1070
1071
1072
No other files should be present in the archive.
1073
1074
1075
1076
1077
Files in the tar archive may use LF or
1078
CRLF line endings interchangably. The &eCos;
1079
Administration Tool ensures that the installed files are given the
1080
appropriate host-specific line endings.
1081
1082
1083
1084
1085
Binary files may be placed in the archive, but the distribution of
1086
object code is not recommended. All binary files must be given a
1087
.bin suffix in addition to any file extension they
1088
may already have. For example, the GIF image file
1089
myfile.gif must be named
1090
myfile.gif.bin in the archive. The
1091
.bin suffix is removed during file extraction and
1092
is used to inhibit the manipulation of line endings by the &eCos;
1093
Administration Tool.
1094
1095
1096
1097
1098
 
1099
1100
Preparing eCos packages for distribution
1101
 
1102
1103
Development of new &eCos; packages or new versions of existing &eCos;
1104
packages will take place in the context of an existing &eCos;
1105
component repository. This section details the steps involved in
1106
extracting new packages from a repository and generating a
1107
corresponding &eCos; package distribution file for distribution of the
1108
packages to other &eCos; users. The steps required are as follows:
1109
1110
 
1111
1112
1113
1114
Create a temporary directory 
1115
class="directory">$PKGTMP for manipulation of the package
1116
distribution file contents and copy the source files of the new
1117
packages into this directory, preserving the relative path to the
1118
package. In the case of a new package at 
1119
class="directory">mypkg/current in the repository:
1120
1121
1122
    $ mkdir -p $PKGTMP/mypkg
1123
    $ cp -p -R $ECOS_REPOSITORY/mypkg/current $PKGTMP/mypkg
1124
1125
1126
Where more than one package is to be distributed in a single package
1127
distribution file, copy each package in the above manner. Note that
1128
multiple packages distributed in a single package distribution file
1129
cannot be installed separately. Where such flexibility is required,
1130
distribution of each new package in separate package distribution files
1131
is recommended.
1132
1133
1134
1135
1136
Copy any template files associated with the distributed packages into
1137
the temporary directory, preserving the relative path to the template.
1138
For example:
1139
1140
1141
    $ mkdir -p $PKGTMP/templates
1142
    $ cp -p -R $ECOS_REPOSITORY/templates/mytemplate $PKGTMP/templates
1143
1144
1145
1146
1147
Remove any files from the temporary directory hierarchy which you do
1148
not want to distribute with the packages (eg object files, 
1149
class="directory">CVS directories).
1150
1151
1152
1153
1154
Add a .bin suffix to the name of any binary
1155
files. For example, if the packages contains GIF image files (*.gif)
1156
for documentation purposes, such files must be renamed to *.gif.bin as
1157
follows:
1158
1159
1160
   $ find $PKGTMP -type f -name '*.gif' -exec mv {} {}.bin ';'
1161
1162
1163
The .bin suffix is removed during file extraction
1164
and is used to inhibit the manipulation of line endings by the eCos
1165
Package Administration Tool.
1166
1167
1168
1169
1170
Extract the package records for the new packages from the package
1171
database file at $ECOS_REPOSITORY/ecos.db and
1172
create a new file containing these records at
1173
$PKGTMP/pkgadd.db (in the root of the temporary
1174
directory hierarchy). Any target records which reference the
1175
distributed packages must also be provided in pkgadd.db.
1176
1177
1178
1179
1180
Rename the version directories under 
1181
class="directory">$PKGTMP (typically 
1182
class="directory">current during development) to reflect
1183
the versions of the packages you are distributing. For example,
1184
version 1.0 of a package may use the version directory name 
1185
class="directory">v1_0:
1186
1187
1188
    $ cd $PKGTMP/mypkg
1189
    $ mv current v1_0
1190
1191
1192
 describes the version naming
1193
conventions.
1194
1195
1196
1197
1198
Rename any template files under 
1199
class="directory">$PKGTMP (typically
1200
current.ect during development) to reflect the
1201
version of the template you are distributing. For example, version 1.0
1202
of a template may use the filename v1_0.ect:
1203
1204
1205
    $ cd $PKGTMP/templates/mytemplate
1206
    $ mv current.ect v1_0.ect
1207
1208
1209
It is also important to edit the contents of the template file, changing
1210
the version of each referenced package to match that of the packages you
1211
are distributing. This step will eliminate version warnings during the
1212
subsequent loading of the template.
1213
1214
1215
1216
1217
Optionally create a licence agreement file at
1218
$PKGTMP/pkgadd.txt containing the licensing terms
1219
under which you are distributing the new packages. Limit each line in
1220
this file to a maximum of 79 characters.
1221
1222
1223
1224
1225
Create a GNU tar archive of the temporary directory hierarchy. By
1226
convention, this archive would have a name of the form
1227
<package_name>-<version>:
1228
1229
1230
    $ cd $PKGTMP
1231
    $ tar cf mypkg-1.0.tar *
1232
1233
1234
Note that non-GNU version of tar may create archive files which exhibit
1235
subtle incompatibilities with GNU tar. For this reason, always use GNU
1236
tar to create the archive file.
1237
1238
1239
1240
1241
Compress the archive using gzip and give the resulting file a
1242
.epk file extension:
1243
1244
1245
    $ gzip mypkg-1.0.tar
1246
    $ mv mypkg-1.0.tar.gz mypkg-1.0.epk
1247
1248
1249
The resulting eCos package distribution file (*.epk) is in a compressed
1250
format and may be distributed without further compression.
1251
1252
1253
1254
 
1255
1256
 
1257
1258
 
1259
1260
 
1261

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.