Skip to content

Instantly share code, notes, and snippets.

@hsur
Last active February 22, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsur/19ad681df53efaf0a8c9658c5e349222 to your computer and use it in GitHub Desktop.
Save hsur/19ad681df53efaf0a8c9658c5e349222 to your computer and use it in GitHub Desktop.
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