2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Copyright 2008 Jean Privat <jean@pryen.org>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # mkcsrc - generate a new c_src directory from a current nitc bootstrap
23 # transform a bootstrap result (generated by the nc tool) into a new
24 # c_src in the current directory (previous one will be errased).
25 # One c_src generated, you can replace the old one in the root.
26 # Before commiting, do not forget to:
27 # * verify any regression
28 # * add/remove files in c_src
30 # number is the bootstrap level (prefix) to use. It correspond to the nc
31 # level. By default, the lastest generated nitc is used
36 if [ "x$p" = "x" ]; then
37 p=`ls .nit_compile/nitc*.sh -t | head -1 | sed 's!\.nit_compile/nitc\.\(.*\)_build\.sh!\1!'`
38 if [ "x$p" = "x" ]; then
39 echo "No generated nitc"
42 echo "Lastest generated nitc uses prefix $p"
45 rm -r c_src 2> /dev/null
48 sed -n "s|.nit_compile/\\(.*\\).${p}_sep.c.*|\\1|p" .nit_compile/nitc.${p}_build.sh | while read -r file; do
50 sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.c" > c_src/${file}._sep.c
51 sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.h" > c_src/${file}._sep.h
53 sed "/include/s/.${p}_/._/" .nit_compile/nitc.${p}_tables.c > c_src/nitc._tables.c
54 sed "s|.nit_compile|.|g;s|../bin/../|../|g;s/.${p}_/._/g;s|nitc_${p}|nitc|" .nit_compile/nitc.${p}_build.sh > c_src/nitc._build.sh
55 chmod +x c_src/nitc._build.sh
56 cp ../c_src/Makefile ../c_src/README c_src