Add tools/cmpconfig.c to compare to configuration files

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4592 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-04-11 23:06:30 +00:00
parent f873ab55b6
commit 940bdc50fb
10 changed files with 636 additions and 24 deletions

View file

@ -2635,10 +2635,14 @@
drivers/Kconfig, drivers/mtd/Kconfig, drivers/input/Kconfig
drivers/analog/Kconfig, drivers/lcd/Kconfig: Updated kernel
configuration support provided by Lzyy.
* Kconfig: Many more Kconfig updates (no longer tracking in the ChangeLog)
* arch/arm/src/Makefile, arch/x86/src/Makefile, arch/avr/src/Makefile,
arch/mips/src/Makefile, arch/sim/src/Makefile, arch/hc/src/Makefile,
arch/sh/src/Makefile: The libgcc.a in newer versions of GCC now
have an dependency on an external implementation of export(). This
required modification to the Makefiles that do the final link: Now
libgcc.a must be included within the group of libraries that are
search recursively.
search recursively.
* arch/arm/srm/stm32/stm32_otgfsdev.c: A USB OTG FS device-side driver
for the STM32 F4 (and maybe F2 and F1 connectivity line).
* tools/cmpconfig.c: A tool for comparing two configuration files.

View file

@ -249,12 +249,9 @@ menu "Device Drivers"
source drivers/Kconfig
endmenu
menuconfig NET
bool "Networking support"
default n
if NET
menu "Networking support"
source net/Kconfig
endif
endmenu
menu "File systems"
source fs/Kconfig

View file

@ -605,5 +605,5 @@ ifneq ($(APPDIR),)
endif
menuconfig:
APPSDIR=${CONFIG_APPS_DIR} mconf Kconfig
@APPSDIR=${CONFIG_APPS_DIR} mconf Kconfig

View file

@ -1153,7 +1153,8 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
usbtrace(TRACE_COMPLETE(privep->epphy), privreq->req.xfrd);
stm32_req_complete(privep, OK);
privep->zlp = false;
/* The endpoint is no longer transferring data */
privep->active = false;
}
}

View file

