mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 14:33:34 +08:00
Completes coding of the PWM module
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4200 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
############################################################################
|
||||
# Makefile.export
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(TOPDIR)/.config
|
||||
include $(EXPORTDIR)/Make.defs
|
||||
|
||||
ifdef ARCHSCRIPT
|
||||
LDPATH = ${shell echo "$(ARCHSCRIPT)" | sed -e "s/^-T[ ]*//g"}
|
||||
LDNAME = ${shell basename ${LDPATH}}
|
||||
LDDIR = ${shell dirname ${LDPATH}}
|
||||
endif
|
||||
ARCHSUBDIR = "arch/$(CONFIG_ARCH)/src"
|
||||
ARCHDIR ="$(TOPDIR)/$(ARCHSUBDIR)"
|
||||
|
||||
all: $(EXPORTDIR)/makeinfo.sh
|
||||
default: all
|
||||
.PHONY: clean
|
||||
|
||||
$(EXPORTDIR)/makeinfo.sh: $(TOPDIR)/.config $(EXPORTDIR)/Make.defs
|
||||
@echo "#!/bin/bash" > $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "ARCHSUBDIR=\"$(ARCHSUBDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "ARCHDIR=\"$(ARCHDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
ifdef ARCHSCRIPT
|
||||
@echo "LDNAME=\"$(LDNAME)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "LDDIR=\"$(LDDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "LDPATH=\"$(LDPATH)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
endif
|
||||
@echo "ARCHCFLAGS=\"$(ARCHCFLAGS) $(ARCHCPUFLAGS)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@echo "ARCHCXXFLAGS=\"$(ARCHCXXFLAGS) $(ARCHCPUFLAGS)\"" >> $(EXPORTDIR)/makeinfo.sh
|
||||
@chmod 755 $(EXPORTDIR)/makeinfo.sh
|
||||
|
||||
clean:
|
||||
@rm -f $(EXPORTDIR)/makeinfo.sh
|
||||
@@ -0,0 +1,67 @@
|
||||
############################################################################
|
||||
# Makefile.host
|
||||
#
|
||||
# Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
all: mkconfig mkversion mksyscall bdf-converter
|
||||
default: mkconfig mksyscall
|
||||
.PHONY: clean
|
||||
|
||||
# Add CFLAGS=-g on the make command line build debug versions
|
||||
|
||||
CFLAGS = -O2 -Wall -I.
|
||||
|
||||
# mkconfig - Convert a .config file into a C config.h file
|
||||
|
||||
mkconfig: mkconfig.c cfgparser.c
|
||||
@gcc $(CFLAGS) -o mkconfig mkconfig.c cfgparser.c
|
||||
|
||||
# mkversion - Convert a .version file into a C version.h file
|
||||
|
||||
mkversion: mkconfig.c cfgparser.c
|
||||
@gcc $(CFLAGS) -o mkversion mkversion.c cfgparser.c
|
||||
|
||||
# mksyscall - Convert a CSV file into syscall stubs and proxies
|
||||
|
||||
mksyscall: mksyscall.c
|
||||
@gcc $(CFLAGS) -o mksyscall mksyscall.c
|
||||
|
||||
# bdf-converter - Converts a BDF font to the NuttX font format
|
||||
|
||||
bdf-converter: bdf-converter.c
|
||||
@gcc $(CFLAGS) -o bdf-converter bdf-converter.c
|
||||
|
||||
clean:
|
||||
@rm -f *.o *.a *~ .*.swp
|
||||
@rm -f mkconfig mksyscall mkversion bdf-converter
|
||||
@rm -f mkconfig.exe mksyscall.exe mkversion.exe bdf-converter.exe
|
||||
Executable
+303
@@ -0,0 +1,303 @@
|
||||
tools/README.txt
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This README file addresses the contents of the NuttX tools/ directory.
|
||||
|
||||
The tools/ directory contains miscellaneous scripts and host C programs
|
||||
that are necessary parts of the the NuttX build system. These files
|
||||
include:
|
||||
|
||||
README.txt
|
||||
|
||||
This file
|
||||
|
||||
configure.sh
|
||||
|
||||
This is a bash script that is used to configure NuttX for a given
|
||||
target board. See configs/README.txt or Documentation/NuttxPortingGuide.html
|
||||
for a description of how to configure NuttX with this script.
|
||||
|
||||
mkconfig.c, cfgparser.c, and cfgparser.h
|
||||
|
||||
This is C file that is used to build mkconfig program. The mkconfig
|
||||
program is used during the initial NuttX build.
|
||||
|
||||
When you configure NuttX, you will copy a configuration file called .config
|
||||
in the top level NuttX directory (See configs/README.txt or
|
||||
Documentation/NuttxPortingGuide.html). The first time you make NuttX,
|
||||
the top-level makefile will build the mkconfig executable from mkconfig.c
|
||||
(using Makefile.host). The top-level Makefile will then execute the
|
||||
mkconfig program to convert the .config file in the top level directory
|
||||
into include/nuttx/config.h. config.h is a another version of the
|
||||
NuttX configuration that can be included by C files.
|
||||
|
||||
mkexport.sh and Makefile.export
|
||||
|
||||
These implement part of the top-level Makefile's 'export' target. That
|
||||
target will bundle up all of the NuttX libraries, header files, and the
|
||||
startup object into an export-able, binary NuttX distribution. The
|
||||
Makefile.export is used only by the mkexport.sh script to parse out
|
||||
options from the top-level Make.defs file.
|
||||
|
||||
mkversion.c, cfgparser.c, and cfgparser.h
|
||||
|
||||
This is C file that is used to build mkversion program. The mkversion
|
||||
program is used during the initial NuttX build.
|
||||
|
||||
When you build NuttX there should be a version file called .version in
|
||||
the top level NuttX directory (See Documentation/NuttxPortingGuide.html).
|
||||
The first time you make NuttX, the top-level makefile will build th
|
||||
mkversion executable from mkversion.c (using Makefile.host). The top-
|
||||
level Makefile will then execute the mkversion program to convert the
|
||||
.version file in the top level directory into include/nuttx/version.h.
|
||||
version.h provides version information that can be included by C files.
|
||||
|
||||
mksyscall.c
|
||||
|
||||
This is a C file that is used to build mksyscall program. The mksyscall
|
||||
program is used during the initial NuttX build by the logic in the top-
|
||||
level syscall/ directory.
|
||||
|
||||
If you build NuttX as a separately compiled, monolithic kernel and separate
|
||||
applications, then there is a syscall layer that is used to get from the
|
||||
user application space to the NuttX kernel space. In the user application
|
||||
"proxies" for each of the kernel functions are provided. The proxies have
|
||||
the same function signature as the kernel function, but only execute a
|
||||
system call.
|
||||
|
||||
Within the kernel, there are "stubs" for each of the system calls. The
|
||||
stubs receive the marshalled system call data, and perform the actually
|
||||
kernel function call (in kernel-mode) on behalf of the proxy function.
|
||||
|
||||
Information about the stubs and proxies is maintained in a comma separated
|
||||
value (CSV) file in the syscall/ directory. The mksyscall program will
|
||||
accept this CVS file as input and generate all of the required proxy or
|
||||
stub files as output. See syscall/README.txt for additonal information.
|
||||
|
||||
bdf-convert.c
|
||||
|
||||
This C file is used to build the bdf-converter program. The bdf-converter
|
||||
program be used to convert fonts in Bitmap Distribution Format (BDF)
|
||||
into fonts that can be used in the NX graphics system.
|
||||
|
||||
Below are general instructions for creating and installing a new font
|
||||
in the NX graphic system:
|
||||
|
||||
1. Locate a font in BDF format,
|
||||
2. Use the bdf-converter program to convert the BDF font to the NuttX
|
||||
font format. This will result in a C header file containing
|
||||
defintions. That header file should be installed at, for example,
|
||||
graphics/nxfonts/nxfonts_myfont.h.
|
||||
|
||||
Create a new NuttX configuration variable. For example, suppose
|
||||
you define the following variable: CONFIG_NXFONT_MYFONT. Then
|
||||
you would need to:
|
||||
|
||||
3. Define CONFIG_NXFONT_MYFONT=y in your NuttX configuration file.
|
||||
|
||||
A font ID number has to be assigned for each new font. The font ID
|
||||
is defined in the file include/nuttx/nx/nxfonts.h. Those definitions
|
||||
have to be extended to support your new font. Look at how the font ID
|
||||
enabled by CONFIG_NXFONT_SANS23X27 is defined and add an ID for your
|
||||
new font in a similar fashion:
|
||||
|
||||
4. include/nuttx/nx/nxfonts.h. Add you new font as a possible system
|
||||
default font:
|
||||
|
||||
#if defined(CONFIG_NXFONT_SANS23X27)
|
||||
# define NXFONT_DEFAULT FONTID_SANS23X27
|
||||
#elif defined(CONFIG_NXFONT_MYFONT)
|
||||
# define NXFONT_DEFAULT FONTID_MYFONT
|
||||
#endif
|
||||
|
||||
Then define the actual font ID. Make sure that the font ID value
|
||||
is unique:
|
||||
|
||||
enum nx_fontid_e
|
||||
{
|
||||
FONTID_DEFAULT = 0 /* The default font */
|
||||
#ifdef CONFIG_NXFONT_SANS23X27
|
||||
, FONTID_SANS23X27 = 1 /* The 23x27 sans serif font */
|
||||
#endif
|
||||
#ifdef CONFIG_NXFONT_MYFONT
|
||||
, FONTID_MYFONT = 2 /* My shiny, new font */
|
||||
#endif
|
||||
...
|
||||
|
||||
New Add the font to the NX build system. There are several files that
|
||||
you have to modify to to this. Look how the build system uses the
|
||||
font CONFIG_NXFONT_SANS23X27 for examaples:
|
||||
|
||||
5. nuttx/graphics/Makefile. This file needs logic to auto-generate
|
||||
a C source file from the header file that you generated with the
|
||||
the bdf-converter program. Notice NXFONTS_FONTID=2; this must be
|
||||
set to the same font ID value that you defined in the
|
||||
include/nuttx/nx/nxfonts.h file.
|
||||
|
||||
genfontsources:
|
||||
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
|
||||
@$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES)
|
||||
endif
|
||||
ifeq ($(CONFIG_NXFONT_MYFONT),y)
|
||||
@$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES)
|
||||
endif
|
||||
|
||||
6. nuttx/graphics/nxfonts/Make.defs. Set the make variable NXFSET_CSRCS.
|
||||
NXFSET_CSRCS determines the name of the font C file to build when
|
||||
NXFONTS_FONTID=2:
|
||||
|
||||
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
|
||||
NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
|
||||
endif
|
||||
ifeq ($(CONFIG_NXFONT_MYFONT),y)
|
||||
NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
|
||||
endif
|
||||
|
||||
7. nuttx/graphics/nxfonts/Makefile.sources. This is the Makefile used
|
||||
in step 5 that will actually generate the font C file. So, given
|
||||
your NXFONTS_FONTID=2, it needs to determine a prefix to use for
|
||||
auto-generated variable and function names and (again) the name of
|
||||
the autogenerated file to create (this must be the same name that
|
||||
was used in nuttx/graphics/nxfonts/Make.defs):
|
||||
|
||||
ifeq ($(NXFONTS_FONTID),1)
|
||||
NXFONTS_PREFIX := g_sans23x27_
|
||||
GEN_CSRC = nxfonts_bitmaps_sans23x27.c
|
||||
endif
|
||||
ifeq ($(NXFONTS_FONTID),2)
|
||||
NXFONTS_PREFIX := g_myfont_
|
||||
GEN_CSRC = nxfonts_bitmaps_myfont.c
|
||||
endif
|
||||
|
||||
8. graphics/nxfonts/nxfonts_bitmaps.c. This is the file that contains
|
||||
the generic font structures. It is used as a "template" file by
|
||||
nuttx/graphics/nxfonts/Makefile.sources to create your customized
|
||||
font data set.
|
||||
|
||||
#if NXFONTS_FONTID == 1
|
||||
# include "nxfonts_sans23x27.h"
|
||||
#elif NXFONTS_FONTID == 2
|
||||
# include "nxfonts_myfont.h"
|
||||
#else
|
||||
# error "No font ID specified"
|
||||
#endif
|
||||
|
||||
Where nxfonts_myfont.h is the NuttX font file that we generated in
|
||||
step 2 using the bdf-converter tool.
|
||||
|
||||
9. graphics/nxfonts/nxfonts_getfont.c. Finally, we need to extend the
|
||||
logic that does the run-time font lookups so that can find our new
|
||||
font. The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid).
|
||||
The new font information needs to be added to data structures used by
|
||||
that function:
|
||||
|
||||
#ifdef CONFIG_NXFONT_SANS23X27
|
||||
extern const struct nx_fontpackage_s g_sans23x27_package;
|
||||
#endif
|
||||
#ifdef CONFIG_NXFONT_MYFONT
|
||||
extern const struct nx_fontpackage_s g_myfont_package;
|
||||
#endif
|
||||
|
||||
static FAR const struct nx_fontpackage_s *g_fontpackages[] =
|
||||
{
|
||||
#ifdef CONFIG_NXFONT_SANS23X27
|
||||
&g_sans23x27_package,
|
||||
#endif
|
||||
#ifdef CONFIG_NXFONT_MYFONT
|
||||
&g_myfont_package,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
Makefile.host
|
||||
|
||||
This is the makefile that is used to make the mkconfig program from
|
||||
the mkconfig.c C file, the mkversion program from the mkconfig.c C file,
|
||||
or the mksyscall program from the mksyscall.c file.
|
||||
|
||||
mkromfsimg.sh
|
||||
|
||||
This script may be used to automate the generate of a ROMFS file system
|
||||
image. It accepts an rcS script "template" and generates and image that
|
||||
may be mounted under /etc in the NuttX pseudo file system.
|
||||
|
||||
mkdeps.sh
|
||||
mknulldeps.sh
|
||||
|
||||
NuttX uses the GCC compilers capabilities to create Makefile dependencies.
|
||||
The bash script mkdeps.sh is used to run GCC in order to create the
|
||||
dependencies. If a NuttX configuration uses the GCC toolchain, its Make.defs
|
||||
file (see configs/README.txt) will include a line like:
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
If the NuttX configuration does not use a GCC compatible toolchain, then
|
||||
it cannot use the dependencies and instead it uses mknulldeps.sh:
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||
|
||||
The mknulldeps.sh is a stub script that does essentially nothing.
|
||||
|
||||
define.sh
|
||||
|
||||
Different compilers have different conventions for specifying pre-
|
||||
processor definitions on the compiler command line. This bash
|
||||
script allows the build system to create create command line definitions
|
||||
without concern for the particular compiler in use.
|
||||
|
||||
incdir.sh
|
||||
|
||||
Different compilers have different conventions for specifying lists
|
||||
of include file paths on the the compiler command line. This bash
|
||||
script allows the build system to create include file paths without
|
||||
concern for the particular compiler in use.
|
||||
|
||||
link.sh
|
||||
winlink.sh
|
||||
unlink.sh
|
||||
|
||||
Different file system have different capabilities for symbolic links.
|
||||
Some windows file systems have no native support for symbolic links.
|
||||
Cygwin running under windows has special links built in that work with
|
||||
all cygwin tools. However, they do not work when Windows native tools
|
||||
are used with cygwin. In that case something different must be done.
|
||||
|
||||
If you are building under Linux or under cygwin with a cygwin tool
|
||||
chain, then your Make.defs file may have definitions like the
|
||||
following:
|
||||
|
||||
DIRLINK = $(TOPDIR)/tools/link.sh
|
||||
DIRUNLINK = (TOPDIR)/tools/unlink.sh
|
||||
|
||||
The first definition is not always present because link.sh is the
|
||||
default. link.sh is a bash script that performs a normal, Linux-style
|
||||
symbolic link; unlink.sh is a do-it-all unlinking script.
|
||||
|
||||
But if you are building under cygwin using a Windows native toolchain,
|
||||
then you will need something like the following in you Make.defs file:
|
||||
|
||||
DIRLINK = $(TOPDIR)/tools/winlink.sh
|
||||
DIRUNLINK = (TOPDIR)/tools/unlink.sh
|
||||
|
||||
winlink.sh will copy the whole directory instead of linking it.
|
||||
|
||||
NOTE: I have been told that some NuttX users have been able to build
|
||||
successfully using the GnuWin32 tools and modifying the link.sh
|
||||
script so that it uses the NTFS mklink command. But I have never
|
||||
tried that
|
||||
|
||||
mkimage.sh
|
||||
|
||||
The creates a downloadable image as needed with the rrload bootloader.
|
||||
|
||||
indent.sh
|
||||
|
||||
This script can be used to indent .c and .h files in a manner similar
|
||||
to my coding NuttX coding style. It doesn't do a really good job,
|
||||
however (see the comments at the top of the indent.sh file).
|
||||
|
||||
zipme.sh
|
||||
|
||||
I use this script to create the nuttx-xx.yy.tar.gz tarballs for
|
||||
release on SourceForge. It is handy because it also does the
|
||||
kind of clean that you need to do to make a clean code release.
|
||||
@@ -0,0 +1,675 @@
|
||||
/****************************************************************************
|
||||
* tools/bdf-converter.c
|
||||
*
|
||||
* Copyright (C) 2011 NX Engineering, S.A., All rights reserved.
|
||||
* Author: Jose Pablo Carballo Gomez <jcarballo@nx-engineering.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Based one the "Glyph Bitmap Distribution Format (BDF) Specification",
|
||||
* Version 2.2, by Adobe Systems Incorporated.
|
||||
*
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
#define VERBOSE
|
||||
#define DBG
|
||||
*/
|
||||
|
||||
// BDF Specification Version 2.2:
|
||||
// This version lifts the restriction on line length. In this version, the new
|
||||
// maximum length of a value of the type string is 65535 characters, and hence
|
||||
// lines may now be at least this long.
|
||||
|
||||
#define BDF_MAX_LINE_LENGTH 65535
|
||||
|
||||
/* Ranges of 7-bit and 8-bit fonts */
|
||||
|
||||
#define NXFONT_MIN7BIT 33
|
||||
#define NXFONT_MAX7BIT 126
|
||||
|
||||
#define NXFONT_MIN8BIT 161
|
||||
#define NXFONT_MAX8BIT 255
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure holds information about a glyph */
|
||||
|
||||
typedef struct glyphinfo_s
|
||||
{
|
||||
char *name; /* Name for they glyph */
|
||||
int encoding; /* The Adobe Standard Encoding value */
|
||||
int dw_x0; /* Width in x of the vector indicating
|
||||
* the position of the next glyph's origin
|
||||
* relative to the origin of this glyph */
|
||||
int dw_y0; /* Width in y of the vector indicating
|
||||
* the position of the next glyph's origin
|
||||
* relative to the origin of this glyph */
|
||||
int bb_w; /* The width of the black pixels in x */
|
||||
int bb_h; /* The height of the black pixels in y */
|
||||
int bb_x_off; /* X displacement of the lower left corner
|
||||
* of the bitmap from origin 0 */
|
||||
int bb_y_off; /* Y displacement of the lower left corner
|
||||
* of the bitmap from origin 0 */
|
||||
uint64_t *bitmap; /* Hexadecimal data for the character bitmap */
|
||||
} glyphinfo_t;
|
||||
|
||||
/* This structures provides the metrics for one glyph */
|
||||
|
||||
typedef struct nx_fontmetric_s
|
||||
{
|
||||
uint32_t stride : 3; /* Width of one font row in bytes */
|
||||
uint32_t width : 6; /* Width of the font in bits */
|
||||
uint32_t height : 6; /* Height of the font in rows */
|
||||
uint32_t xoffset : 6; /* Top, left-hand corner X-offset in pixels */
|
||||
uint32_t yoffset : 6; /* Top, left-hand corner y-offset in pixels */
|
||||
uint32_t unused : 5;
|
||||
} nx_fontmetric_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trimLine
|
||||
*
|
||||
* Description:
|
||||
* Trims the line removing space characters at the front and at the end
|
||||
* of the line.
|
||||
*
|
||||
* Input Parameters:
|
||||
* line - The line to trim
|
||||
*
|
||||
****************************************************************************/
|
||||
static void trimLine(char *line)
|
||||
{
|
||||
char *str;
|
||||
str = line;
|
||||
char *strEnd;
|
||||
for (strEnd = str + strlen(str) - 1;
|
||||
strEnd >= str && isspace((int)(*strEnd));
|
||||
strEnd--);
|
||||
*(strEnd + 1) = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_parseIntLine
|
||||
*
|
||||
* Description:
|
||||
* Parses a line containing a BDF property followed by integers. It will
|
||||
* ignore the first token that corresponds to the property name.
|
||||
*
|
||||
* Input Parameters:
|
||||
* line - A line with a BDF property followed by integers, i.e.:
|
||||
* "FONTBOUNDINGBOX 8 13 0 -2"
|
||||
* count - How many integers are specified by the BDF property. In the
|
||||
* example above, count = 4.
|
||||
* info - A pointer to memory provided by the caller in which to
|
||||
* return the array of integers. For the example above:
|
||||
* info[0] = 8
|
||||
* info[1] = 13
|
||||
* info[2] = 0
|
||||
* info[3] = -2
|
||||
*
|
||||
****************************************************************************/
|
||||
static void bdf_parseintline(char *line, unsigned int count, int *info)
|
||||
{
|
||||
char *str, *token, *saveptr1;
|
||||
str = line;
|
||||
|
||||
/* Ignore the key */
|
||||
|
||||
token = (char *)strtok_r(str, " ", &saveptr1);
|
||||
|
||||
while ((token = (char *)strtok_r(NULL, " ", &saveptr1)) && count--)
|
||||
{
|
||||
*(info++) = atoi(token);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_printglyphinfo
|
||||
*
|
||||
* Description:
|
||||
* Prints the information available for a glyph.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ginfo - A glyphinfo_t struct with the glyph's information.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef DBG
|
||||
static void bdf_printglyphinfo(const glyphinfo_t *ginfo)
|
||||
{
|
||||
printf("NAME = %s\n", ginfo->name);
|
||||
printf("ENCODING = %d\n", ginfo->encoding);
|
||||
printf("DW_X0 = %d\n", ginfo->dw_x0);
|
||||
printf("DW_Y0 = %d\n", ginfo->dw_y0);
|
||||
printf("BB_W = %d\n", ginfo->bb_w);
|
||||
printf("BB_H = %d\n", ginfo->bb_h);
|
||||
printf("BB_X_OFF = %d\n", ginfo->bb_x_off);
|
||||
printf("BB_Y_OFF = %d\n", ginfo->bb_y_off);
|
||||
int i;
|
||||
for (i = 0; i < ginfo->bb_h; i++)
|
||||
{
|
||||
printf("BITMAP[%d] = %x\n", i, ginfo->bitmap[i]);
|
||||
}
|
||||
}
|
||||
#endif /* DBG */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_printnxmetricinfo
|
||||
*
|
||||
* Description:
|
||||
* Prints the information available for a glyph's metric in the NX
|
||||
* graphics system.
|
||||
*
|
||||
* Input Parameters:
|
||||
* info - A nx_fontmetric_t struct with the glyph's information.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef DBG
|
||||
static void bdf_printnxmetricinfo(const nx_fontmetric_t *info)
|
||||
{
|
||||
printf("STRIDE = %d\n", info->stride);
|
||||
printf("WIDTH = %d\n", info->width);
|
||||
printf("HEIGHT = %d\n", info->height);
|
||||
printf("XOFFSET = %d\n", info->xoffset);
|
||||
printf("YOFFSET = %d\n", info->yoffset);
|
||||
}
|
||||
#endif /* DBG */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_getglyphinfo
|
||||
*
|
||||
* Description:
|
||||
* Obtains the information for an individual glyph. The BDF properties
|
||||
* taken into account are:
|
||||
* - ENCODING
|
||||
* - DWIDTH
|
||||
* - BBX
|
||||
* BDF properties ignored:
|
||||
* - SWIDTH
|
||||
* - SWIDTH1
|
||||
* - DWIDTH1
|
||||
* - VVECTOR
|
||||
*
|
||||
* Input Parameters:
|
||||
* file - The input file stream pointing to the first line of the
|
||||
* glyph's information (right after STARTCHAR).
|
||||
* ginfo - A glyphinfo_t struct to fill with the glyph's information.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
|
||||
{
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
char lineCopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str, *token, *saveptr1;
|
||||
bool done;
|
||||
|
||||
done = false;
|
||||
|
||||
while(fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL && !done)
|
||||
{
|
||||
trimLine(line);
|
||||
strcpy(lineCopy, line);
|
||||
str = line;
|
||||
|
||||
while ((token = (char *)strtok_r(str, " ", &saveptr1)))
|
||||
{
|
||||
|
||||
/* ENCODING information */
|
||||
|
||||
if(strcmp(token, "ENCODING") == 0)
|
||||
{
|
||||
token = (char *)strtok_r(NULL, " ", &saveptr1);
|
||||
ginfo->encoding = atoi(token);
|
||||
}
|
||||
|
||||
/* DWIDTH information */
|
||||
|
||||
if(strcmp(token, "DWIDTH") == 0)
|
||||
{
|
||||
token = (char *)strtok_r(NULL, " ", &saveptr1);
|
||||
ginfo->dw_x0 = atoi(token);
|
||||
token = (char *)strtok_r(NULL, " ", &saveptr1);
|
||||
ginfo->dw_y0 = atoi(token);
|
||||
}
|
||||
|
||||
/* BBX information */
|
||||
|
||||
else if(strcmp(token, "BBX") == 0)
|
||||
{
|
||||
int bbxinfo[4];
|
||||
bdf_parseintline(lineCopy, 4, bbxinfo);
|
||||
ginfo->bb_w = bbxinfo[0];
|
||||
ginfo->bb_h = bbxinfo[1];
|
||||
ginfo->bb_x_off = bbxinfo[2];
|
||||
ginfo->bb_y_off = bbxinfo[3];
|
||||
|
||||
/* This is the last BDF property of interest*/
|
||||
|
||||
done = true;
|
||||
}
|
||||
|
||||
str = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_getglyphbitmap
|
||||
*
|
||||
* Description:
|
||||
* Obtains the character bitmap information for an individual glyph.
|
||||
*
|
||||
* Input Parameters:
|
||||
* file - The input file stream pointing to the first line of the
|
||||
* glyph's bitmap (right after BITMAP).
|
||||
* ginfo - A glyphinfo_t struct to fill with the glyph's bitmap.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
|
||||
{
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
uint64_t *bitmap;
|
||||
bool readingbitmap;
|
||||
|
||||
bitmap = ginfo->bitmap;
|
||||
readingbitmap = true;
|
||||
|
||||
while (readingbitmap)
|
||||
{
|
||||
if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
|
||||
{
|
||||
trimLine(line);
|
||||
|
||||
if(strcmp(line, "ENDCHAR") == 0)
|
||||
{
|
||||
readingbitmap = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *endptr;
|
||||
*bitmap = strtoul(line, &endptr, 16);
|
||||
bitmap++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* error condition */
|
||||
|
||||
readingbitmap = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_getstride
|
||||
*
|
||||
* Description:
|
||||
* Obtains the stride for an individual glyph. The stride is the width
|
||||
* of one glyph's bitmap row in bytes.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ginfo - A glyphinfo_t struct with the glyph's information.
|
||||
* stride - A pointer to memory provided by the caller in which to
|
||||
* return the stride.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void bdf_getstride(glyphinfo_t *ginfo, uint32_t *stride)
|
||||
{
|
||||
*stride = (ginfo->bb_w % 8 == 0) ? ginfo->bb_w / 8 : ginfo->bb_w / 8 + 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bdf_printoutput
|
||||
*
|
||||
* Description:
|
||||
* Prints to the output stream the information of an individual glyph in
|
||||
* the NuttX font format.
|
||||
*
|
||||
* Input Parameters:
|
||||
* out - The output stream.
|
||||
* ginfo - A glyphinfo_t struct with the glyph's information.
|
||||
* nxmetric - A nx_fontmetric_t struct with the glyph's information.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void bdf_printoutput(FILE *out,
|
||||
glyphinfo_t *ginfo,
|
||||
nx_fontmetric_t *nxmetric)
|
||||
{
|
||||
|
||||
/* Only interested in the 7 and 8 bit ranges */
|
||||
|
||||
if ((ginfo->encoding >= NXFONT_MIN7BIT &&
|
||||
ginfo->encoding <= NXFONT_MAX7BIT) ||
|
||||
(ginfo->encoding >= NXFONT_MIN8BIT &&
|
||||
ginfo->encoding <= NXFONT_MAX8BIT))
|
||||
{
|
||||
|
||||
/* Glyph general info */
|
||||
|
||||
if (ginfo->bb_x_off < 0)
|
||||
{
|
||||
fprintf(out,
|
||||
"/* %s (%d) -- NOTE: Xoffset should be %d, not 0. */\n",
|
||||
ginfo->name,
|
||||
ginfo->encoding,
|
||||
ginfo->bb_x_off);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out, "/* %s (%d) */\n", ginfo->name, ginfo->encoding);
|
||||
}
|
||||
|
||||
/* Glyph metrics */
|
||||
|
||||
fprintf(out,
|
||||
"#define NXFONT_METRICS_%d {%d, %d, %d, %d, %d, 0}\n",
|
||||
ginfo->encoding,
|
||||
nxmetric->stride,
|
||||
nxmetric->width,
|
||||
nxmetric->height,
|
||||
nxmetric->xoffset,
|
||||
nxmetric->yoffset);
|
||||
|
||||
/* Glyph bitmap */
|
||||
|
||||
fprintf(out, "#define NXFONT_BITMAP_%d {", ginfo->encoding);
|
||||
int i, j;
|
||||
for (i = 0; i < ginfo->bb_h - 1; i++)
|
||||
{
|
||||
for (j = 1; j <= nxmetric->stride; j++)
|
||||
{
|
||||
int nxbyteoffset;
|
||||
uint8_t nxbyte = 0;
|
||||
uint64_t tempbitmap = ginfo->bitmap[i];
|
||||
|
||||
/* Get the next byte */
|
||||
|
||||
nxbyteoffset = (nxmetric->stride - j) * 8;
|
||||
nxbyte = (uint8_t)(tempbitmap >> nxbyteoffset);
|
||||
fprintf(out, "0x%x, ", nxbyte);
|
||||
}
|
||||
}
|
||||
|
||||
/* Different behavior for the last bitmap */
|
||||
|
||||
for (j = 1; j <= nxmetric->stride; j++)
|
||||
{
|
||||
int nxbyteoffset;
|
||||
uint8_t nxbyte = 0;
|
||||
uint64_t tempbitmap = ginfo->bitmap[i];
|
||||
|
||||
/* Get the next byte */
|
||||
|
||||
nxbyteoffset = (nxmetric->stride - j) * 8;
|
||||
nxbyte = (uint8_t)(tempbitmap >> nxbyteoffset);
|
||||
|
||||
if (j == nxmetric->stride)
|
||||
{
|
||||
fprintf(out, "0x%x}\n", nxbyte);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out, "0x%x, ", nxbyte);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *file, *out;
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
char lineCopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str, *token, *saveptr1;
|
||||
char *input, *output;
|
||||
|
||||
/* FONTBOUNDINGBOX properties*/
|
||||
|
||||
int fbb_x = 0;
|
||||
int fbb_y = 0;
|
||||
int fbb_x_off = 0;
|
||||
int fbb_y_off = 0;
|
||||
|
||||
/* Input BDF file */
|
||||
|
||||
input = argv[1];
|
||||
|
||||
if (input == NULL)
|
||||
{
|
||||
printf("%s: no input file\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
file = fopen(input, "r");
|
||||
|
||||
if (file == NULL)
|
||||
{
|
||||
printf("%s: error opening file %s\n", argv[0], input);
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
printf("Opening \"%s\"\n", input);
|
||||
#endif /* VERBOSE */
|
||||
}
|
||||
|
||||
/* Output file */
|
||||
if (argv[2])
|
||||
{
|
||||
output = argv[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
output = "nxfonts_myfont.h";
|
||||
}
|
||||
|
||||
out = fopen(output, "w");
|
||||
|
||||
if (out == NULL)
|
||||
{
|
||||
printf("%s: error opening file %s\n", argv[0], output);
|
||||
fclose(file);
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
|
||||
{
|
||||
|
||||
#ifdef DBG
|
||||
printf("--\n");
|
||||
#endif /* DBG */
|
||||
|
||||
// Save a copy of the line
|
||||
|
||||
strcpy(lineCopy,line);
|
||||
|
||||
// Clean it
|
||||
|
||||
trimLine(line);
|
||||
str = line;
|
||||
|
||||
while ((token = (char *)strtok_r(str, " ", &saveptr1)))
|
||||
{
|
||||
|
||||
/* FONTBOUNDINGBOX - Global font information */
|
||||
|
||||
if (strcmp(token, "FONTBOUNDINGBOX") == 0)
|
||||
{
|
||||
int fbbinfo[4];
|
||||
bdf_parseintline(lineCopy, 4, fbbinfo);
|
||||
fbb_x = fbbinfo[0];
|
||||
fbb_y = fbbinfo[1];
|
||||
fbb_x_off = fbbinfo[2];
|
||||
fbb_y_off = fbbinfo[3];
|
||||
|
||||
/* Print FONTBOUNDINGBOX information */
|
||||
|
||||
fprintf(out, "/* Maximum height and width of any");
|
||||
fprintf(out, " glyph in the set */\n\n");
|
||||
fprintf(out, "#define NXFONT_MAXHEIGHT %d\n", fbb_y);
|
||||
fprintf(out, "#define NXFONT_MAXWIDTH %d\n\n", fbb_x);
|
||||
}
|
||||
|
||||
/* STARTCHAR - Individual glyph information */
|
||||
|
||||
if (strcmp(token, "STARTCHAR") == 0)
|
||||
{
|
||||
glyphinfo_t ginfo;
|
||||
|
||||
/* Glyph name */
|
||||
|
||||
ginfo.name = (char *)strtok_r(NULL, " ", &saveptr1);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Processing glyph: %s\n", ginfo.name);
|
||||
#endif /* VERBOSE */
|
||||
|
||||
/* Glyph information:
|
||||
* ENCODING
|
||||
* DWIDTH
|
||||
* BBX
|
||||
*/
|
||||
ginfo.encoding = 0;
|
||||
ginfo.dw_x0 = 0;
|
||||
ginfo.dw_y0 = 0;
|
||||
ginfo.bb_w = 0;
|
||||
ginfo.bb_h = 0;
|
||||
ginfo.bb_x_off = 0;
|
||||
ginfo.bb_y_off = 0;
|
||||
bdf_getglyphinfo(file, &ginfo);
|
||||
|
||||
/* Glyph bitmap */
|
||||
|
||||
ginfo.bitmap = malloc(sizeof(uint64_t) * ginfo.bb_h);
|
||||
bdf_getglyphbitmap(file, &ginfo);
|
||||
|
||||
#ifdef DBG
|
||||
bdf_printglyphinfo(&ginfo);
|
||||
#endif /* DBG */
|
||||
|
||||
/* Convert to nxfonts */
|
||||
|
||||
nx_fontmetric_t nxmetric;
|
||||
uint32_t stride;
|
||||
bdf_getstride(&ginfo, &stride);
|
||||
nxmetric.stride = stride;
|
||||
nxmetric.width = ginfo.bb_w;
|
||||
nxmetric.height = ginfo.bb_h;
|
||||
|
||||
/* The NuttX font format does not support
|
||||
* negative X offsets. */
|
||||
|
||||
if (ginfo.bb_x_off < 0)
|
||||
{
|
||||
nxmetric.xoffset = 0;
|
||||
printf("%s: ignoring negative x offset for "
|
||||
"glyph '%s' (%d)\n",
|
||||
argv[0],
|
||||
ginfo.name,
|
||||
ginfo.encoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
nxmetric.xoffset = ginfo.bb_x_off;
|
||||
}
|
||||
|
||||
nxmetric.yoffset = fbb_y + fbb_y_off -
|
||||
ginfo.bb_y_off - ginfo.bb_h;
|
||||
|
||||
|
||||
#ifdef DBG
|
||||
bdf_printnxmetricinfo(&nxmetric);
|
||||
#endif /* DBG */
|
||||
|
||||
/* The space (32) character is treated differently */
|
||||
|
||||
if (ginfo.encoding == 32)
|
||||
{
|
||||
fprintf(out, "/* The width of a space */\n\n");
|
||||
fprintf(out, "#define NXFONT_SPACEWIDTH %d\n\n", ginfo.dw_x0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bdf_printoutput(out, &ginfo, &nxmetric);
|
||||
}
|
||||
|
||||
/* Free memory */
|
||||
|
||||
free(ginfo.bitmap);
|
||||
|
||||
}
|
||||
|
||||
str = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
fclose(file);
|
||||
fclose(out);
|
||||
|
||||
/* The End */
|
||||
|
||||
printf("Generated \"%s\"\n", output);
|
||||
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
* tools/cfgpaser.c
|
||||
*
|
||||
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "cfgparser.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
char line[LINESIZE+1];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static char *skip_space(char *ptr)
|
||||
{
|
||||
while (*ptr && isspace((int)*ptr)) ptr++;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static char *find_name_end(char *ptr)
|
||||
{
|
||||
while (*ptr && (isalnum((int)*ptr) || *ptr == '_')) ptr++;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static char *find_value_end(char *ptr)
|
||||
{
|
||||
while (*ptr && !isspace((int)*ptr))
|
||||
{
|
||||
if (*ptr == '"')
|
||||
{
|
||||
do ptr++; while (*ptr && *ptr != '"');
|
||||
if (*ptr) ptr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
do ptr++; while (*ptr && !isspace((int)*ptr) && *ptr != '"');
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static char *read_line(FILE *stream)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
line[LINESIZE] = '\0';
|
||||
if (!fgets(line, LINESIZE, stream))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = skip_space(line);
|
||||
if (*ptr && *ptr != '#' && *ptr != '\n')
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_line(char *ptr, char **varname, char **varval)
|
||||
{
|
||||
*varname = ptr;
|
||||
*varval = NULL;
|
||||
|
||||
ptr = find_name_end(ptr);
|
||||
if (*ptr && *ptr != '=')
|
||||
{
|
||||
*ptr = '\0';
|
||||
ptr = skip_space(ptr + 1);
|
||||
}
|
||||
|
||||
if (*ptr == '=')
|
||||
{
|
||||
*ptr = '\0';
|
||||
ptr = skip_space(ptr + 1);
|
||||
if (*ptr)
|
||||
{
|
||||
*varval = ptr;
|
||||
ptr = find_value_end(ptr);
|
||||
*ptr = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void parse_file(FILE *stream)
|
||||
{
|
||||
char *varname;
|
||||
char *varval;
|
||||
char *ptr;
|
||||
|
||||
do
|
||||
{
|
||||
ptr = read_line(stream);
|
||||
if (ptr)
|
||||
{
|
||||
parse_line(ptr, &varname, &varval);
|
||||
if (varname)
|
||||
{
|
||||
if (!varval || strcmp(varval, "n") == 0)
|
||||
{
|
||||
printf("#undef %s\n", varname);
|
||||
}
|
||||
else if (strcmp(varval, "y") == 0)
|
||||
{
|
||||
printf("#define %s 1\n", varname);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("#define %s %s\n", varname, varval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (ptr);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* tools/cfgpaser.h
|
||||
*
|
||||
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __TOOLS_CFGPARSER_H
|
||||
#define __TOOLS_CFGPARSER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LINESIZE ( PATH_MAX > 256 ? PATH_MAX : 256 )
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern char line[LINESIZE+1];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
extern void parse_file(FILE *stream);
|
||||
|
||||
#endif /* __TOOLS_CFGPARSER_H */
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
# configure.sh
|
||||
#
|
||||
# Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
WD=`pwd`
|
||||
TOPDIR="${WD}/.."
|
||||
USAGE="
|
||||
|
||||
USAGE: ${0} [-d] [-a <app-dir>] <board-name>/<config-name>
|
||||
|
||||
Where:
|
||||
<board-name> is the name of the board in the configs directory
|
||||
<config-name> is the name of the board configuration sub-directory
|
||||
<add-dir> is the path to the apps/ directory, relative to the nuttx directory
|
||||
|
||||
"
|
||||
|
||||
# Parse command arguments
|
||||
|
||||
unset boardconfig
|
||||
unset appdir
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case "$1" in
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-h )
|
||||
echo "$USAGE"
|
||||
exit 0
|
||||
;;
|
||||
-a )
|
||||
shift
|
||||
appdir=$1
|
||||
;;
|
||||
*)
|
||||
if [ ! -z "${boardconfig}" ]; then
|
||||
echo ""
|
||||
echo "<board/config> defined twice"
|
||||
echo "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
boardconfig=$1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Sanity checking
|
||||
|
||||
if [ -z "${boardconfig}" ]; then
|
||||
echo ""
|
||||
echo "Missing <board/config> argument"
|
||||
echo "$USAGE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
configpath=${TOPDIR}/configs/${boardconfig}
|
||||
if [ ! -d "${configpath}" ]; then
|
||||
echo "Directory ${configpath} does not exist. Options are:"
|
||||
echo ""
|
||||
echo "Select one of the following options for <board-name>:"
|
||||
configlist=`find ${TOPDIR}/configs -name defconfig`
|
||||
for defconfig in $configlist; do
|
||||
config=`dirname $defconfig | sed -e "s,${TOPDIR}/configs/,,g"`
|
||||
echo " $config"
|
||||
done
|
||||
echo ""
|
||||
echo "$USAGE"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [ ! -r "${configpath}/Make.defs" ]; then
|
||||
echo "File ${configpath}/Make.defs does not exist"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ ! -r "${configpath}/setenv.sh" ]; then
|
||||
echo "File ${configpath}/setenv.sh does not exist"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
if [ ! -r "${configpath}/defconfig" ]; then
|
||||
echo "File ${configpath}/defconfig does not exist"
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# Check for the apps/ dir in the usual place if appdir was not provided
|
||||
|
||||
if [ -z "${appdir}" ]; then
|
||||
|
||||
# Check for a version file
|
||||
|
||||
unset CONFIG_VERSION_STRING
|
||||
if [ -x "${TOPDIR}/.version" ]; then
|
||||
. "${TOPDIR}/.version"
|
||||
fi
|
||||
|
||||
# Check for an unversioned apps/ directory
|
||||
|
||||
if [ -d "${TOPDIR}/../apps" ]; then
|
||||
appdir="../apps"
|
||||
|
||||
else
|
||||
# Check for a versioned apps/ directory
|
||||
|
||||
if [ -d "${TOPDIR}/../apps-${CONFIG_VERSION_STRING}" ]; then
|
||||
appdir="../apps-${CONFIG_VERSION_STRING}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Okay... setup the configuration
|
||||
|
||||
cp -f "${configpath}/Make.defs" "${TOPDIR}/." || \
|
||||
{ echo "Failed to copy ${configpath}/Make.defs" ; exit 7 ; }
|
||||
cp -f "${configpath}/setenv.sh" "${TOPDIR}/." || \
|
||||
{ echo "Failed to copy ${configpath}/setenv.sh" ; exit 8 ; }
|
||||
chmod 755 "${TOPDIR}/setenv.sh"
|
||||
cp -f "${configpath}/defconfig" "${TOPDIR}/.config" || \
|
||||
{ echo "Failed to copy ${configpath}/defconfig" ; exit 9 ; }
|
||||
|
||||
# Copy option appconfig
|
||||
|
||||
if [ ! -z "${appdir}" ]; then
|
||||
if [ ! -r "${configpath}/appconfig" ]; then
|
||||
echo "NOTE: No readable appconfig file found in ${configpath}"
|
||||
else
|
||||
cp -f "${configpath}/appconfig" "${TOPDIR}/${appdir}/.config" || \
|
||||
{ echo "Failed to copy ${configpath}/appconfig" ; exit 10 ; }
|
||||
|
||||
echo "" >> "${TOPDIR}/.config"
|
||||
echo "# Application configuration" >> "${TOPDIR}/.config"
|
||||
echo "" >> "${TOPDIR}/.config"
|
||||
echo "CONFIG_APPS_DIR=\"$appdir\"" >> "${TOPDIR}/.config"
|
||||
fi
|
||||
fi
|
||||
|
||||
Executable
+224
@@ -0,0 +1,224 @@
|
||||
#!/bin/bash
|
||||
# tools/define.sh
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Handle command line options
|
||||
#
|
||||
|
||||
progname=$0
|
||||
wintool=n
|
||||
usage="USAGE: $progname [-w] [-d] [-l] [-h] <compiler-path> <def1>[=val1] [<def2>[=val2] [<def3>[=val3] ...]]"
|
||||
advice="Try '$progname -h' for more information"
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-w )
|
||||
wintool=y
|
||||
;;
|
||||
-h )
|
||||
echo "$progname is a tool for flexible generation of command line pre-processor"
|
||||
echo "definitions arguments for a variety of diffent compilers in a variety of"
|
||||
echo "compilation environments"
|
||||
echo ""
|
||||
echo $usage
|
||||
echo ""
|
||||
echo "Where:"
|
||||
echo " <compiler-path>"
|
||||
echo " The full path to your compiler"
|
||||
echo " <def1> <def2> [<def3> ..."
|
||||
echo " A list of pre-preprocesser variable names to be defind."
|
||||
echo " [=val1] [=val2] [=val3]"
|
||||
echo " optional values to be assigned to each pre-processor variable."
|
||||
echo " If not supplied, the variable will be defined with no explicit value."
|
||||
echo " -w"
|
||||
echo " The compiler is a Windows native tool and requires Windows"
|
||||
echo " style pathnames like C:\\Program Files"
|
||||
echo " -d"
|
||||
echo " Enable script debug"
|
||||
;;
|
||||
* )
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
ccpath=$1
|
||||
shift
|
||||
varlist=$@
|
||||
|
||||
if [ -z "$ccpath" ]; then
|
||||
echo "Missing compiler path"
|
||||
echo $usage
|
||||
echo $advice
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$varlist" ]; then
|
||||
echo "Missing definition list"
|
||||
echo $usage
|
||||
echo $advice
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Most compilers support CFLAG options like '-D<defn>' to add pre-processor
|
||||
# variable defintions. Some (like the Zilog tools), do not. This script
|
||||
# makes the selection of pre-processor definitions compiler independent.
|
||||
#
|
||||
# Below are all known compiler names (as found in the config/*/*/Make.defs
|
||||
# files). If a new compiler is used that has some unusual syntax, then
|
||||
# additional logic needs to be added to this file.
|
||||
#
|
||||
# NAME Syntax
|
||||
# $(CROSSDEV)gcc -D<def1> -D<def2> -D<def3> ...
|
||||
# sdcc -D<def2> -D<def2> -D<def3> ...
|
||||
# $(ZDSBINDIR)/ez8cc.exe -define:<def1> -define:<def2> -define:<def3> ...
|
||||
# $(ZDSBINDIR)/zneocc.exe -define:<def1> -define:<def2> -define:<def3> ...
|
||||
# $(ZDSBINDIR)/ez80cc.exe -define:<def1> -define:<def2> -define:<def3> ...
|
||||
#
|
||||
os=`uname -o 2>/dev/null || echo "Other"`
|
||||
|
||||
#
|
||||
# Let's assume that all GCC compiler paths contain the string gcc and
|
||||
# no non-GCC compiler pathes include this substring
|
||||
#
|
||||
gcc=`echo $ccpath | grep gcc`
|
||||
sdcc=`echo $ccpath | grep sdcc`
|
||||
|
||||
if [ "X$os" = "XCygwin" ]; then
|
||||
#
|
||||
# We can treat Cygwin native toolchains just like Linux native
|
||||
# toolchains in the Linux. Let's assume:
|
||||
# 1. GCC or SDCC are the only possible Cygwin native compilers
|
||||
# 2. If this is a Window native GCC version, then -w provided
|
||||
# on the command line (wintool=y)
|
||||
|
||||
if [ -z "$gcc" -a -z "$sdcc" ]; then
|
||||
#
|
||||
# Not GCC or SDCC, must be Windows native
|
||||
#
|
||||
compiler=`cygpath -u "$ccpath"`
|
||||
else
|
||||
if [ "X$wintool" == "Xy" ]; then
|
||||
#
|
||||
# It is a native GCC or SDCC compiler
|
||||
#
|
||||
compiler=`cygpath -u "$ccpath"`
|
||||
else
|
||||
#
|
||||
# GCC or SDCC and not for Windows
|
||||
#
|
||||
compiler="$ccpath"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
#
|
||||
# Otherwise, we must be in a Linux environment where there are
|
||||
# only Linux native toolchains
|
||||
#
|
||||
compiler="$ccpath"
|
||||
fi
|
||||
exefile=`basename "$compiler"`
|
||||
|
||||
# Check for some well known, non-GCC Windows native tools that require
|
||||
# a special output format as well as special paths
|
||||
|
||||
if [ "X$exefile" = "Xez8cc.exe" -o "X$exefile" = "Xzneocc.exe" -o "X$exefile" = "Xez80cc.exe" ]; then
|
||||
fmt=define
|
||||
else
|
||||
fmt=std
|
||||
fi
|
||||
|
||||
# Now process each directory in the directory list
|
||||
|
||||
unset response
|
||||
for vardef in $varlist; do
|
||||
|
||||
varname=`echo $vardef | cut -d'=' -f1`
|
||||
varvalue=`echo $vardef | cut -d'=' -f2`
|
||||
|
||||
# Handle the output depending on if there is a value for the variable or not
|
||||
|
||||
if [ -z "$varvalue" ]; then
|
||||
|
||||
# Handle the output using the selected format
|
||||
|
||||
if [ "X$fmt" = "Xdefine" ]; then
|
||||
# Treat the first definition differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response="-define:"$varname
|
||||
else
|
||||
response=$response" -define:$varname"
|
||||
fi
|
||||
else
|
||||
# Treat the first definition differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response=-D$varname
|
||||
else
|
||||
response=$response" -D$varname"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
||||
# Handle the output using the selected format
|
||||
|
||||
if [ "X$fmt" = "Xdefine" ]; then
|
||||
# Treat the first definition differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response="-define:"$varname=$varvalue
|
||||
else
|
||||
response=$response" -define:$varname=$varvalue"
|
||||
fi
|
||||
else
|
||||
# Treat the first definition differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response=-D$varname=$varvalue
|
||||
else
|
||||
response=$response" -D$varname=$varvalue"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo $response
|
||||
|
||||
|
||||
Executable
+211
@@ -0,0 +1,211 @@
|
||||
#!/bin/bash
|
||||
# tools/incdir.sh
|
||||
#
|
||||
# Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Handle command line options
|
||||
|
||||
progname=$0
|
||||
wintool=n
|
||||
usage="USAGE: $progname [-w] [-d] [-h] <compiler-path> <dir1> [<dir2> [<dir3> ...]]"
|
||||
advice="Try '$progname -h' for more information"
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-w )
|
||||
wintool=y
|
||||
;;
|
||||
-h )
|
||||
echo "$progname is a tool for flexible generation of include path arguments for a"
|
||||
echo "variety of different compilers in a variety of compilation environments"
|
||||
echo ""
|
||||
echo $usage
|
||||
echo ""
|
||||
echo "Where:"
|
||||
echo " <compiler-path>"
|
||||
echo " The full path to your compiler"
|
||||
echo " <dir1> [<dir2> [<dir3> ...]]"
|
||||
echo " A list of include directories"
|
||||
echo " -w"
|
||||
echo " The compiler is a Windows native tool and requires Windows"
|
||||
echo " style pathnames like C:\\Program Files"
|
||||
echo " -d"
|
||||
echo " Enable script debug"
|
||||
;;
|
||||
* )
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
ccpath=$1
|
||||
shift
|
||||
dirlist=$@
|
||||
|
||||
if [ -z "$ccpath" ]; then
|
||||
echo "Missing compiler path"
|
||||
echo $usage
|
||||
echo $advice
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$dirlist" ]; then
|
||||
echo "Missing include directory list"
|
||||
echo $usage
|
||||
echo $advice
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Most compilers support CFLAG options like '-I<dir>' to add include
|
||||
# file header paths. Some (like the Zilog tools), do not. This script
|
||||
# makes the selection of header file paths compiler independent.
|
||||
#
|
||||
# Below are all known compiler names (as found in the config/*/*/Make.defs
|
||||
# files). If a new compiler is used that has some unusual syntax, then
|
||||
# additional logic needs to be added to this file.
|
||||
#
|
||||
# NAME Syntax
|
||||
# $(CROSSDEV)gcc -I<dir1> -I<dir2> -I<dir3> ...
|
||||
# sdcc -I<dir2> -I<dir2> -I<dir3> ...
|
||||
# $(ZDSBINDIR)/ez8cc.exe -usrinc:'<dir1>:<dir2>:<dir3>:...`
|
||||
# $(ZDSBINDIR)/zneocc.exe -usrinc:'<dir1>:<dir2>:<dir3>:...`
|
||||
# $(ZDSBINDIR)/ez80cc.exe -usrinc:'<dir1>:<dir2>:<dir3>:...`
|
||||
#
|
||||
# Furthermore, just to make matters more difficult, with Windows based
|
||||
# toolchains, we have to use the full windows-style paths to the header
|
||||
# files.
|
||||
|
||||
os=`uname -o 2>/dev/null || echo "Other"`
|
||||
|
||||
# Let's assume that all GCC compiler paths contain the string gcc or
|
||||
# g++ and no non-GCC compiler pathes include these substrings
|
||||
|
||||
gcc=`echo $ccpath | grep gcc`
|
||||
if [ -z "${gcc}" ]; then
|
||||
gcc=`echo $ccpath | grep g++`
|
||||
fi
|
||||
|
||||
sdcc=`echo $ccpath | grep sdcc`
|
||||
|
||||
if [ "X$os" = "XCygwin" ]; then
|
||||
# We can treat Cygwin native toolchains just like Linux native
|
||||
# toolchains in the Linux. Let's assume:
|
||||
# 1. GCC or SDCC are the only possible Cygwin native compilers
|
||||
# 2. If this is a Window native GCC version, then -w must be
|
||||
# provided on the command line (wintool=y)
|
||||
|
||||
if [ -z "$gcc" -a -z "$sdcc" ]; then
|
||||
# Not GCC or SDCC, must be Windows native
|
||||
windows=yes
|
||||
compiler=`cygpath -u "$ccpath"`
|
||||
else
|
||||
if [ "X$wintool" == "Xy" ]; then
|
||||
# It is a native GCC or SDCC compiler
|
||||
windows=yes
|
||||
compiler=`cygpath -u "$ccpath"`
|
||||
else
|
||||
# GCC or SDCC and not for Windows
|
||||
windows=no
|
||||
compiler="$ccpath"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Otherwise, we must be in a Linux environment where there are
|
||||
# only Linux native toolchains
|
||||
windows=no
|
||||
compiler="$ccpath"
|
||||
fi
|
||||
exefile=`basename "$compiler"`
|
||||
|
||||
# Check for some well known, non-GCC Windows native tools that require
|
||||
# a special output format as well as special paths
|
||||
|
||||
if [ "X$exefile" = "Xez8cc.exe" -o "X$exefile" = "Xzneocc.exe" -o "X$exefile" = "Xez80cc.exe" ]; then
|
||||
fmt=userinc
|
||||
else
|
||||
fmt=std
|
||||
fi
|
||||
|
||||
# Now process each directory in the directory list
|
||||
|
||||
unset response
|
||||
for dir in $dirlist; do
|
||||
|
||||
# Verify that the include directory exists
|
||||
|
||||
if [ ! -d $dir ]; then
|
||||
echo "Include path '$dir' does not exist"
|
||||
echo $showusage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the path needs to be extended for Windows-based tools under Cygwin
|
||||
|
||||
if [ "X$windows" = "Xyes" ]; then
|
||||
path=`cygpath -w $dir`
|
||||
else
|
||||
path=$dir
|
||||
fi
|
||||
|
||||
# Handle the output using the selected format
|
||||
|
||||
if [ "X$fmt" = "Xuserinc" ]; then
|
||||
# Treat the first directory differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response="-usrinc:'"$path
|
||||
else
|
||||
response=$response":$path"
|
||||
fi
|
||||
else
|
||||
# Treat the first directory differently
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
response=-I\"$path\"
|
||||
else
|
||||
response=$response" -I\"$path\""
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "X$fmt" = "Xuserinc" ]; then
|
||||
response=$response"'"
|
||||
fi
|
||||
|
||||
echo $response
|
||||
|
||||
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/sh
|
||||
############################################################################
|
||||
# tools/indent.sh
|
||||
#
|
||||
# Copyright (C) 2008, 2010 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# This script uses the Linux 'indent' utility to re-format C source files
|
||||
# to match the coding style that I use. It differs from my coding style in that
|
||||
#
|
||||
# - I normally put the trailing */ of a multi-line comment on a separate line,
|
||||
# - I usually align things vertically (like '=' in assignments),
|
||||
# - indent puts a bogus blank line at the top of the file,
|
||||
# - I don't like the way it handles nested conditional compilation intermixed with code.
|
||||
#
|
||||
|
||||
# Constants
|
||||
|
||||
options="-nbad -bap -bbb -nbbo -nbc -bl -bl2 -bls -nbs -cbi2 -ncdw -nce -ci2 -cli0 -cp40 -ncs -nbfda -nbfde -di1 -nfc1 -fca -i2 -l80 -lp -ppi2 -lps -npcs -pmt -nprs -npsl -saf -sai -sbi2 -saw -sc -sob -nss -nut"
|
||||
|
||||
usage="USAGE: $0 <in-file> <out-file>"
|
||||
|
||||
# Inputs
|
||||
|
||||
infile=$1
|
||||
outfile=$2
|
||||
|
||||
# Verify inputs
|
||||
|
||||
if [ -z "$infile" ]; then
|
||||
echo "Missing <in-file>"
|
||||
echo $usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -r $infile ]; then
|
||||
echo "Readable $infile does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$outfile" ]; then
|
||||
echo "Missing <out-file>"
|
||||
echo $usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f $outfile ]; then
|
||||
echo "Removing old $outfile"
|
||||
rm $outfile || { echo "Failed to remove $outfile" ; exit 1 ; }
|
||||
fi
|
||||
|
||||
# Perform the indentation
|
||||
|
||||
indent $options $infile -o $outfile
|
||||
|
||||
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/link.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
#set -x
|
||||
|
||||
src=$1
|
||||
dest=$2
|
||||
|
||||
# Verify that arguments were provided
|
||||
|
||||
if [ -z "${src}" -o -z "${dest}" ]; then
|
||||
echo "Missing src and/or dest arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if something already exists at the destination path replace it with
|
||||
# the new link (which might be different). Note that we check for the
|
||||
# the link (-h) before we check for existence (-e) because a bad link will
|
||||
# report that it does not exist.
|
||||
|
||||
if [ -h "${dest}" ]; then
|
||||
rm -f "${dest}"
|
||||
else
|
||||
|
||||
# If the path exists and is a directory that contains the "fake link"
|
||||
# mark, then treat it like a soft link (i.e., remove the directory)
|
||||
|
||||
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
||||
rm -rf "${dest}"
|
||||
else
|
||||
|
||||
# Does anything exist at the destination path?
|
||||
|
||||
if [ -e "${dest}" ]; then
|
||||
|
||||
# It is something else (like a file) or directory that does
|
||||
# not contain the "fake link" mark
|
||||
|
||||
echo "${dest} already exists but is not a symbolic link"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify that a directory exists at the source path
|
||||
|
||||
if [ ! -d "${src}" ]; then
|
||||
echo "No directory at ${src}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create the soft link
|
||||
|
||||
ln -s "${src}" "${dest}" || \
|
||||
{ echo "Failed to create link: $dest" ; exit 1 ; }
|
||||
@@ -0,0 +1,250 @@
|
||||
/****************************************************************************
|
||||
* tools/mkconfig.c
|
||||
*
|
||||
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "cfgparser.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define DEFCONFIG ".config"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline char *getfilepath(const char *name)
|
||||
{
|
||||
snprintf(line, PATH_MAX, "%s/" DEFCONFIG, name);
|
||||
line[PATH_MAX] = '\0';
|
||||
return strdup(line);
|
||||
}
|
||||
|
||||
static void show_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s <abs path to .config>\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
char *filepath;
|
||||
FILE *stream;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Unexpected number of arguments\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
filepath = getfilepath(argv[1]);
|
||||
if (!filepath)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
stream= fopen(filepath, "r");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
printf("/* config.h -- Autogenerated! Do not edit. */\n\n");
|
||||
printf("#ifndef __INCLUDE_NUTTX_CONFIG_H\n");
|
||||
printf("#define __INCLUDE_NUTTX_CONFIG_H\n\n");
|
||||
printf("/* Architecture-specific options *************************/\n\n");
|
||||
parse_file(stream);
|
||||
printf("\n/* Sanity Checks *****************************************/\n\n");
|
||||
printf("/* If this is an NXFLAT, external build, then make sure that\n");
|
||||
printf(" * NXFLAT support is enabled in the base code.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if defined(__NXFLAT__) && !defined(CONFIG_NXFLAT)\n");
|
||||
printf("# error \"NXFLAT support not enabled in this configuration\"\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* NXFLAT requires PIC support in the TCBs. */\n\n");
|
||||
printf("#if defined(CONFIG_NXFLAT)\n");
|
||||
printf("# undef CONFIG_PIC\n");
|
||||
printf("# define CONFIG_PIC 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Binary format support is disabled if no binary formats are\n");
|
||||
printf(" * configured (at present, NXFLAT is the only supported binary.\n");
|
||||
printf(" * format).\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if !defined(CONFIG_NXFLAT)\n");
|
||||
printf("# undef CONFIG_BINFMT_DISABLE\n");
|
||||
printf("# define CONFIG_BINFMT_DISABLE 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* The correct way to disable RR scheduling is to set the\n");
|
||||
printf(" * timeslice to zero.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#ifndef CONFIG_RR_INTERVAL\n");
|
||||
printf("# define CONFIG_RR_INTERVAL 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* The correct way to disable filesystem supuport is to set the\n");
|
||||
printf(" * number of file descriptors to zero.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#ifndef CONFIG_NFILE_DESCRIPTORS\n");
|
||||
printf("# define CONFIG_NFILE_DESCRIPTORS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If a console is selected, then make sure that there are\n");
|
||||
printf(" * resources for 3 file descriptors and, if any streams are\n");
|
||||
printf(" * selected, also for 3 file streams.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#ifdef CONFIG_DEV_CONSOLE\n");
|
||||
printf("# if CONFIG_NFILE_DESCRIPTORS < 3\n");
|
||||
printf("# undef CONFIG_NFILE_DESCRIPTORS\n");
|
||||
printf("# define CONFIG_NFILE_DESCRIPTORS 3\n");
|
||||
printf("# endif\n\n");
|
||||
printf("# if CONFIG_NFILE_STREAMS > 0 && CONFIG_NFILE_STREAMS < 3\n");
|
||||
printf("# undef CONFIG_NFILE_STREAMS\n");
|
||||
printf("# define CONFIG_NFILE_STREAMS 3\n");
|
||||
printf("# endif\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If priority inheritance is disabled, then do not allocate any\n");
|
||||
printf(" * associated resources.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if !defined(CONFIG_PRIORITY_INHERITANCE) || !defined(CONFIG_SEM_PREALLOCHOLDERS)\n");
|
||||
printf("# undef CONFIG_SEM_PREALLOCHOLDERS\n");
|
||||
printf("# define CONFIG_SEM_PREALLOCHOLDERS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("#if !defined(CONFIG_PRIORITY_INHERITANCE) || !defined(CONFIG_SEM_NNESTPRIO)\n");
|
||||
printf("# undef CONFIG_SEM_NNESTPRIO\n");
|
||||
printf("# define CONFIG_SEM_NNESTPRIO 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If no file descriptors are configured, then make certain no\n");
|
||||
printf(" * streams are configured either.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if CONFIG_NFILE_DESCRIPTORS == 0\n");
|
||||
printf("# undef CONFIG_NFILE_STREAMS\n");
|
||||
printf("# define CONFIG_NFILE_STREAMS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* There must be at least one memory region. */\n\n");
|
||||
printf("#ifndef CONFIG_MM_REGIONS\n");
|
||||
printf("# define CONFIG_MM_REGIONS 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If no file streams are configured, then make certain that buffered I/O\n");
|
||||
printf(" * support is disabled\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if CONFIG_NFILE_STREAMS == 0\n");
|
||||
printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
|
||||
printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* We are building a kernel version of the C library, then some user-space features\n");
|
||||
printf(" * need to be disabled\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)\n");
|
||||
printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
|
||||
printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
|
||||
printf("# undef CONFIG_NUNGET_CHARS\n");
|
||||
printf("# define CONFIG_NUNGET_CHARS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If no standard C buffered I/O is not supported, then line-oriented buffering\n");
|
||||
printf(" * cannot be supported.\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if CONFIG_STDIO_BUFFER_SIZE == 0\n");
|
||||
printf("# undef CONFIG_STDIO_LINEBUFFER\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If the maximum message size is zero, then we assume that message queues\n");
|
||||
printf(" * support should be disabled\n");
|
||||
printf(" */\n\n");
|
||||
printf("#if CONFIG_MQ_MAXMSGSIZE <= 0 && !defined(CONFIG_DISABLE_MQUEUE)\n");
|
||||
printf("# define CONFIG_DISABLE_MQUEUE 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* If mountpoint support in not included, then no filesystem can be supported */\n\n");
|
||||
printf("#ifdef CONFIG_DISABLE_MOUNTPOINT\n");
|
||||
printf("# undef CONFIG_FS_FAT\n");
|
||||
printf("# undef CONFIG_FS_ROMFS\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Check if any readable and writable filesystem (OR USB storage) is supported */\n\n");
|
||||
printf("#undef CONFIG_FS_READABLE\n");
|
||||
printf("#undef CONFIG_FS_WRITABLE\n");
|
||||
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_FS_ROMFS) || defined(CONFIG_USBSTRG) || \\\n");
|
||||
printf(" defined(CONFIG_FS_NXFFS) || defined(CONFIG_APPS_BINDIR)\n");
|
||||
printf("# define CONFIG_FS_READABLE 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_USBSTRG) || defined(CONFIG_FS_NXFFS)\n");
|
||||
printf("# define CONFIG_FS_WRITABLE 1\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* There can be no network support with no socket descriptors */\n\n");
|
||||
printf("#if CONFIG_NSOCKET_DESCRIPTORS <= 0\n");
|
||||
printf("# undef CONFIG_NET\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Conversely, if there is no network support, there is no need for\n");
|
||||
printf(" * socket descriptors\n");
|
||||
printf(" */\n\n");
|
||||
printf("#ifndef CONFIG_NET\n");
|
||||
printf("# undef CONFIG_NSOCKET_DESCRIPTORS\n");
|
||||
printf("# define CONFIG_NSOCKET_DESCRIPTORS 0\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Protocol support can only be provided on top of basic network support */\n\n");
|
||||
printf("#ifndef CONFIG_NET\n");
|
||||
printf("# undef CONFIG_NET_TCP\n");
|
||||
printf("# undef CONFIG_NET_UDP\n");
|
||||
printf("# undef CONFIG_NET_ICMP\n");
|
||||
printf("#endif\n\n");
|
||||
printf("/* Verbose debug and sub-system debug only make sense if debug is enabled */\n\n");
|
||||
printf("#ifndef CONFIG_DEBUG\n");
|
||||
printf("# undef CONFIG_DEBUG_VERBOSE\n");
|
||||
printf("# undef CONFIG_DEBUG_SCHED\n");
|
||||
printf("# undef CONFIG_DEBUG_MM\n");
|
||||
printf("# undef CONFIG_DEBUG_PAGING\n");
|
||||
printf("# undef CONFIG_DEBUG_DMA\n");
|
||||
printf("# undef CONFIG_DEBUG_FS\n");
|
||||
printf("# undef CONFIG_DEBUG_LIB\n");
|
||||
printf("# undef CONFIG_DEBUG_BINFMT\n");
|
||||
printf("# undef CONFIG_DEBUG_NET\n");
|
||||
printf("# undef CONFIG_DEBUG_USB\n");
|
||||
printf("# undef CONFIG_DEBUG_GRAPHICS\n");
|
||||
printf("# undef CONFIG_DEBUG_GPIO\n");
|
||||
printf("# undef CONFIG_DEBUG_STACK\n");
|
||||
printf("#endif\n\n");
|
||||
printf("#endif /* __INCLUDE_NUTTX_CONFIG_H */\n");
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
Executable
+196
@@ -0,0 +1,196 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/mkdeps.sh
|
||||
#
|
||||
# Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
#
|
||||
# Usage:
|
||||
|
||||
show_usage ()
|
||||
{
|
||||
echo ""
|
||||
echo "$progname [OPTIONS] CC -- CFLAGS -- file [file [file...]]"
|
||||
echo ""
|
||||
echo "Where:"
|
||||
echo " CC"
|
||||
echo " A variable number of arguments that define how to execute the compiler"
|
||||
echo " CFLAGS"
|
||||
echo " The compiler compilation flags"
|
||||
echo " file"
|
||||
echo " One or more C files whose dependencies will be checked. Each file is expected"
|
||||
echo " to reside in the current directory unless --dep-path is provided on the command line"
|
||||
echo ""
|
||||
echo "And [OPTIONS] include:"
|
||||
echo " --dep-debug"
|
||||
echo " Enable script debug"
|
||||
echo " --dep-path <path>"
|
||||
echo " Do not look in the current directory for the file. Instead, look in <path> to see"
|
||||
echo " if the file resides there. --dep-path may be used multiple times to specify"
|
||||
echo " multiple alternative location"
|
||||
echo " --winpaths <TOPDIR>"
|
||||
echo " CC generates dependency lists using Windows paths (e.g., C:\blablah\blabla). This"
|
||||
echo " switch instructs the script to use 'cygpath' to convert the Windows paths to Cygwin"
|
||||
echo " paths"
|
||||
echo " --help"
|
||||
echo " Shows this message and exits"
|
||||
exit 1
|
||||
}
|
||||
|
||||
dodep ()
|
||||
{
|
||||
unset fullpath
|
||||
if [ -z "$altpath" ]; then
|
||||
if [ -r $1 ]; then
|
||||
fullpath=$1
|
||||
else
|
||||
echo "# ERROR: No readable file at $1"
|
||||
show_usage
|
||||
fi
|
||||
else
|
||||
for path in $altpath; do
|
||||
tmppath=$path/$1
|
||||
if [ -r $tmppath ]; then
|
||||
fullpath=$tmppath
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ -z "$fullpath" ]; then
|
||||
echo "# ERROR: No readable file for $1 found at any location"
|
||||
show_usage
|
||||
fi
|
||||
fi
|
||||
|
||||
$cc -M $cflags $fullpath || \
|
||||
( echo "# ERROR: $cc -M $cflags $fullpath FAILED"; exit 4; )
|
||||
}
|
||||
|
||||
unset cc
|
||||
unset cflags
|
||||
unset files
|
||||
unset args
|
||||
unset altpath
|
||||
winpaths=n
|
||||
unset topdir
|
||||
|
||||
# Accumulate CFLAGS up to "--"
|
||||
progname=$0
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-- )
|
||||
cc=$cflags
|
||||
cflags=$args
|
||||
args=
|
||||
;;
|
||||
--dep-debug )
|
||||
if [ -z "$args" ]; then
|
||||
set -x
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--dep-path )
|
||||
if [ -z "$args" ]; then
|
||||
shift
|
||||
altpath="$altpath $1"
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--winpaths )
|
||||
if [ -z "$args" ]; then
|
||||
shift
|
||||
winpaths=y
|
||||
topdir=$1
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--help )
|
||||
show_usage
|
||||
;;
|
||||
*)
|
||||
args="$args $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
files=$args
|
||||
|
||||
if [ -z "$cc" ]; then
|
||||
echo "ERROR: No compiler specified"
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$files" ]; then
|
||||
# Don't report an error -- this happens normally in some configurations
|
||||
echo "# No files specified for dependency generataion"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if this compiler generates Cygwin/Linux paths or Windows paths
|
||||
|
||||
if [ "X${winpaths}" = "Xy" ]; then
|
||||
# We will have to parse and modify each dependency (yech)
|
||||
# Make sure a valid TOPDIR argument was provided
|
||||
|
||||
if [ -z "$topdir" -o ! -d $topdir ]; then
|
||||
echo "<TOPDIR> not specified or does not exist: $topdir"
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the top dir expressed like the Windows GCC would use it, except
|
||||
# with forward slashs
|
||||
|
||||
wtopdir=`cygpath -w ${topdir} | sed -e "s,\\\\\\,/,g"`
|
||||
|
||||
# Then get the dependency and perform conversions on it to make it
|
||||
# palatable to the Cygwin make. This is probably not sufficiently
|
||||
# general to work on all platforms (like if your disk is not C:).
|
||||
|
||||
for file in $files ; do
|
||||
dodep $file | sed -e "s,\\\,/,g" -e "s,${wtopdir},${topdir},g" \
|
||||
-e "s,/ ,\\\ ,g" -e "s,c:/,/cygdrive/c/,g" \
|
||||
-e "s,/$,\\\,g"
|
||||
done
|
||||
else
|
||||
# For normal Cygwin/Linux GCC, the dependency paths are in the
|
||||
# correct form and can simply be echoed on stdout
|
||||
|
||||
for file in $files ; do
|
||||
dodep $file
|
||||
done
|
||||
fi
|
||||
|
||||
Executable
+309
@@ -0,0 +1,309 @@
|
||||
#!/bin/bash
|
||||
# tools/mkexport.sh
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# TODO:
|
||||
# 1. This script assumes the host archiver ar may not be appropriate for
|
||||
# non-GCC toolchains
|
||||
# 2. For the kernel build, the user libriars should be built into some
|
||||
# libuser.a. The list of user libraries would have to accepted with
|
||||
# some new argument, perhaps -u.
|
||||
|
||||
# Get the input parameter list
|
||||
|
||||
USAGE="USAGE: $0 [-d] [-z] -t <top-dir> [-x <lib-ext>] -l \"lib1 [lib2 [lib3 ...]]\""
|
||||
unset TOPDIR
|
||||
unset LIBLIST
|
||||
unset TGZ
|
||||
LIBEXT=.a
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-l )
|
||||
shift
|
||||
LIBLIST=$1
|
||||
;;
|
||||
-t )
|
||||
shift
|
||||
TOPDIR=$1
|
||||
;;
|
||||
-x )
|
||||
shift
|
||||
LIBEXT=$1
|
||||
;;
|
||||
-z )
|
||||
TGZ=y
|
||||
;;
|
||||
-h )
|
||||
echo $USAGE
|
||||
exit 0
|
||||
;;
|
||||
* )
|
||||
echo "Unrecognized argument: $1"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Check arguments
|
||||
|
||||
if [ -z "${TOPDIR}" -o -z "${LIBLIST}" ]; then
|
||||
echo "MK: Missing required arguments"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${TOPDIR}" ]; then
|
||||
echo "MK: Directory ${TOPDIR} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the version string
|
||||
|
||||
if [ ! -f "${TOPDIR}/.version" ]; then
|
||||
echo "MK: File ${TOPDIR}/.version does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "${TOPDIR}/.version"
|
||||
if [ ! -z "${CONFIG_VERSION_STRING}" -a "${CONFIG_VERSION_STRING}" != "0.0" ]; then
|
||||
VERSION="-${CONFIG_VERSION_STRING}"
|
||||
fi
|
||||
|
||||
# Create the export directory
|
||||
|
||||
EXPORTSUBDIR="nuttx-export${VERSION}"
|
||||
EXPORTDIR="${TOPDIR}/${EXPORTSUBDIR}"
|
||||
|
||||
# If the export directory already exists, then remove it and create a new one
|
||||
|
||||
if [ -d "${EXPORTDIR}" ]; then
|
||||
echo "MK: Removing old export directory"
|
||||
rm -rf "${EXPORTDIR}"
|
||||
fi
|
||||
|
||||
# Remove any possible previous results
|
||||
|
||||
rm -f "${EXPORTDIR}.tar"
|
||||
rm -f "${EXPORTDIR}.zip"
|
||||
rm -f "${EXPORTDIR}.tar.gz"
|
||||
|
||||
# Create the export directory and some of its subdirectories
|
||||
|
||||
mkdir "${EXPORTDIR}" || { echo "MK: 'mkdir ${EXPORTDIR}' failed"; exit 1; }
|
||||
mkdir "${EXPORTDIR}/startup" || { echo "MK: 'mkdir ${EXPORTDIR}/startup' failed"; exit 1; }
|
||||
mkdir "${EXPORTDIR}/libs" || { echo "MK: 'mkdir ${EXPORTDIR}/libs' failed"; exit 1; }
|
||||
mkdir "${EXPORTDIR}/build" || { echo "MK: 'mkdir ${EXPORTDIR}/build' failed"; exit 1; }
|
||||
mkdir "${EXPORTDIR}/arch" || { echo "MK: 'mkdir ${EXPORTDIR}/arch' failed"; exit 1; }
|
||||
|
||||
# Verify that we have a Make.defs file.
|
||||
|
||||
if [ ! -f "${TOPDIR}/Make.defs" ]; then
|
||||
echo "MK: Directory ${TOPDIR}/Make.defs does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the Make.defs files, but disable windows path conversions
|
||||
|
||||
grep -v "WINTOOL[ \t]*=[ \t]y" "${TOPDIR}/Make.defs" > "${EXPORTDIR}/Make.defs"
|
||||
|
||||
# Extract information from the Make.defs file. A Makefile can do this best
|
||||
|
||||
make -C "${TOPDIR}/tools" -f Makefile.export TOPDIR="${TOPDIR}" EXPORTDIR="${EXPORTDIR}"
|
||||
source "${EXPORTDIR}/makeinfo.sh"
|
||||
rm -f "${EXPORTDIR}/makeinfo.sh"
|
||||
rm -f "${EXPORTDIR}/Make.defs"
|
||||
|
||||
# Verify the build info that we got from makeinfo.sh
|
||||
|
||||
if [ ! -d "${ARCHDIR}" ]; then
|
||||
echo "MK: Directory ${ARCHDIR} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Is there a linker script in this configuration?
|
||||
|
||||
if [ ! -z "${LDPATH}" ]; then
|
||||
|
||||
# Apparently so. Verify that the script exists
|
||||
|
||||
if [ ! -f "${LDPATH}" ]; then
|
||||
echo "MK: File ${LDPATH} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the linker script
|
||||
|
||||
cp --preserve=all "${LDPATH}" "${EXPORTDIR}/build/." || \
|
||||
{ echo "MK: cp ${LDPATH} failed"; exit 1; }
|
||||
fi
|
||||
|
||||
# Save the compilation options
|
||||
|
||||
echo "ARCHCFLAGS = ${ARCHCFLAGS}" >"${EXPORTDIR}/build/Make.defs"
|
||||
echo "ARCHCXXFLAGS = ${ARCHCXXFLAGS}" >>"${EXPORTDIR}/build/Make.defs"
|
||||
|
||||
# Copy the NuttX include directory (retaining attributes and following symbolic links)
|
||||
|
||||
cp -LR --preserve=all "${TOPDIR}/include" "${EXPORTDIR}/." || \
|
||||
{ echo "MK: 'cp ${TOPDIR}/include' failed"; exit 1; }
|
||||
find "${EXPORTDIR}/include" -name .svn | xargs rm -rf
|
||||
|
||||
# Copy the startup object file(s)
|
||||
|
||||
make -C ${ARCHDIR} export_head TOPDIR=${TOPDIR} EXPORT_DIR="${EXPORTDIR}"
|
||||
|
||||
# Copy architecture-specific header files into the arch export sub-directory.
|
||||
# This is tricky because each architecture does things in a little different
|
||||
# way.
|
||||
#
|
||||
# First copy any header files in the architecture src/ sub-directory (some
|
||||
# architectures keep all of the header files there, some a few, and others
|
||||
# none
|
||||
|
||||
cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null
|
||||
|
||||
# Then look a list of possible places where other architecture-specific
|
||||
# header files might be found. If those places exist (as directories or
|
||||
# as symbolic links to directories, then copy the header files from
|
||||
# those directories into the EXPORTDIR
|
||||
|
||||
ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32"
|
||||
for hdir in $ARCH_HDRDIRS; do
|
||||
|
||||
# Does the directory (or symbolic link) exist?
|
||||
|
||||
if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then
|
||||
|
||||
# Yes.. create a export sub-directory of the same name
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/${hdir}" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; }
|
||||
|
||||
# Then copy the header files (only) into the new directory
|
||||
|
||||
cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null
|
||||
|
||||
# One architecture has low directory called "chip" that holds the
|
||||
# header files
|
||||
|
||||
if [ -d "${ARCHDIR}/${hdir}/chip" ]; then
|
||||
|
||||
# Yes.. create a export sub-directory of the same name
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/${hdir}/chip" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/chip' failed"; exit 1; }
|
||||
|
||||
# Then copy the header files (only) into the new directory
|
||||
|
||||
cp -f "${ARCHDIR}"/${hdir}/chip/*.h "${EXPORTDIR}"/arch/${hdir}/chip/. 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy OS internal header files as well. They are used by some architecture-
|
||||
# specific header files.
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/os" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/chip' failed"; exit 1; }
|
||||
cp -f "${TOPDIR}"/sched/*.h "${EXPORTDIR}"/arch/os/. 2>/dev/null
|
||||
|
||||
# Add the board library to the list of libraries
|
||||
|
||||
if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then
|
||||
LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}"
|
||||
fi
|
||||
|
||||
# Then process each library
|
||||
|
||||
for lib in ${LIBLIST}; do
|
||||
if [ ! -f "${TOPDIR}/${lib}" ]; then
|
||||
echo "MK: Library ${TOPDIR}/${lib} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get some shorter names for the library
|
||||
|
||||
libname=`basename ${lib} ${LIBEXT}`
|
||||
shortname=`echo ${libname} | sed -e "s/^lib//g"`
|
||||
|
||||
# Copy the application library unmodified
|
||||
|
||||
if [ "X${libname}" = "Xlibapps" ]; then
|
||||
cp --preserve=all "${TOPDIR}/${lib}" "${EXPORTDIR}/libs/." || \
|
||||
{ echo "MK: cp ${TOPDIR}/${lib} failed"; exit 1; }
|
||||
else
|
||||
|
||||
# Create a temporary directory and extract all of the objects there
|
||||
# Hmmm.. this probably won't work if the archiver is not 'ar'
|
||||
|
||||
mkdir "${EXPORTDIR}/tmp" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/tmp' failed"; exit 1; }
|
||||
cd "${EXPORTDIR}/tmp" || \
|
||||
{ echo "MK: 'cd ${EXPORTDIR}/tmp' failed"; exit 1; }
|
||||
ar x "${TOPDIR}/${lib}"
|
||||
|
||||
# Rename each object file (to avoid collision when they are combined)
|
||||
# and add the file to libnuttx
|
||||
|
||||
for file in `ls`; do
|
||||
mv "${file}" "${shortname}-${file}"
|
||||
ar rcs "${EXPORTDIR}/libs/libnuttx${LIBEXT}" "${shortname}-${file}"
|
||||
done
|
||||
|
||||
cd "${TOPDIR}" || \
|
||||
{ echo "MK: 'cd ${TOPDIR}' failed"; exit 1; }
|
||||
rm -rf "${EXPORTDIR}/tmp"
|
||||
fi
|
||||
done
|
||||
|
||||
# Now tar up the whole export directory
|
||||
|
||||
cd "${TOPDIR}" || \
|
||||
{ echo "MK: 'cd ${TOPDIR}' failed"; exit 1; }
|
||||
|
||||
if [ "X${TGZ}" = "Xy" ]; then
|
||||
tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1
|
||||
gzip -f "${EXPORTSUBDIR}.tar"
|
||||
else
|
||||
zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Clean up after ourselves
|
||||
|
||||
rm -rf "${EXPORTSUBDIR}"
|
||||
Executable
+289
@@ -0,0 +1,289 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# File: mkimage.sh
|
||||
#
|
||||
# Copyright (C) 2002 RidgeRun, Inc.
|
||||
# Author: RidgeRun, Inc <skranz@@ridgerun.com>
|
||||
# - Adapted for the Cadenux environment, 9-6-02, Gregory Nutt
|
||||
# - Added --EAddr option, 6-18-03, Gregory Nutt
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
# NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
########################################################
|
||||
# Description:
|
||||
# -----------
|
||||
# Scenario #1
|
||||
# -----------
|
||||
# This utility was developed by RidgeRun for the
|
||||
# purpose of converting a standard binary executable
|
||||
# image (such as ELF) into a special format (RR
|
||||
# format) suitable for quick downloads to the target
|
||||
# TI925 RidgeRun Bootloader (rrload). The image is
|
||||
# produced by constructing a special header which is
|
||||
# then tacked onto the front of the supplied binary
|
||||
# image. The resulting binary image is smaller than
|
||||
# what would normally be encountered with traditional
|
||||
# download formats (such as SREC or uuencoded; both
|
||||
# ascii based). The special header at the front of the
|
||||
# image is used to guide the target's rrload (a
|
||||
# booloader developed by RidgeRun Inc). The header
|
||||
# data contains a field representing the total byte
|
||||
# count of the binary data following the header as
|
||||
# well as a field that indicates the load address of
|
||||
# run image. Additionally, a field exists in the
|
||||
# header which indicates the image's entry point which
|
||||
# could be called by the bootloader to invoked the
|
||||
# just downloaded program.
|
||||
# -----------
|
||||
# Scenario #2
|
||||
# -----------
|
||||
# If the supplied image is not a standard binary
|
||||
# executagle image then that is ok too, a header is
|
||||
# constructed and tacked onto the front of the supplied
|
||||
# binary data forming the new binary image (in rr format).
|
||||
# In this case the EntryAddr is set to 0xFFFFFFFF by
|
||||
# default and the LoadAddr is set to 0x00000000 by
|
||||
# default unless otherwise indicated by command line
|
||||
# arguments -LEntry and -LAddr which if used are assumed
|
||||
# to be in hexidecimal units.
|
||||
#
|
||||
# -----------
|
||||
# Scenario #3
|
||||
# -----------
|
||||
#
|
||||
# Read/Write file system (like JFFS) that will not
|
||||
# work if rrload stores a 20 byte header at the beginning
|
||||
# of the flashed component image
|
||||
#
|
||||
# mkimage [--NoHeader ] <input-bin> <out-RR>
|
||||
#
|
||||
# Usage:
|
||||
# mkimage [--LAddr h] [--EAddr h] [--NoHeader] <input-bin> <out-RR>
|
||||
#
|
||||
# Examples:
|
||||
# $ mkimage linux linux.rr
|
||||
# ..or..
|
||||
# $ mkimage -LAddr 10008000 -EAddr 10008000 vmlinux vmlinux.rr
|
||||
# ..or..
|
||||
# $ mkimage --NoHeader fileSys.gz fileSys.gz.rr
|
||||
# ..or..
|
||||
# $ mkimage --LAddr A00 fileSys.gz fileSys.gz.rr
|
||||
# ..or..
|
||||
# $ mkimage --LAddr A00 fileSys.gz fileSys.gz.rr
|
||||
# ^
|
||||
# |
|
||||
# Assumed hex units.
|
||||
# Please omit the
|
||||
# leading "0x".
|
||||
########################################################
|
||||
|
||||
if [ $# -lt 2 ] ; then
|
||||
echo "Error: missing argument"
|
||||
echo "Usage: mkimage [--Prefix prefix] [--LAddr n] [--EAddr n] [--NoHeader] <input-Bin> <out-RR>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pleae Note the following formatting inconsistency.
|
||||
# (Sorry, for now this is necessary)
|
||||
LoadAddr="00000000" # Note: hex val *without* proceeding "0x"
|
||||
EntryAddr="0xFFFFFFFF" # Note: hex val *with* procedding "0x"
|
||||
|
||||
unset prefix
|
||||
Header="y"
|
||||
LAddrSupplied="n"
|
||||
EAddrSupplied="n"
|
||||
compress="n"
|
||||
|
||||
while [ $# -gt 0 ] ; do
|
||||
case "$1" in
|
||||
--Prefix)
|
||||
shift;
|
||||
prefix="$1"
|
||||
shift
|
||||
;;
|
||||
--LAddr )
|
||||
shift
|
||||
LoadAddr="$1"
|
||||
# Next, make the supplied LAddr exactly 8 hex chars long.
|
||||
LoadAddr="0000000${LoadAddr}"
|
||||
LoadAddr=$(echo $LoadAddr | sed -e "s/^.*\(........\)$/\1/g")
|
||||
LAddrSupplied="y"
|
||||
shift
|
||||
;;
|
||||
--EAddr )
|
||||
shift
|
||||
EntryAddr="$1"
|
||||
# Next, make the supplied LEntry exactly 8 hex chars long.
|
||||
EntryAddr="0000000${EntryAddr}"
|
||||
EntryAddr=$(echo $EntryAddr | sed -e "s/^.*\(........\)$/\1/g")
|
||||
EntryAddr=0x$EntryAddr
|
||||
EAddrSupplied="y"
|
||||
shift
|
||||
;;
|
||||
--NoHeader )
|
||||
Header="n"
|
||||
shift
|
||||
;;
|
||||
--compress )
|
||||
compress="y"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! $# -eq 2 ] ; then
|
||||
echo "Error: invalid argument set."
|
||||
echo "Usage: mkimage [--LAddr h] <input-Bin> <out-RR>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
binary=$1.stripped
|
||||
outbin=$2
|
||||
|
||||
cp $1 $binary
|
||||
FileTypeExec=$(${prefix}objdump -f $binary 2>/dev/null | egrep "EXEC_P")
|
||||
|
||||
if [ ! -z "$FileTypeExec" ] ; then
|
||||
|
||||
# -----------
|
||||
# Scenario #1
|
||||
# -----------
|
||||
# We have an executable style binary (like ELF, etc).
|
||||
# So...
|
||||
# ---------------------------------
|
||||
# Next | Create the binary image data.
|
||||
# ---------------------------------
|
||||
${prefix}strip ${binary}
|
||||
${prefix}objcopy -S -O binary $binary ${binary}.binary
|
||||
# ---------------------------------
|
||||
# Next | Create compress image if requested
|
||||
# ---------------------------------
|
||||
image_file=${binary}.binary
|
||||
if [ "$compress" = "y" ] ; then
|
||||
gzip -f -9 -c ${binary}.binary > ${binary}.binary.gz
|
||||
image_file=${binary}.binary.gz
|
||||
fi
|
||||
# ---------------------------------
|
||||
# Next | Create the header information (ascii) needed
|
||||
# | by the TI925 bootloader. This includes the
|
||||
# | load address, entry address and byte count of
|
||||
# | the binary executable data which will follow it.
|
||||
# ---------------------------------
|
||||
if [ "$LAddrSupplied" = "n" ] ; then
|
||||
# Next, Since LoadAddr not already supplied by user we'll
|
||||
# derive it by consulting the binary executable file.
|
||||
LoadAddr=$(${prefix}objdump -h ${binary} | grep " 0 \.")
|
||||
LoadAddr=$(echo $LoadAddr | cut -d' ' -f4) # eight hex chars
|
||||
fi
|
||||
if [ "$EAddrSupplied" = "n" ] ; then
|
||||
# Next, Since EntryAddr not already supplied by user we'll
|
||||
# derive it by consulting the binary executable file.
|
||||
EntryAddr=$(${prefix}objdump -f ${binary} | grep -i "start")
|
||||
EntryAddr=$(echo $EntryAddr | cut -d' ' -f3) # eight hex chars
|
||||
fi
|
||||
# Next, Compute byte length of binary portion.
|
||||
numBytes=$(wc --bytes $image_file)
|
||||
numBytes=$(echo $numBytes | cut -d' ' -f1)
|
||||
numBytes=$(echo 16o $numBytes p | dc) # converts to hex.
|
||||
# Next, make the numBytes string exactly 8 hex chars long.
|
||||
numBytes="0000000${numBytes}"
|
||||
numBytes=$(echo $numBytes | sed -e "s/^.*\(........\)$/\1/g")
|
||||
# ---------------------------------
|
||||
# Next | Combine the ascii header information
|
||||
# | with the binary image to make the
|
||||
# | final downloadable *mostly* binary
|
||||
# | image.
|
||||
# ---------------------------------
|
||||
rm -f ${outbin}
|
||||
echo ">LoadAddr :0x${LoadAddr}" >> ${outbin}
|
||||
if [ "${Header}" = "y" ]; then
|
||||
echo ">EntryAddr:${EntryAddr}" >> ${outbin}
|
||||
else
|
||||
echo ">NoHeader" >> ${outbin}
|
||||
fi
|
||||
echo ">NumBytes :0x${numBytes}" >> ${outbin}
|
||||
cat $image_file >> ${outbin}
|
||||
# ---------------------------------
|
||||
# Cleanup and exit
|
||||
# ---------------------------------
|
||||
rm -f ${binary}.binary $image_file
|
||||
exit 0
|
||||
|
||||
else
|
||||
|
||||
# -----------
|
||||
# Scenario #2
|
||||
# -----------
|
||||
# Just a binary image but not a standard executable
|
||||
# style binary (like ELF, etc). Might be a compressed
|
||||
# filesystem image, etc.
|
||||
# So...
|
||||
# ---------------------------------
|
||||
# Next | Create the header information (ascii) needed
|
||||
# | by the TI925 bootloader. This includes the
|
||||
# | load address, entry address and byte count of
|
||||
# | the binary file which will follow it.
|
||||
# ---------------------------------
|
||||
# | Create compress image if requested
|
||||
# ---------------------------------
|
||||
#
|
||||
image_file=${binary}
|
||||
if [ "$compress" = "y" ] ; then
|
||||
gzip -f -9 -c ${image_file} > ${image_file}.gz
|
||||
image_file=${image_file}.gz
|
||||
fi
|
||||
#
|
||||
# Note: The LoadAddr and EntryAddr are already established
|
||||
# for us at this point, but we will need to compute the
|
||||
# byte length of binary portion next.
|
||||
#
|
||||
numBytes=$(wc --bytes ${image_file})
|
||||
numBytes=$(echo $numBytes | cut -d' ' -f1)
|
||||
numBytes=$(echo 16o $numBytes p | dc) # converts to hex.
|
||||
# Next, make the numBytes string exactly 8 hex chars long.
|
||||
numBytes="0000000${numBytes}"
|
||||
numBytes=$(echo $numBytes | sed -e "s/^.*\(........\)$/\1/g")
|
||||
#
|
||||
# ---------------------------------
|
||||
# Next | Combine the ascii header information
|
||||
# | with the binary image to make the
|
||||
# | final downloadable *mostly* binary
|
||||
# | image.
|
||||
# ---------------------------------
|
||||
#
|
||||
rm -f ${outbin}
|
||||
echo ">LoadAddr :0x${LoadAddr}" >> ${outbin}
|
||||
if [ ${Header} = "y" ]; then
|
||||
echo ">EntryAddr:${EntryAddr}" >> ${outbin}
|
||||
else
|
||||
echo ">NoHeader" >> ${outbin}
|
||||
fi
|
||||
echo ">NumBytes :0x${numBytes}" >> ${outbin}
|
||||
cat ${image_file} >> ${outbin}
|
||||
# ---------------------------------
|
||||
# Cleanup and exit
|
||||
# ---------------------------------
|
||||
rm -f ${image_file}.gz
|
||||
exit 0
|
||||
fi
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# tools/mknulldeps.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
echo "# The selected toolchain does not support dependency generation"
|
||||
Executable
+261
@@ -0,0 +1,261 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/mkromfsimg.sh
|
||||
#
|
||||
# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Environmental stuff
|
||||
|
||||
wd=`pwd`
|
||||
workingdir=$wd/img
|
||||
rcsfile=rcS
|
||||
rcstemplate=$rcsfile.template
|
||||
romfsimg=romfs.img
|
||||
headerfile=nsh_romfsimg.h
|
||||
|
||||
# Get the input parameters
|
||||
|
||||
topdir=$1
|
||||
usage="USAGE: $0 <topdir>"
|
||||
|
||||
if [ -z "$topdir" -o ! -d "$topdir" ]; then
|
||||
echo "The full path to the NuttX base directory must be provided on the command line"
|
||||
echo $usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract all values from the .config in the $topdir that contains all of the NuttX
|
||||
# configuration settings. The .config file was intended to be include-able by makefiles
|
||||
# and source-able by scripts. Unfortunately,there are too many syntactic differents
|
||||
# to make that practical
|
||||
|
||||
if [ ! -r $topdir/.config ]; then
|
||||
echo "No readable file at $topdir/.config"
|
||||
echo "Has NuttX been configured?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
romfsetc=`grep CONFIG_NSH_ROMFSETC= $topdir/.config | cut -d'=' -f2`
|
||||
disablempt=`grep CONFIG_DISABLE_MOUNTPOINT= $topdir/.config | cut -d'=' -f2`
|
||||
disablescript=`grep CONFIG_NSH_DISABLESCRIPT= $topdir/.config | cut -d'=' -f2`
|
||||
ndescriptors=`grep CONFIG_NFILE_DESCRIPTORS= $topdir/.config | cut -d'=' -f2`
|
||||
devconsole=`grep CONFIG_DEV_CONSOLE= $topdir/.config | cut -d'=' -f2`
|
||||
romfs=`grep CONFIG_FS_ROMFS= $topdir/.config | cut -d'=' -f2`
|
||||
romfsmpt=`grep CONFIG_NSH_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2`
|
||||
initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2`
|
||||
romfsdevno=`grep CONFIG_NSH_ROMFSDEVNO= $topdir/.config | cut -d'=' -f2`
|
||||
romfssectsize=`grep CONFIG_NSH_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2`
|
||||
fatfs=`grep CONFIG_FS_FAT= $topdir/.config | cut -d'=' -f2`
|
||||
fatdevno=`grep CONFIG_NSH_FATDEVNO= $topdir/.config | cut -d'=' -f2`
|
||||
fatsectsize=`grep CONFIG_NSH_FATSECTSIZE= $topdir/.config | cut -d'=' -f2`
|
||||
fatnsectors=`grep CONFIG_NSH_FATNSECTORS= $topdir/.config | cut -d'=' -f2`
|
||||
fatmpt=`grep CONFIG_NSH_FATMOUNTPT= $topdir/.config | cut -d'=' -f2`
|
||||
|
||||
# The following settings are required for general ROMFS support
|
||||
#
|
||||
# Mountpoint support must be enabled
|
||||
|
||||
if [ "X$disablempt" = "Xy" ]; then
|
||||
echo "Mountpoint support is required for this feature"
|
||||
echo "Set CONFIG_DISABLE_MOUNTPOINT=n to continue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Scripting support must be enabled
|
||||
|
||||
if [ "X$disablescript" = "Xy" ]; then
|
||||
echo "NSH scripting support is required for this feature"
|
||||
echo "Set CONFIG_NSH_DISABLESCRIPT=n to continue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We need at least 2 file descriptors 1 for the ROMFS mount and one for
|
||||
# FAT mount performed in rcS. That still wouldn't be enough to to do much
|
||||
# with NSH
|
||||
|
||||
if [ -z "$ndescriptors" -o "$ndescriptors" -lt 2 ]; then
|
||||
echo "No file descriptors have been allocated"
|
||||
if [ "X$devconsole" = "Xy" ]; then
|
||||
echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 4"
|
||||
else
|
||||
echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 1"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If a console is enabled, then three more file descriptors are required
|
||||
# for stdin, stdout, and stderr
|
||||
|
||||
if [ "X$devconsole" = "Xy" -a "$ndescriptors" -lt 5 ]; then
|
||||
echo "Insufficient file descriptors have been allocated"
|
||||
echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 4"
|
||||
fi
|
||||
|
||||
# ROMFS support is required, of course
|
||||
|
||||
if [ "X$romfs" != "Xy" ]; then
|
||||
echo "ROMFS support is disabled in the NuttX configuration"
|
||||
echo "Set CONFIG_FS_ROMFS=y to continue"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# The options in the default rcS.template also require FAT FS support
|
||||
|
||||
if [ "X$fatfs" != "Xy" ]; then
|
||||
echo "FAT FS support is disabled in the NuttX configuration"
|
||||
echo "Set CONFIG_FS_FAT=y to continue"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Verify that genromfs has been installed
|
||||
|
||||
genromfs -h 1>/dev/null 2>&1 || { \
|
||||
echo "Host executable genromfs not available in PATH"; \
|
||||
echo "You may need to download in from http://romfs.sourceforge.net/"; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
# Supply defaults for all un-defined ROMFS settings
|
||||
|
||||
if [ -z "$romfsmpt" ]; then
|
||||
romfsmpt="/etc"
|
||||
fi
|
||||
if [ -z "$initscript" ]; then
|
||||
initscript="init.d/rcS"
|
||||
fi
|
||||
if [ -z "$romfsdevno" ]; then
|
||||
romfsdevno=0
|
||||
fi
|
||||
if [ -z "$romfssectsize" ]; then
|
||||
romfssectsize=64
|
||||
fi
|
||||
|
||||
# Supply defaults for all un-defined FAT FS settings
|
||||
|
||||
if [ -z "$fatdevno" ]; then
|
||||
fatdevno=1
|
||||
fi
|
||||
if [ -z "$fatsectsize" ]; then
|
||||
fatsectsize=512
|
||||
fi
|
||||
if [ -z "$fatnsectors" ]; then
|
||||
fatnsectors=1024
|
||||
fi
|
||||
if [ -z "$fatmpt" ]; then
|
||||
fatmpt="/tmp"
|
||||
fi
|
||||
|
||||
# Verify the mountpoint. Verify that it is an absolute path but not /, /dev,
|
||||
# /., /./*, /.., or /../*
|
||||
|
||||
if [ ${romfsmpt:0:1} != "\"" ]; then
|
||||
echo "CONFIG_NSH_ROMFSMOUNTPT must be a string"
|
||||
echo "Change it so that it is enclosed in quotes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
uromfsmpt=`echo $romfsmpt | sed -e "s/\"//g"`
|
||||
|
||||
if [ ${uromfsmpt:0:1} != "/" ]; then
|
||||
echo "CONFIG_NSH_ROMFSMOUNTPT must be an absolute path in the target FS"
|
||||
echo "Change it so that it begins with the character '/'. Eg. /etc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpdir=$uromfsmpt
|
||||
while [ ${tmpdir:0:1} == "/" ]; do
|
||||
tmpdir=${tmpdir:1}
|
||||
done
|
||||
|
||||
if [ -z "$tmpdir" -o "X$tmpdir" = "Xdev" -o "X$tmpdir" = "." -o \
|
||||
${tmpdir:0:2} = "./" -o "X$tmpdir" = ".." -o ${tmpdir:0:3} = "../" ]; then
|
||||
echo "Invalid CONFIG_NSH_ROMFSMOUNTPT selection."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify that the path to the init file is a relative path and not ., ./*, .., or ../*
|
||||
|
||||
if [ ${initscript:0:1} != "\"" ]; then
|
||||
echo "CONFIG_NSH_INITSCRIPT must be a string"
|
||||
echo "Change it so that it is enclosed in quotes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
uinitscript=`echo $initscript | sed -e "s/\"//g"`
|
||||
|
||||
if [ ${uinitscript:0:1} == "/" ]; then
|
||||
echo "CONFIG_NSH_INITSCRIPT must be an relative path in under $romfsmpt"
|
||||
echo "Change it so that it begins with the character '/'. Eg. init.d/rcS. "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "X$uinitscript" = "." -o ${uinitscript:0:2} = "./" -o \
|
||||
"X$uinitscript" = ".." -o ${uinitscript:0:3} = "../" ]; then
|
||||
echo "Invalid CONFIG_NSH_INITSCRIPT selection. Must not begin with . or .."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a working directory
|
||||
|
||||
rm -rf $workingdir || { echo "Failed to remove the old $workingdir"; exit 1; }
|
||||
mkdir -p $workingdir || { echo "Failed to created the new $workingdir"; exit 1; }
|
||||
|
||||
# Create the rcS file from the rcS.template
|
||||
|
||||
if [ ! -r $rcstemplate ]; then
|
||||
echo "$rcstemplete does not exist"
|
||||
rmdir $workingdir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat $rcstemplate | \
|
||||
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
|
||||
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
|
||||
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
|
||||
sed -e "s,XXXRDMOUNTPOUNTXXX,$fatmpt,g" >$rcsfile
|
||||
|
||||
# And install it at the specified relative location
|
||||
|
||||
install -D --mode=0755 $rcsfile $workingdir/$uinitscript || \
|
||||
{ echo "Failed to install $rcsfile at $workingdir/$uinitscript"; rm -f $rcsfile; exit 1; }
|
||||
rm -f $rcsfile
|
||||
|
||||
# Now we are ready to make the ROMFS image
|
||||
|
||||
genromfs -f $romfsimg -d $workingdir -V "NSHInitVol" || { echo "genromfs failed" ; exit 1 ; }
|
||||
rm -rf $workingdir || { echo "Failed to remove the old $workingdir"; exit 1; }
|
||||
|
||||
# And, finally, create the header file
|
||||
|
||||
xxd -i $romfsimg >$headerfile || { echo "xxd of $< failed" ; rm -f $romfsimg; exit 1 ; }
|
||||
rm -f $romfsimg
|
||||
@@ -0,0 +1,831 @@
|
||||
/****************************************************************************
|
||||
* tools/mksyscall.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LINESIZE (PATH_MAX > 256 ? PATH_MAX : 256)
|
||||
|
||||
#define MAX_FIELDS 16
|
||||
#define MAX_PARMSIZE 128
|
||||
#define NAME_INDEX 0
|
||||
#define HEADER_INDEX 1
|
||||
#define COND_INDEX 2
|
||||
#define RETTYPE_INDEX 3
|
||||
#define PARM1_INDEX 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static bool g_debug;
|
||||
static bool g_inline;
|
||||
static char g_line[LINESIZE+1];
|
||||
static char g_parm[MAX_FIELDS][MAX_PARMSIZE];
|
||||
static FILE *g_stubstream;
|
||||
static int g_lineno;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static char *skip_space(char *ptr)
|
||||
{
|
||||
while (*ptr && isspace(*ptr)) ptr++;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static char *read_line(FILE *stream)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
g_line[LINESIZE] = '\0';
|
||||
if (!fgets(g_line, LINESIZE, stream))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_lineno++;
|
||||
if (g_debug)
|
||||
{
|
||||
printf("Line: %s\n", g_line);
|
||||
}
|
||||
|
||||
ptr = skip_space(g_line);
|
||||
if (*ptr && *ptr != '#' && *ptr != '\n')
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *copy_parm(char *src, char *dest)
|
||||
{
|
||||
char *start = src;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_PARMSIZE; i++)
|
||||
{
|
||||
if (*src == '"')
|
||||
{
|
||||
*dest = '\0';
|
||||
return src;
|
||||
}
|
||||
else if (*src == '\n' || *src == '\0')
|
||||
{
|
||||
fprintf(stderr, "%d: Unexpected end of line: \"%s\"\n", g_lineno, start);
|
||||
exit(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%d: Parameter too long: \"%s\"\n", g_lineno, start);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
static char *find_parm(char *ptr)
|
||||
{
|
||||
char *start = ptr;
|
||||
|
||||
if (*ptr != '"')
|
||||
{
|
||||
fprintf(stderr, "%d: I'm confused: \"%s\"\n", g_lineno, start);
|
||||
exit(5);
|
||||
}
|
||||
ptr++;
|
||||
|
||||
ptr = skip_space(ptr);
|
||||
if (*ptr == '\n' || *ptr == '\0')
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if (*ptr != ',')
|
||||
{
|
||||
fprintf(stderr, "%d: Expected ',': \"%s\"\n", g_lineno, start);
|
||||
exit(6);
|
||||
}
|
||||
ptr++;
|
||||
|
||||
ptr = skip_space(ptr);
|
||||
if (*ptr != '"')
|
||||
{
|
||||
fprintf(stderr, "%d: Expected \": \"%s\"\n", g_lineno, start);
|
||||
exit(7);
|
||||
}
|
||||
ptr++;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static int parse_csvline(char *ptr)
|
||||
{
|
||||
int nparms;
|
||||
int i;
|
||||
|
||||
/* Format "arg1","arg2","arg3",... Spaces will be tolerated outside of the
|
||||
* quotes. Any initial spaces have already been skipped so the first thing
|
||||
* should be '"'.
|
||||
*/
|
||||
|
||||
if (*ptr != '"')
|
||||
{
|
||||
fprintf(stderr, "%d: Bad line: \"%s\"\n", g_lineno, g_line);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
ptr++;
|
||||
nparms = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ptr = copy_parm(ptr, &g_parm[nparms][0]);
|
||||
nparms++;
|
||||
ptr = find_parm(ptr);
|
||||
}
|
||||
while (ptr);
|
||||
|
||||
if (g_debug)
|
||||
{
|
||||
printf("Parameters: %d\n", nparms);
|
||||
for (i = 0; i < nparms; i++)
|
||||
{
|
||||
printf(" Parm%d: \"%s\"\n", i+1, g_parm[i]);
|
||||
}
|
||||
}
|
||||
return nparms;
|
||||
}
|
||||
|
||||
static bool is_vararg(const char *type, int index, int nparms)
|
||||
{
|
||||
if (strcmp(type,"...") == 0)
|
||||
{
|
||||
if (index != (nparms-1))
|
||||
{
|
||||
fprintf(stderr, "%d: ... is not the last in the argument list\n", g_lineno);
|
||||
exit(11);
|
||||
}
|
||||
else if (nparms < 2)
|
||||
{
|
||||
fprintf(stderr, "%d: Need one parameter before ...\n", g_lineno);
|
||||
exit(14);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_union(const char *type)
|
||||
{
|
||||
return (strncmp(type,"union", 5) == 0);
|
||||
}
|
||||
|
||||
static const char *check_funcptr(const char *type)
|
||||
{
|
||||
const char *str = strstr(type,"(*)");
|
||||
if (str)
|
||||
{
|
||||
return str + 2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *check_array(const char *type)
|
||||
{
|
||||
const char *str = strchr(type, '[');
|
||||
if (str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void print_formalparm(FILE *stream, const char *argtype, int parmno)
|
||||
{
|
||||
const char *part2;
|
||||
int len;
|
||||
|
||||
/* Function pointers and array formal parameter types are a little more work */
|
||||
|
||||
if ((part2 = check_funcptr(argtype)) != NULL || (part2 = check_array(argtype)) != NULL)
|
||||
{
|
||||
len = part2 - argtype;
|
||||
(void)fwrite(argtype, 1, len, stream);
|
||||
fprintf(stream, "parm%d%s", parmno, part2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, "%s parm%d", argtype, parmno);
|
||||
}
|
||||
}
|
||||
|
||||
static void get_formalparmtype(const char *arg, char *formal)
|
||||
{
|
||||
/* The formal parm type is a pointer to everything up to the first'|' (or
|
||||
* the end of the string if there is no '|' in the type description).
|
||||
*/
|
||||
|
||||
while (*arg != '|' && *arg != '\0')
|
||||
{
|
||||
*formal++ = *arg++;
|
||||
}
|
||||
*formal = '\0';
|
||||
}
|
||||
|
||||
static void get_actualparmtype(const char *arg, char *actual)
|
||||
{
|
||||
const char *pstart = strchr(arg,'|');
|
||||
if (pstart)
|
||||
{
|
||||
/* The actual parameter type starts after the '|' */
|
||||
|
||||
pstart++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The actual parameter is the same as the formal parameter
|
||||
* at starts at the beginning of the type string.
|
||||
*/
|
||||
|
||||
pstart = arg;
|
||||
}
|
||||
|
||||
/* The actual parm type is a pointer to everything up to the next '|' (or
|
||||
* the end of the string if there is no '|' in the type description).
|
||||
*/
|
||||
|
||||
while (*pstart != '|' && *pstart != '\0')
|
||||
{
|
||||
*actual++ = *pstart++;
|
||||
}
|
||||
*actual = '\0';
|
||||
}
|
||||
|
||||
static void get_fieldname(const char *arg, char *fieldname)
|
||||
{
|
||||
char *pactual = strchr(arg,'|');
|
||||
char *pstart;
|
||||
|
||||
if (pactual)
|
||||
{
|
||||
/* The actual parameter type starts after the '|' */
|
||||
|
||||
pactual++;
|
||||
pstart = strchr(pactual,'|');
|
||||
if (pstart)
|
||||
{
|
||||
/* The fieldname is everything past the second '|' to the end of the string */
|
||||
|
||||
pstart++;
|
||||
strncpy(fieldname, pstart, MAX_PARMSIZE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%d: Missing union fieldname: %s\n", g_lineno, arg);
|
||||
exit(15);
|
||||
}
|
||||
|
||||
static FILE *open_proxy(void)
|
||||
{
|
||||
char filename[MAX_PARMSIZE+10];
|
||||
FILE *stream;
|
||||
|
||||
snprintf(filename, MAX_PARMSIZE+9, "PROXY_%s.c", g_parm[NAME_INDEX]);
|
||||
filename[MAX_PARMSIZE+9] = '\0';
|
||||
|
||||
stream = fopen(filename, "w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
|
||||
exit(10);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
static void generate_proxy(int nparms)
|
||||
{
|
||||
FILE *stream = open_proxy();
|
||||
char formal[MAX_PARMSIZE];
|
||||
char fieldname[MAX_PARMSIZE];
|
||||
bool bvarargs = false;
|
||||
int nformal;
|
||||
int nactual;
|
||||
int i;
|
||||
|
||||
/* Generate "up-front" information, include correct header files */
|
||||
|
||||
fprintf(stream, "/* Auto-generated %s proxy file -- do not edit */\n\n", g_parm[NAME_INDEX]);
|
||||
fprintf(stream, "#include <nuttx/config.h>\n");
|
||||
|
||||
/* Does this function have a variable number of parameters? If so then the
|
||||
* final parameter type will be encoded as "..."
|
||||
*/
|
||||
|
||||
if (is_vararg(g_parm[PARM1_INDEX+nparms-1], nparms-1, nparms))
|
||||
{
|
||||
nformal = nparms-1;
|
||||
bvarargs = true;
|
||||
fprintf(stream, "#include <stdarg.h>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
nformal = nparms;
|
||||
}
|
||||
|
||||
fprintf(stream, "#include <%s>\n", g_parm[HEADER_INDEX]);
|
||||
fprintf(stream, "#include <syscall.h>\n\n");
|
||||
|
||||
if (g_parm[COND_INDEX][0] != '\0')
|
||||
{
|
||||
fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
/* Generate the function definition that matches standard function prototype */
|
||||
|
||||
fprintf(stream, "%s %s(", g_parm[RETTYPE_INDEX], g_parm[NAME_INDEX]);
|
||||
|
||||
/* Generate the formal parameter list */
|
||||
|
||||
if (nformal <= 0)
|
||||
{
|
||||
fprintf(stream, "void");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < nformal; i++)
|
||||
{
|
||||
/* The formal and actual parameter types may be encoded.. extra the
|
||||
* formal parameter type.
|
||||
*/
|
||||
|
||||
get_formalparmtype(g_parm[PARM1_INDEX+i], formal);
|
||||
|
||||
/* Arguments after the first must be separated from the preceding
|
||||
* parameter with a comma.
|
||||
*/
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
fprintf(stream, ", ");
|
||||
}
|
||||
print_formalparm(stream, formal, i+1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the end of the formal parameter list */
|
||||
|
||||
if (bvarargs)
|
||||
{
|
||||
fprintf(stream, ", ...)\n{\n");
|
||||
|
||||
/* Get parm variables .. some from the parameter list and others from
|
||||
* the varargs.
|
||||
*/
|
||||
|
||||
if (nparms < 7)
|
||||
{
|
||||
fprintf(stream, " va_list ap;\n");
|
||||
for (i = nparms; i < 7; i++)
|
||||
{
|
||||
fprintf(stream, " uintptr_t parm%d;\n", i);
|
||||
}
|
||||
|
||||
fprintf(stream, "\n va_start(ap, parm%d);\n", nparms-1);
|
||||
for (i = nparms; i < 7; i++)
|
||||
{
|
||||
fprintf(stream, " parm%d = va_arg(ap, uintptr_t);\n", i);
|
||||
}
|
||||
fprintf(stream, " va_end(ap);\n\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, ")\n{\n");
|
||||
}
|
||||
|
||||
/* Generate the system call. Functions that do not return or return void
|
||||
* are special cases.
|
||||
*/
|
||||
|
||||
nactual = bvarargs ? 6 : nparms;
|
||||
if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0)
|
||||
{
|
||||
fprintf(stream, " (void)sys_call%d(", nactual);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, " return (%s)sys_call%d(", g_parm[RETTYPE_INDEX], nactual);
|
||||
}
|
||||
|
||||
/* Create the parameter list with the matching types. The first parameter
|
||||
* is always the syscall number.
|
||||
*/
|
||||
|
||||
fprintf(stream, "(unsigned int)SYS_%s", g_parm[NAME_INDEX]);
|
||||
|
||||
for (i = 0; i < nactual; i++)
|
||||
{
|
||||
/* Is the parameter a union member */
|
||||
|
||||
if (i < nparms && is_union(g_parm[PARM1_INDEX+i]))
|
||||
{
|
||||
/* Then we will have to pick a field name that can be cast to a
|
||||
* uintptr_t. There probably should be some error handling here
|
||||
* to catch the case where the fieldname was not supplied.
|
||||
*/
|
||||
|
||||
get_fieldname(g_parm[PARM1_INDEX+i], fieldname);
|
||||
fprintf(stream, ", (uintptr_t)parm%d.%s", i+1, fieldname);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, ", (uintptr_t)parm%d", i+1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the tail end of the function. */
|
||||
|
||||
fprintf(stream, ");\n}\n\n");
|
||||
if (g_parm[COND_INDEX][0] != '\0')
|
||||
{
|
||||
fprintf(stream, "#endif /* %s */\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
}
|
||||
|
||||
static FILE *open_stub(void)
|
||||
{
|
||||
if (g_inline)
|
||||
{
|
||||
if (!g_stubstream)
|
||||
{
|
||||
g_stubstream = fopen("STUB.h", "w");
|
||||
if (g_stubstream == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open STUB.h: %s\n", strerror(errno));
|
||||
exit(9);
|
||||
}
|
||||
fprintf(g_stubstream, "/* Autogenerated STUB header file */\n\n");
|
||||
fprintf(g_stubstream, "#ifndef __STUB_H\n");
|
||||
fprintf(g_stubstream, "#define __STUB_H\n\n");
|
||||
}
|
||||
|
||||
return g_stubstream;
|
||||
}
|
||||
else
|
||||
{
|
||||
char filename[MAX_PARMSIZE+8];
|
||||
FILE *stream;
|
||||
|
||||
snprintf(filename, MAX_PARMSIZE+7, "STUB_%s.c", g_parm[NAME_INDEX]);
|
||||
filename[MAX_PARMSIZE+7] = '\0';
|
||||
|
||||
stream = fopen(filename, "w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
|
||||
exit(9);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
static void stub_close(FILE *stream)
|
||||
{
|
||||
if (!g_inline)
|
||||
{
|
||||
fclose(stream);
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_stub(int nparms)
|
||||
{
|
||||
FILE *stream = open_stub();
|
||||
char formal[MAX_PARMSIZE];
|
||||
char actual[MAX_PARMSIZE];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
/* Generate "up-front" information, include correct header files */
|
||||
|
||||
fprintf(stream, "/* Auto-generated %s stub file -- do not edit */\n\n", g_parm[0]);
|
||||
fprintf(stream, "#include <nuttx/config.h>\n");
|
||||
fprintf(stream, "#include <stdint.h>\n");
|
||||
fprintf(stream, "#include <%s>\n\n", g_parm[HEADER_INDEX]);
|
||||
|
||||
if (g_parm[COND_INDEX][0] != '\0')
|
||||
{
|
||||
fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
/* Generate the function definition that matches standard function prototype */
|
||||
|
||||
if (g_inline)
|
||||
{
|
||||
fprintf(stream, "static inline ");
|
||||
}
|
||||
fprintf(stream, "uintptr_t STUB_%s(", g_parm[NAME_INDEX]);
|
||||
|
||||
/* Generate the formal parameter list. A function received no parameters is a special case. */
|
||||
|
||||
if (nparms <= 0)
|
||||
{
|
||||
fprintf(stream, "void");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < nparms; i++)
|
||||
{
|
||||
/* Treat the first argument in the list differently from the others..
|
||||
* It does not need a comma before it.
|
||||
*/
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
/* Check for a variable number of arguments */
|
||||
|
||||
if (is_vararg(g_parm[PARM1_INDEX+i], i, nparms))
|
||||
{
|
||||
/* Always receive six arguments in this case */
|
||||
|
||||
for (j = i+1; j <= 6; j++)
|
||||
{
|
||||
fprintf(stream, ", uintptr_t parm%d", j);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, ", uintptr_t parm%d", i+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, "uintptr_t parm%d", i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stream, ")\n{\n");
|
||||
|
||||
/* Then call the proxied function. Functions that have no return value are
|
||||
* a special case.
|
||||
*/
|
||||
|
||||
if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0)
|
||||
{
|
||||
fprintf(stream, " %s(", g_parm[NAME_INDEX]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, " return (uintptr_t)%s(", g_parm[NAME_INDEX]);
|
||||
}
|
||||
|
||||
/* The pass all of the system call parameters, casting to the correct type
|
||||
* as necessary.
|
||||
*/
|
||||
|
||||
for (i = 0; i < nparms; i++)
|
||||
{
|
||||
/* Get the formal type of the parameter, and get the type that we
|
||||
* actually have to cast to. For example for a formal type like 'int parm[]'
|
||||
* we have to cast the actual parameter to 'int*'. The worst is a union
|
||||
* type like 'union sigval' where we have to cast to (union sigval)((FAR void *)parm)
|
||||
* -- Yech.
|
||||
*/
|
||||
|
||||
get_formalparmtype(g_parm[PARM1_INDEX+i], formal);
|
||||
get_actualparmtype(g_parm[PARM1_INDEX+i], actual);
|
||||
|
||||
/* Treat the first argument in the list differently from the others..
|
||||
* It does not need a comma before it.
|
||||
*/
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
/* Check for a variable number of arguments */
|
||||
|
||||
if (is_vararg(actual, i, nparms))
|
||||
{
|
||||
/* Always pass six arguments */
|
||||
|
||||
for (j = i+1; j <=6; j++)
|
||||
{
|
||||
fprintf(stream, ", parm%d", j);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_union(formal))
|
||||
{
|
||||
fprintf(stream, ", (%s)((%s)parm%d)", formal, actual, i+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, ", (%s)parm%d", actual, i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_union(formal))
|
||||
{
|
||||
fprintf(stream, "(%s)((%s)parm%d)", formal, actual, i+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, "(%s)parm%d",actual, i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Tail end of the function. If the proxied function has no return
|
||||
* value, just return zero (OK).
|
||||
*/
|
||||
|
||||
if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0)
|
||||
{
|
||||
fprintf(stream, ");\n return 0;\n}\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, ");\n}\n\n");
|
||||
}
|
||||
|
||||
if (g_parm[COND_INDEX][0] != '\0')
|
||||
{
|
||||
fprintf(stream, "#endif /* %s */\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
stub_close(stream);
|
||||
}
|
||||
|
||||
static void show_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [-p|s|i] <CSV file>\n\n", progname);
|
||||
fprintf(stderr, "Where:\n\n");
|
||||
fprintf(stderr, "\t-p : Generate proxies\n");
|
||||
fprintf(stderr, "\t-s : Generate stubs\n");
|
||||
fprintf(stderr, "\t-i : Generate proxies as static inline functions\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
char *csvpath;
|
||||
bool proxies = false;
|
||||
FILE *stream;
|
||||
char *ptr;
|
||||
int ch;
|
||||
|
||||
/* Parse command line options */
|
||||
|
||||
g_debug = false;
|
||||
g_inline = false;
|
||||
|
||||
while ((ch = getopt(argc, argv, ":dps")) > 0)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'd' :
|
||||
g_debug = true;
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
proxies = true;
|
||||
break;
|
||||
|
||||
case 's' :
|
||||
proxies = false;
|
||||
break;
|
||||
|
||||
case 'i' :
|
||||
g_inline = true;
|
||||
break;
|
||||
|
||||
case '?' :
|
||||
fprintf(stderr, "Unrecognized option: %c\n", optopt);
|
||||
show_usage(argv[0]);
|
||||
|
||||
case ':' :
|
||||
fprintf(stderr, "Missing option argument, option: %c\n", optopt);
|
||||
show_usage(argv[0]);
|
||||
|
||||
break;
|
||||
fprintf(stderr, "Unexpected option: %c\n", ch);
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
fprintf(stderr, "Missing <CSV file>\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
csvpath = argv[optind];
|
||||
if (++optind < argc)
|
||||
{
|
||||
fprintf(stderr, "Unexpected garbage at the end of the line\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
/* Open the CSV file */
|
||||
|
||||
stream= fopen(csvpath, "r");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "open %s failed: %s\n", csvpath, strerror(errno));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
/* Process each line in the CVS file */
|
||||
|
||||
while ((ptr = read_line(stream)) != NULL)
|
||||
{
|
||||
/* Parse the line from the CVS file */
|
||||
|
||||
int nargs = parse_csvline(ptr);
|
||||
if (nargs < PARM1_INDEX)
|
||||
{
|
||||
fprintf(stderr, "Only %d arguments found: %s\n", nargs, g_line);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
if (proxies)
|
||||
{
|
||||
generate_proxy(nargs - PARM1_INDEX);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_stubstream = NULL;
|
||||
generate_stub(nargs - PARM1_INDEX);
|
||||
if (g_stubstream != NULL)
|
||||
{
|
||||
fprintf(g_stubstream, "\n#endif /* __STUB_H */\n");
|
||||
fclose(g_stubstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the CSV file */
|
||||
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
* tools/mkversion.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "cfgparser.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define DEFCONFIG ".version"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline char *getfilepath(const char *name)
|
||||
{
|
||||
snprintf(line, PATH_MAX, "%s/" DEFCONFIG, name);
|
||||
line[PATH_MAX] = '\0';
|
||||
return strdup(line);
|
||||
}
|
||||
|
||||
static void show_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s <abs path to .version>\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
char *filepath;
|
||||
FILE *stream;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Unexpected number of arguments\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
filepath = getfilepath(argv[1]);
|
||||
if (!filepath)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
stream= fopen(filepath, "r");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
printf("/* version.h -- Autogenerated! Do not edit. */\n\n");
|
||||
printf("#ifndef __INCLUDE_NUTTX_VERSION_H\n");
|
||||
printf("#define __INCLUDE_NUTTX_VERSION_H\n\n");
|
||||
parse_file(stream);
|
||||
printf("\n#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 8) | (CONFIG_VERSION_MINOR))\n\n");
|
||||
printf("#endif /* __INCLUDE_NUTTX_VERSION_H */\n");
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/unlink.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
link=$1
|
||||
|
||||
# Verify that arguments were provided
|
||||
|
||||
if [ -z "${link}" ]; then
|
||||
echo "Missing link argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if something already exists at the link path
|
||||
|
||||
if [ -e "${link}" ]; then
|
||||
|
||||
# Yes, is it a symbolic link? If so, then remove it
|
||||
|
||||
if [ -h "${link}" ]; then
|
||||
rm -f "${link}"
|
||||
else
|
||||
|
||||
# If the path is a directory and contains the "fake link" mark, then
|
||||
# treat it like a soft link (i.e., remove the directory)
|
||||
|
||||
if [ -d "${link}" -a -f "${link}/.fakelnk" ]; then
|
||||
rm -rf "${link}"
|
||||
else
|
||||
|
||||
# It is something else (like a file) or directory that does
|
||||
# not contain the "fake link" mark
|
||||
|
||||
echo "${link} already exists but is not a symbolic link"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
# version.sh
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
WD=`pwd`
|
||||
|
||||
# Get command line parameters
|
||||
|
||||
USAGE="USAGE: $0 [-d|-h] [-b build] -v <major.minor> <outfile-path>"
|
||||
ADVICE="Try '$0 -h' for more information"
|
||||
|
||||
unset VERSION
|
||||
unset BUILD
|
||||
unset OUTFILE
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-b )
|
||||
shift
|
||||
BUILD=$1
|
||||
;;
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-v )
|
||||
shift
|
||||
VERSION=$1
|
||||
;;
|
||||
-h )
|
||||
echo "$0 is a tool for generation of proper version files for the NuttX build"
|
||||
echo ""
|
||||
echo $USAGE
|
||||
echo ""
|
||||
echo "Where:"
|
||||
echo " -d"
|
||||
echo " Enable script debug"
|
||||
echo " -h"
|
||||
echo " show this help message and exit"
|
||||
echo " -v <major.minor>"
|
||||
echo " The NuttX version number expressed a major and minor number separated"
|
||||
echo " by a period"
|
||||
echo " <outfile-path>"
|
||||
echo " The full path to the version file to be created"
|
||||
exit 0
|
||||
;;
|
||||
* )
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
OUTFILE=$1
|
||||
|
||||
# Make sure we know what is going on
|
||||
|
||||
if [ -z ${VERSION} ] ; then
|
||||
echo "Missing versioning information"
|
||||
echo $USAGE
|
||||
echo $ADVICE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z ${OUTFILE} ] ; then
|
||||
echo "Missing path to the output file"
|
||||
echo $USAGE
|
||||
echo $ADVICE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the major and minor version numbers
|
||||
|
||||
MAJOR=`echo ${VERSION} | cut -d'.' -f1`
|
||||
if [ "X${MAJOR}" = "X${VERSION}" ]; then
|
||||
echo "Missing minor version number"
|
||||
echo $USAGE
|
||||
echo $ADVICE
|
||||
exit 2
|
||||
fi
|
||||
MINOR=`echo ${VERSION} | cut -d'.' -f2`
|
||||
|
||||
# Get SVN information (if not provided on the command line)
|
||||
|
||||
if [ -z "${BUILD}" ]; then
|
||||
SVNINFO=`svn info 2>/dev/null | fgrep 'Revision:'`
|
||||
if [ -z "${SVNINFO}" ]; then
|
||||
echo "SVN version information is not available"
|
||||
exit 3
|
||||
fi
|
||||
BUILD=`echo ${SVNINFO} | cut -d' ' -f2`
|
||||
if [ -z "${BUILD}" ]; then
|
||||
echo "SVN build information not found"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
|
||||
# Write a version file into the NuttX directoy. The syntax of file is such that it
|
||||
# may be sourced by a bash script or included by a Makefile.
|
||||
|
||||
echo "#!/bin/bash" >${OUTFILE}
|
||||
echo "" >>${OUTFILE}
|
||||
echo "CONFIG_VERSION_STRING=\"${VERSION}\"" >>${OUTFILE}
|
||||
echo "CONFIG_VERSION_MAJOR=${MAJOR}" >>${OUTFILE}
|
||||
echo "CONFIG_VERSION_MINOR=${MINOR}" >>${OUTFILE}
|
||||
echo "CONFIG_VERSION_BUILD=${BUILD}" >>${OUTFILE}
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/winlink.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# NuttX uses symbolic links to configure platform-specific directories into
|
||||
# the build system. This works great except for when a Windows native
|
||||
# toolchain is used in a Cygwin environment. In that case, symbolic
|
||||
# links do not work correctly when accessed from the Windows native toolchain;
|
||||
# rather, just look link files with the extension .lnk
|
||||
#
|
||||
# In this environment, the build system will work around this using this script
|
||||
# as a replacement for the 'ln' command. This scrpt will simply copy the
|
||||
# directory into the expected positiion.
|
||||
#
|
||||
#set -x
|
||||
|
||||
src=$1
|
||||
dest=$2
|
||||
|
||||
# Verify that arguments were provided
|
||||
|
||||
if [ -z "${src}" -o -z "${dest}" ]; then
|
||||
echo "Missing src and/or dest arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if something already exists at the destination path replace it with
|
||||
# the new link (which might be different). Note that we check for the
|
||||
# the link (-h) before we check for existence (-e) because a bad link will
|
||||
# report that it does not exist.
|
||||
|
||||
if [ -h "${dest}" ]; then
|
||||
rm -f "${dest}"
|
||||
else
|
||||
|
||||
# If the path exists and is a directory that contains the "fake link"
|
||||
# mark, then treat it like a soft link (i.e., remove the directory)
|
||||
|
||||
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
||||
rm -rf "${dest}"
|
||||
else
|
||||
|
||||
# Does anything exist at the destination path?
|
||||
|
||||
if [ -e "${dest}" ]; then
|
||||
|
||||
# It is something else (like a file) or directory that does
|
||||
# not contain the "fake link" mark
|
||||
|
||||
echo "${dest} already exists but is not a symbolic link"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Verify that a directory exists at the source path
|
||||
|
||||
if [ ! -d "${src}" ]; then
|
||||
echo "No directory at ${src}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the directory
|
||||
|
||||
cp -a "${src}" "${dest}" || \
|
||||
{ echo "Failed to create link: $dest" ; rm -rf ${dest} ; exit 1 ; }
|
||||
touch "${dest}/.fakelnk" || \
|
||||
{ echo "Failed to touch ${dest}/.fakelnk" ; rm -rf ${dest} ; exit 1 ; }
|
||||
|
||||
Executable
+178
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
# zipme.sh
|
||||
#
|
||||
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#set -x
|
||||
|
||||
WD=`pwd`
|
||||
VERSION=$1
|
||||
|
||||
TAR="tar cvf"
|
||||
ZIP=gzip
|
||||
|
||||
# Make sure we know what is going on
|
||||
|
||||
if [ -z ${VERSION} ] ; then
|
||||
echo "You must supply a version like xx.yy as a parameter"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Find the directory we were executed from and were we expect to
|
||||
# see the directories to tar up
|
||||
|
||||
MYNAME=`basename $0`
|
||||
|
||||
if [ -x ${WD}/${MYNAME} ] ; then
|
||||
TRUNKDIR="${WD}/../.."
|
||||
else
|
||||
if [ -x ${WD}/tools/${MYNAME} ] ; then
|
||||
TRUNKDIR="${WD}/.."
|
||||
else
|
||||
if [ -x ${WD}/nuttx-${VERSION}/tools/${MYNAME} ] ; then
|
||||
TRUNKDIR="${WD}"
|
||||
else
|
||||
echo "You must cd into the NUTTX directory to execute this script."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get the NuttX directory names and the path to the parent directory
|
||||
|
||||
NUTTX=${TRUNKDIR}/nuttx-${VERSION}
|
||||
APPDIR=${TRUNKDIR}/apps-${VERSION}
|
||||
|
||||
# Make sure that the versioned directory exists
|
||||
|
||||
if [ ! -d ${TRUNKDIR} ]; then
|
||||
echo "Directory ${TRUNKDIR} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ${TRUNKDIR} || \
|
||||
{ echo "Failed to cd to ${TRUNKDIR}" ; exit 1 ; }
|
||||
|
||||
if [ ! -d nuttx-${VERSION} ] ; then
|
||||
echo "Directory ${TRUNKDIR}/nuttx-${VERSION} does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d apps-${VERSION} ] ; then
|
||||
echo "Directory ${TRUNKDIR}/apps-${VERSION} does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create the versioned tarball names
|
||||
|
||||
NUTTX_TARNAME=nuttx-${VERSION}.tar
|
||||
APPS_TARNAME=apps-${VERSION}.tar
|
||||
NUTTX_ZIPNAME=${NUTTX_TARNAME}.gz
|
||||
APPS_ZIPNAME=${APPS_TARNAME}.gz
|
||||
|
||||
# Prepare the nuttx directory -- Remove editor garbage
|
||||
|
||||
find ${TRUNKDIR} -name '*~' -exec rm -f '{}' ';' || \
|
||||
{ echo "Removal of emacs garbage failed!" ; exit 1 ; }
|
||||
find ${TRUNKDIR} -name '*.swp' -exec rm -f '{}' ';' || \
|
||||
{ echo "Removal of VI garbage failed!" ; exit 1 ; }
|
||||
|
||||
# Make sure that versioned copies of the certain files are in place
|
||||
|
||||
cd ${NUTTX}/Documentation || \
|
||||
{ echo "Failed to cd to ${NUTTX}/Documentation" ; exit 1 ; }
|
||||
|
||||
cp -f ../TODO TODO.txt
|
||||
cp -f ../ChangeLog ChangeLog.txt
|
||||
|
||||
# Write a version file into the NuttX directoy. The syntax of file is such that it
|
||||
# may be sourced by a bash script or included by a Makefile.
|
||||
|
||||
VERSIONSH=${NUTTX}/tools/version.sh
|
||||
if [ ! -x "${VERSIONSH}" ]; then
|
||||
echo "No executable script was found at: ${VERSIONSH}"
|
||||
exit 1
|
||||
fi
|
||||
${VERSIONSH} -v ${VERSION} ${NUTTX}/.version || \
|
||||
{ echo "${VERSIONSH} failed"; cat ${NUTTX}/.version; exit 1; }
|
||||
chmod 755 ${NUTTX}/.version
|
||||
|
||||
# Perform a full clean for the distribution
|
||||
|
||||
cd ${TRUNKDIR} || \
|
||||
{ echo "Failed to cd to ${TRUNKDIR}" ; exit 1 ; }
|
||||
|
||||
make -C ${NUTTX} distclean
|
||||
|
||||
# Remove any previous tarballs
|
||||
|
||||
if [ -f ${NUTTX_TARNAME} ] ; then
|
||||
echo "Removing ${TRUNKDIR}/${NUTTX_TARNAME}"
|
||||
rm -f ${NUTTX_TARNAME} || \
|
||||
{ echo "rm ${NUTTX_TARNAME} failed!" ; exit 1 ; }
|
||||
fi
|
||||
|
||||
if [ -f ${NUTTX_ZIPNAME} ] ; then
|
||||
echo "Removing ${TRUNKDIR}/${NUTTX_ZIPNAME}"
|
||||
rm -f ${NUTTX_ZIPNAME} || \
|
||||
{ echo "rm ${NUTTX_ZIPNAME} failed!" ; exit 1 ; }
|
||||
fi
|
||||
|
||||
if [ -f ${APPS_TARNAME} ] ; then
|
||||
echo "Removing ${TRUNKDIR}/${APPS_TARNAME}"
|
||||
rm -f ${APPS_TARNAME} || \
|
||||
{ echo "rm ${APPS_TARNAME} failed!" ; exit 1 ; }
|
||||
fi
|
||||
|
||||
if [ -f ${APPS_ZIPNAME} ] ; then
|
||||
echo "Removing ${TRUNKDIR}/${APPS_ZIPNAME}"
|
||||
rm -f ${APPS_ZIPNAME} || \
|
||||
{ echo "rm ${APPS_ZIPNAME} failed!" ; exit 1 ; }
|
||||
fi
|
||||
|
||||
# Then tar and zip-up the directories
|
||||
|
||||
cd ${TRUNKDIR} || \
|
||||
{ echo "Failed to cd to ${TRUNKDIR}" ; exit 1 ; }
|
||||
|
||||
${TAR} ${NUTTX_TARNAME} nuttx-${VERSION} || \
|
||||
{ echo "tar of ${NUTTX_TARNAME} failed!" ; exit 1 ; }
|
||||
${ZIP} ${NUTTX_TARNAME} || \
|
||||
{ echo "zip of ${NUTTX_TARNAME} failed!" ; exit 1 ; }
|
||||
|
||||
${TAR} ${APPS_TARNAME} apps-${VERSION} || \
|
||||
{ echo "tar of ${APPS_TARNAME} failed!" ; exit 1 ; }
|
||||
${ZIP} ${APPS_TARNAME} || \
|
||||
{ echo "zip of ${APPS_TARNAME} failed!" ; exit 1 ; }
|
||||
|
||||
cd ${NUTTX}
|
||||
|
||||
Reference in New Issue
Block a user