Merge pull request #3310 from robinsonb5-PRs/master
[yosys.git] / misc / create_vcxsrc.sh
1 #!/bin/bash
2
3 set -ex
4 vcxsrc="$1-$2"
5 yosysver="$2"
6 gitsha="$3"
7
8 rm -rf YosysVS-Tpl-v2.zip YosysVS
9 wget https://yosyshq.net/yosys/nogit/YosysVS-Tpl-v2.zip
10 wget https://www.zlib.net/fossils/zlib-1.2.11.tar.gz
11
12 unzip YosysVS-Tpl-v2.zip
13 rm -f YosysVS-Tpl-v2.zip
14 tar xvfz zlib-1.2.11.tar.gz
15
16 mv YosysVS "$vcxsrc"
17 mkdir -p "$vcxsrc"/yosys
18 mkdir -p "$vcxsrc"/yosys/libs/zlib
19 mv zlib-1.2.11/* "$vcxsrc"/yosys/libs/zlib/.
20 rm -rf zlib-1.2.11
21 pushd "$vcxsrc"/yosys
22 ls libs/zlib/*.c | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep '^[^/]' >> ../../srcfiles.txt
23 popd
24 {
25 n=$(grep -B999 '<ItemGroup>' "$vcxsrc"/YosysVS/YosysVS.vcxproj | wc -l)
26 head -n$n "$vcxsrc"/YosysVS/YosysVS.vcxproj
27 egrep '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClInclude Include="../yosys/&" />,'
28 egrep -v '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClCompile Include="../yosys/&" />,'
29 echo '<ClCompile Include="../yosys/kernel/version.cc" />'
30 tail -n +$((n+1)) "$vcxsrc"/YosysVS/YosysVS.vcxproj
31 } > "$vcxsrc"/YosysVS/YosysVS.vcxproj.new
32
33 mv "$vcxsrc"/YosysVS/YosysVS.vcxproj.new "$vcxsrc"/YosysVS/YosysVS.vcxproj
34
35 mkdir -p "$vcxsrc"/yosys
36 tar -cf - -T srcfiles.txt | tar -xf - -C "$vcxsrc"/yosys
37 cp -r share "$vcxsrc"/
38
39 echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys" \
40 "$yosysver (git sha1 $gitsha, Visual Studio)\"; }" > "$vcxsrc"/yosys/kernel/version.cc
41
42 cat > "$vcxsrc"/readme-git.txt << EOT
43 Want to use a git working copy for the yosys source code?
44 Open "Git Bash" in this directory and run:
45
46 mv yosys yosys.bak
47 git clone https://github.com/YosysHQ/yosys.git yosys
48 cd yosys
49 git checkout -B master $(git rev-parse HEAD | cut -c1-10)
50 unzip ../genfiles.zip
51 EOT
52
53 cat > "$vcxsrc"/readme-abc.txt << EOT
54 Yosys is using "ABC" for gate-level optimizations and technology
55 mapping. Download yosys-win32-mxebin-$yosysver.zip and copy the
56 following files from it into this directory:
57
58 pthreadVC2.dll
59 yosys-abc.exe
60 EOT
61
62 sed -i 's/$/\r/; s/\r\r*/\r/g;' "$vcxsrc"/YosysVS/YosysVS.vcxproj "$vcxsrc"/readme-git.txt "$vcxsrc"/readme-abc.txt
63