@ -2,3 +2,276 @@
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config NET
bool "Networking support"
default n
---help---
Enable or disable all network features
if NET
config NET_NOINTS
bool "Not interrupt driven"
default n
---help---
NET_NOINT indicates that uIP not called from the interrupt level.
If NET_NOINTS is defined, critical sections will be managed with semaphores;
Otherwise, it assumed that uIP will be called from interrupt level handling
and critical sections will be managed by enabling and disabling interrupts.
config NET_MULTIBUFFER
bool "Use multiple device-side I/O buffers"
default n
---help---
Traditionally, uIP has used a single buffer for all incoming and
outgoing traffic. If this configuration is selected, then the
driver can manage multiple I/O buffers and can, for example,
be filling one input buffer while sending another output buffer.
Or, as another example, the driver may support queuing of concurrent
input/ouput and output transfers for better performance.
config NET_IPv6
bool "IPv6"
default n
---help---
Build in support for IPv6. Not fully implemented.
config NSOCKET_DESCRIPTORS
int "Number of socket descriptor"
default 8
---help---
Maximum number of socket descriptors per task/thread.
config NET_NACTIVESOCKETS
int "Max socket operations"
---help---
Maximum number of concurrent socket operations (recv, send, etc.).
Default: NET_TCP_CONNS+NET_UCP_CONNS
config NET_SOCKOPTS
bool "Socket options"
default n
---help---
Enable or disable support for socket options
config NET_BUFSIZE
int "Network packet size"
default 562 if !NET_TCP && NET_UDP && !NET_SLIP
default 420 if NET_TCP && !NET_UDP && !NET_SLIP
default 296 if NET_SLIP
---help---
uIP buffer size. Default: 562
config NET_TCPURGDATA
bool "Urgent data"
default n
---help---
Determines if support for TCP urgent data notification should be
compiled in. Urgent data (out-of-band data) is a rarely used TCP feature
that is very seldom would be required.
config NET_TCP
bool "TCP/IP Networking"
default n
---help---
TCP support on or off
endif
if NET_TCP
config NET_TCP_CONNS
int "Number of TCP/IP connections"
default 8
---help---
Maximum number of TCP/IP connections (all tasks)
config NET_MAX_LISTENPORTS
bool "Number of listening ports"
default n
---help---
Maximum number of listening TCP/IP ports (all tasks)
config NET_TCP_READAHEAD_BUFSIZE
bool "TCP/IP read-ahead buffer size"
default 562
---help---
Size of TCP/IP read-ahead buffers
config NET_NTCP_READAHEAD_BUFFERS
int "Number of TCP/IP read-ahead buffers"
default 8
---help---
Number of TCP/IP read-ahead buffers (may be zero)
config NET_TCPBACKLOG
bool "TCP/IP backlog support"
default n
---help---
Incoming connections pend in a backlog until accept() is called.
The size of the backlog is selected when listen() is called.
endif
config NET_UDP
bool "UDP Networking"
default n
depends on NET
---help---
Enable or disable UDP networking support.
if NET_UDP
config NET_UDP_CHECKSUMS
bool "UDP checksums"
default n
---help---
Enable/disable UDP checksum support
config NET_UDP_CONNS
int "Number of UDP sockets"
default 8
---help---
The maximum amount of open concurrent UDP sockets
endif
config NET_ICMP
bool "ICMP networking support"
default n
depends on NET
---help---
Enable minimal ICMP support. Includes built-in support
for sending replies to received ECHO (ping) requests.
if NET_ICMP
config NET_ICMP_PING
bool "ICMP ping interfaces"
default n
---help---
Provide interfaces to support application level support for
for sending ECHO (ping) requests and associating ECHO replies.
config NET_PINGADDRCONF
bool "Ping address configuration"
default n
---help---
Use "ping" packet for setting IP address
endif
config NET_IGMP
bool "IGMPv2 clientsupport"
default n
depends on NET
---help---
Enable IGMPv2 client support.
if NET_IGMP
config PREALLOC_IGMPGROUPS
int "Number of pre-allocated IGMP groups"
default 4
---help---
Pre-allocated IGMP groups are used only if needed from interrupt
level group created (by the IGMP server). Default: 4.
endif
if NET
config NET_STATISTICS
bool "Collect network statistics"
default n
---help---
uIP statistics on or off
config NET_RECEIVE_WINDOW
int "Receive window size"
---help---
The size of the advertised receiver's window
config NET_ARPTAB_SIZE
int "ARP table size"
default 16
---help---
The size of the ARP table
config NET_ARP_IPIN
bool "ARP address harvesting"
default n
---help---
Harvest IP/MAC address mappings from the ARP table
from incoming IP packets.
endif
if NET_UDP
config NET_BROADCAST
bool "UDP broadcast Rx support"
default n
---help---
Incoming UDP broadcast support
endif
if NET
config NET_MULTICAST
bool "Multi-cast Tx support"
default n
---help---
Outgoing multi-cast address support
config NET_FWCACHE_SIZE
int "FW cache size"
---help---
Number of packets to remember when looking for duplicates
config NET_SLIP
bool "SLIP support"
default n
---help---
Enables building of the SLIP driver. SLIP requires
at least one IP protocol selected and the following additional
network settings: NET_NOINTS and NET_MULTIBUFFER.
NET_BUFSIZE *must* be set to 296. Other optional configuration
settings that affect the SLIP driver: NET_STATISTICS.
Default: Ethernet
SLIP supports point-to-point IP communications over a serial port.
The default data link layer for uIP is Ethernet. If NET_SLIP is
defined in the NuttX configuration file, then SLIP will be supported.
The basic differences between the SLIP and Ethernet configurations is
that when SLIP is selected:
* The link level header (that comes before the IP header) is omitted.
* All MAC address processing is suppressed.
* ARP is disabled.
If NET_SLIP is not selected, then Ethernet will be used (there is
no need to define anything special in the configuration file to use
Ethernet -- it is the default).
endif
if NET_SLIP
config SLIP_NINTERFACES
int "Number of SLIP interfaces"
default 1
---help---
Selects the number of physical SLIP
interfaces to support.
Default: 1
config SLIP_STACKSIZE
int "SLIP stack size"
default 2048
---help---
Select the stack size of the SLIP RX and TX tasks. Default: 2048
config SLIP_DEFPRIO
int "SLIP priority"
default 128
---help---
The priority of the SLIP RX and TX tasks. Default: 128
endif

