Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CxcExampleSetup.sh
#!/bin/bash
# Author: hsur
# License: BSD 2-clause
wget http://cxc.sapid.org/downloads/CX-Checker_1.3.0.jar
cat > default.xml <<'EOS'
<?xml version="1.0" encoding="UTF-8"?>
<checker>
<module name="org.sapid.checker.rule.XPathChecker">
<param name="src" value="Misra56.xml"/>
</module>
</checker>
EOS
cat > Misra56.xml <<'EOS'
<?xml version="1.0" encoding="UTF-8"?>
<rules>
<oneRule>
<level>5</level>
<content>misra-56</content>
<xpath>//kw[text() = "goto"]</xpath>
<condition>prohibit</condition>
</oneRule>
</rules>
EOS
cat > main.c <<'EOS'
#include <stdio.h>
int main() {
goto hoge;
printf("foo\n");
hoge:
printf("bar\n");
}
EOS
cat > Makefile <<'EOS'
CC = gcc
CFLAGS = -O2
PROGRAM = myprog
SRC = main.c
all: $(PROGRAM)
$(PROGRAM): $(SRC)
$(CC) $(CFLAGS) $(SRC) -o $(PROGRAM)
cxc:
sdb4 $(CFLAGS) $(SRC) -o $(PROGRAM)
spdMkCXModel -t -sdbD SDB
java org.sapid.checker.main.Main $(SRC) default.xml
clean:; rm -f *.o *~ $(PROGRAM) ; rm -rf SDB/
EOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.