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 to use. It corresponds 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._build.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 is bootstrap level $p"
45 rm -r c_src 2> /dev/null
48 sed -n '/^ *.nit_compile/{s!\\$!!;p}' .nit_compile3/nitc._build.sh | while read -r file; do
50 [ -r ${file%.c}.h ] && cp ${file%.c}.h c_src
52 sed "s|.nit_compile${p}|.|g;s|/\[a-z\]+/../|/|g;s|nitc_${p}|nitc|" .nit_compile${p}/nitc._build.sh > c_src/nitc._build.sh
53 chmod +x c_src/nitc._build.sh
54 cp ../c_src/Makefile ../c_src/README c_src