View file

@ -1,8 +1,8 @@
############################################################################
# Makefile.host
#
# Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
# Copyright (C) 2007, 2008, 2011-2012 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
@ -46,6 +46,11 @@ CFLAGS = -O2 -Wall -I.
mkconfig: mkconfig.c cfgparser.c
@gcc $(CFLAGS) -o mkconfig mkconfig.c cfgparser.c
# cmpconfig - Compare the contents of two configuration files
cmpconfig: cmpconfig.c
@gcc $(CFLAGS) -o cmpconfig cmpconfig.c
# mkversion - Convert a .version file into a C version.h file
mkversion: mkconfig.c cfgparser.c

View file

@ -19,7 +19,7 @@ configure.sh
mkconfig.c, cfgparser.c, and cfgparser.h
This is C file that is used to build mkconfig program. The mkconfig
These are Cs file that are 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
@ -31,6 +31,11 @@ mkconfig.c, cfgparser.c, and cfgparser.h
into include/nuttx/config.h. config.h is a another version of the
NuttX configuration that can be included by C files.
cmdconfig.c
This C file can be used to build a utility for comparing two NuttX
configuration files.
mkexport.sh and Makefile.export
These implement part of the top-level Makefile's 'export' target. That
@ -136,10 +141,10 @@ bdf-convert.c
genfontsources:
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
@$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES)
@$(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)
@$(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.
@ -147,10 +152,10 @@ bdf-convert.c
NXFONTS_FONTID=2:
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
endif
ifeq ($(CONFIG_NXFONT_MYFONT),y)
NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
endif
7. nuttx/graphics/nxfonts/Makefile.sources. This is the Makefile used
@ -161,12 +166,12 @@ bdf-convert.c
was used in nuttx/graphics/nxfonts/Make.defs):
ifeq ($(NXFONTS_FONTID),1)
NXFONTS_PREFIX := g_sans23x27_
GEN_CSRC = nxfonts_bitmaps_sans23x27.c
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
NXFONTS_PREFIX := g_myfont_
GEN_CSRC = nxfonts_bitmaps_myfont.c
endif
8. graphics/nxfonts/nxfonts_bitmaps.c. This is the file that contains
@ -212,8 +217,12 @@ bdf-convert.c
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.
the mkconfig.c C file, the cmpconfig program from cmpconfig.c C file
the mkversion program from the mkconfig.c C file, or the mksyscall
program from the mksyscall.c file. Usage:
cd tools/
make -f Makefile.host <program>
mkromfsimg.sh

View file

