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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [libcdl/] [doc/] [package.sgml] - Blame information for rev 778

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

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

powered by: WebSVN 2.1.0

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