mirror of
https://github.com/golang/go
synced 2024-11-26 13:08:08 -07:00
new approach for generating sysimport.c
(renamed to avoid any conflict with old p4 copies). this approach doesn't require auto-generating files also kept in p4, so it should be easier on go users who don't sync very often. this approach will be more work for go developers: builtin.c needs to be copied to builtin.c.boot in p4 as new functions are added. mkbuiltin does this for certain $USERs to help us remember. R=r DELTA=343 (176 added, 162 deleted, 5 changed) OCL=25803 CL=25805
This commit is contained in:
parent
681299a444
commit
af678a593d
@ -26,7 +26,7 @@ OFILES=\
|
||||
mparith1.$O\
|
||||
mparith2.$O\
|
||||
mparith3.$O\
|
||||
sysimport.$O\
|
||||
builtin.$O\
|
||||
compat.$O\
|
||||
|
||||
$(LIB): $(OFILES)
|
||||
@ -40,25 +40,11 @@ y.tab.h: $(YFILES)
|
||||
y.tab.c: y.tab.h
|
||||
test -f y.tab.c && touch y.tab.c
|
||||
|
||||
# the test here checks whether we have 6g at all.
|
||||
# if so, use it. if not, just use the sysimport.c we have.
|
||||
# this happens on fresh perforce checkouts where
|
||||
# sysimport.c ends up with an older time stamp
|
||||
# than sys.go (or unsafe.go or mksys.c).
|
||||
sysimport.c: sys.go unsafe.go mksys.c
|
||||
if test -x $(BIN)/6g; then \
|
||||
p4 open sysimport.c; \
|
||||
gcc -o mksys mksys.c; \
|
||||
6g sys.go; \
|
||||
6g unsafe.go; \
|
||||
./mksys sys >_sysimport.c && \
|
||||
./mksys unsafe >>_sysimport.c && \
|
||||
mv _sysimport.c sysimport.c; \
|
||||
elif test -f sysimport.c; then \
|
||||
touch sysimport.c; \
|
||||
fi
|
||||
builtin.c: sys.go unsafe.go mkbuiltin1.c mkbuiltin
|
||||
mkbuiltin >builtin.c || \
|
||||
(echo 'mkbuiltin failed; using bootstrap copy of builtin.c'; cp builtin.c.boot builtin.c)
|
||||
|
||||
clean:
|
||||
rm -f $(OFILES) *.6 enam.c 6.out a.out y.tab.h y.tab.c $(LIB) _sysimport.c
|
||||
rm -f $(OFILES) *.6 enam.c 6.out a.out y.tab.h y.tab.c $(LIB) mkbuiltin1 builtin.c _builtin.c
|
||||
|
||||
install: $(LIB)
|
||||
|
31
src/cmd/gc/mkbuiltin
Executable file
31
src/cmd/gc/mkbuiltin
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2009 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
set -e
|
||||
gcc -o mkbuiltin1 mkbuiltin1.c
|
||||
6g sys.go
|
||||
6g unsafe.go
|
||||
rm -f _builtin.c
|
||||
./mkbuiltin1 sys >_builtin.c
|
||||
./mkbuiltin1 unsafe >>_builtin.c
|
||||
|
||||
# If _builtin.c has changed vs builtin.c.boot,
|
||||
# check in the new change if being run by
|
||||
# one of the people who tends to work on
|
||||
# the compiler. This makes sure that changes
|
||||
# don't get forgotten, without causing problems
|
||||
# in end user Go repositories.
|
||||
case "$USER" in
|
||||
ken | r | rsc)
|
||||
if ! cmp _builtin.c builtin.c.boot
|
||||
then
|
||||
p4 open builtin.c.boot
|
||||
cp _builtin.c builtin.c.boot
|
||||
fi
|
||||
esac
|
||||
|
||||
cat _builtin.c
|
||||
rm -f _builtin.c
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Extract import data from sys.6 and generate C string version.
|
||||
// Compile .go file, import data from .6 file, and generate C string version.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -18,7 +18,7 @@ main(int argc, char **argv)
|
||||
char buf[1024], initfunc[1024], *p, *q;
|
||||
|
||||
if(argc != 2) {
|
||||
fprintf(stderr, "usage: sys sys\n");
|
||||
fprintf(stderr, "usage: mkbuiltin1 sys\n");
|
||||
fprintf(stderr, "in file $1.6 s/PACKAGE/$1/\n");
|
||||
exit(1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user