@ -1,8 +1,8 @@
/****************************************************************************
* tools/cfgpaser.c
*
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions

323
tools/cmpconfig.c Normal file
View file

@ -0,0 +1,323 @@
/****************************************************************************
* tools/cmpconfig.c
*
* Copyright (C) 2012 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct variable_s
{
struct variable_s *flink;
char *var;
char *val;
char storage[1];
};
/****************************************************************************
* Private Functions
****************************************************************************/
static void show_usage(const char *progname)
{
fprintf(stderr, "USAGE: %s <config1> <config2>\n", progname);
exit(EXIT_FAILURE);
}
static char *skip_space(char *ptr)
{
while (*ptr && isspace((int)*ptr)) ptr++;
return ptr;
}
static char *read_line(FILE *stream, char *line, int len)
{
char *ptr;
for (;;)
{
line[len-1] = '\0';
if (!fgets(line, len, stream))
{
return NULL;
}
else
{
ptr = skip_space(line);
if (*ptr && *ptr != '#' && *ptr != '\n')
{
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 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';
}
}
}
static void parse_file(FILE *stream, struct variable_s **list)
{
char line[10242];
struct variable_s *curr;
struct variable_s *prev;
struct variable_s *next;
char *varname;
char *varval;
char *ptr;
do
{
ptr = read_line(stream, line, 1024);
if (ptr)
{
parse_line(ptr, &varname, &varval);
if (varname)
{
int varlen = strlen(varname) + 1;
int vallen = 0;
if (varval)
{
vallen = strlen(varval) + 1;
}
curr = (struct variable_s *)malloc(sizeof(struct variable_s) + varlen + vallen - 1);
if (curr)
{
curr->var = &curr->storage[0];
strcpy(curr->var, varname);
curr->val = NULL;
if (varval)
{
curr->val = &curr->storage[varlen];
strcpy(curr->val, varval);
}
}
prev = 0;
next = *list;
while (next && strcmp(next->var, curr->var) <= 0)
{
prev = next;
next = next->flink;
}
if (prev)
{
prev->flink = curr;
}
else
{
*list = curr;
}
curr->flink = next;
}
}
}
while (ptr);
}
static void compare_variables(struct variable_s *list1, struct variable_s *list2)
{
char *varval1;
char *varval2;
while (list1 || list2)
{
if (list1->val)
{
varval1 = list1->val;
}
else
{
varval1 = "<NULL>";
}
if (list2->val)
{
varval2 = list2->val;
}
else
{
varval2 = "<NULL>";
}
if (!list1)
{
printf("file1:\n");
printf("file2: %s=%s\n\n", list2->var, varval2);
list2 = list2->flink;
}
else if (!list2)
{
printf("file1: %s=%s\n", list1->var, varval1);
printf("file2:\n\n");
list1 = list1->flink;
}
else
{
int result = strcmp(list1->var, list2->var);
if (result < 0)
{
printf("file1: %s=%s\n", list1->var, varval1);
printf("file2:\n\n");
list1 = list1->flink;
}
else if (result > 0)
{
printf("file1:\n");
printf("file2: %s=%s\n\n", list2->var, varval2);
list2 = list2->flink;
}
else
{
int result = strcmp(varval1, varval2);
if (result != 0)
{
printf("file1: %s=%s\n", list1->var, varval1);
printf("file2: %s=%s\n\n", list2->var, varval2);
}
list1 = list1->flink;
list2 = list2->flink;
}
}
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, char **argv, char **envp)
{
struct variable_s *list1 = 0;
struct variable_s *list2 = 0;
FILE *stream1;
FILE *stream2;
if (argc != 3)
{
fprintf(stderr, "Unexpected number of arguments: %d\n\n", argc);
show_usage(argv[0]);
}
stream1 = fopen(argv[1], "r");
if (!stream1)
{
fprintf(stderr, "Failed to open %s for reading: %s\n\n",
argv[1], strerror(errno));
show_usage(argv[0]);
}
stream2 = fopen(argv[2], "r");
if (!stream2)
{
fprintf(stderr, "Failed to open %s for reading: %s\n\n",
argv[2], strerror(errno));
show_usage(argv[0]);
}
parse_file(stream1, &list1);
parse_file(stream2, &list2);
fclose(stream1);
fclose(stream2);
printf("Comparing:\n\n");
printf(" file1 = %s\n", argv[1]);
printf(" file2 = %s\n\n", argv[2]);
compare_variables(list1, list2);
return EXIT_SUCCESS;
}

View file

@ -88,7 +88,7 @@ int main(int argc, char **argv, char **envp)
exit(2);
}
stream= fopen(filepath, "r");
stream = fopen(filepath, "r");
if (!stream)
{
fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));