OLD | NEW |
1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 BuildStep() { | 5 BuildStep() { |
6 # Nothing to build. | 6 # Nothing to build. |
7 return | 7 return |
8 } | 8 } |
9 | 9 |
10 CreateMingnPackage() { | |
11 local package_name="$1.${2:-${NACL_ARCH}}" | |
12 echo "CreateMingnPackage ${package_name}" | |
13 local stamp="$(date)" | |
14 MakeDir mingn/stamp | |
15 echo "INSTALLED=\"${stamp}\"" > "mingn/stamp/${package_name}" | |
16 MakeDir ${PUBLISH_DIR}/tarballs | |
17 LogExecute rm -f ${PUBLISH_DIR}/tarballs/${package_name}.zip | |
18 LogExecute zip -qr ${PUBLISH_DIR}/tarballs/${package_name}.zip mingn | |
19 MakeDir "${PUBLISH_DIR}/stamp" | |
20 echo "LATEST=\"${stamp}\"" > "${PUBLISH_DIR}/stamp/${package_name}" | |
21 } | |
22 | |
23 InstallStep() { | 10 InstallStep() { |
24 MakeDir ${PUBLISH_DIR} | 11 MakeDir ${INSTALL_DIR}${PREFIX} |
25 | 12 ChangeDir ${INSTALL_DIR}${PREFIX} |
26 # Create another archive which contains executables. | |
27 MakeDir ${SRC_DIR}/${NACL_ARCH}/bin | |
28 ChangeDir ${SRC_DIR}/${NACL_ARCH}/bin | |
29 | |
30 local BINUTILS_DIR=${NACL_PACKAGES_PUBLISH}/binutils/${TOOLCHAIN} | |
31 local GCC_DIR=${NACL_PACKAGES_PUBLISH}/gcc/${TOOLCHAIN} | |
32 | |
33 local TOOLCHAIN_OUT_DIR=mingn/toolchain/nacl_x86_glibc | |
34 local bin_dir=${TOOLCHAIN_OUT_DIR}/bin | |
35 local libexec_dir=${TOOLCHAIN_OUT_DIR}/libexec/gcc/x86_64-nacl/4.4.3 | |
36 | |
37 MakeDir ${bin_dir} | |
38 MakeDir ${libexec_dir} | |
39 BINARIES="\ | |
40 ${GCC_DIR}/*_${NACL_ARCH}.nexe \ | |
41 ${BINUTILS_DIR}/*_${NACL_ARCH}.nexe" | |
42 | |
43 for binary in ${BINARIES}; do | |
44 name=$(basename ${binary} | sed "s/_${NACL_ARCH}.nexe//") | |
45 if [ ${name} = "cc1" -o ${name} = "cc1plus" -o ${name} = "collect2" ]; then | |
46 LogExecute cp ${binary} ${libexec_dir}/${name} | |
47 else | |
48 LogExecute cp ${binary} ${bin_dir}/${name} | |
49 fi | |
50 done | |
51 | |
52 CreateMingnPackage base | |
53 | 13 |
54 # Create an archive which contains include files and shared objects. | 14 # Create an archive which contains include files and shared objects. |
55 MakeDir ${SRC_DIR}/lib | |
56 ChangeDir ${SRC_DIR}/lib | |
57 | 15 |
58 # Copy files from $NACL_SDK_ROOT to the package. | 16 # Copy files (for now just headers) from $NACL_SDK_ROOT to the package. |
59 local dirs=" | 17 local dirs=" |
60 toolchain/${OS_SUBDIR}_x86_glibc/lib/gcc/x86_64-nacl | |
61 toolchain/${OS_SUBDIR}_x86_glibc/x86_64-nacl/lib32 | |
62 toolchain/${OS_SUBDIR}_x86_glibc/x86_64-nacl/lib | |
63 toolchain/${OS_SUBDIR}_x86_glibc/x86_64-nacl/include | 18 toolchain/${OS_SUBDIR}_x86_glibc/x86_64-nacl/include |
64 " | 19 " |
65 for d in ${dirs}; do | 20 for d in ${dirs}; do |
66 local o=$(echo mingn/${d} | sed "s/${OS_SUBDIR}_/nacl_/") | 21 local o=$(echo ${d} | sed "s/toolchain\/${OS_SUBDIR}_x86_glibc\///") |
67 echo "Copying libs from: ${d} -> ${o}" | 22 echo "Copying libs from: ${d} -> ${o}" |
68 MakeDir ${o} | 23 MakeDir ${o} |
69 if [ -d ${NACL_SDK_ROOT}/${d} ]; then | 24 if [ -d ${NACL_SDK_ROOT}/${d} ]; then |
70 cp -R ${NACL_SDK_ROOT}/${d} $(dirname ${o}) | 25 cp -R ${NACL_SDK_ROOT}/${d} $(dirname ${o}) |
71 else | 26 else |
72 MakeDir ${o} | 27 MakeDir ${o} |
73 fi | 28 fi |
74 done | 29 done |
75 | 30 |
| 31 # Create libmingn.so ldscripts. |
| 32 MakeDir lib |
| 33 cat <<EOF > lib/libmingn.so |
| 34 GROUP(-lcli_main -lnacl_spawn -lppapi_simple -lnacl_io -lppapi -lstdc++ -lm) |
| 35 EXTERN(PSUserMainGet) |
| 36 EOF |
| 37 |
76 # Remove unnecessary files to reduce the size of the archive. | 38 # Remove unnecessary files to reduce the size of the archive. |
77 LogExecute rm -f ${TOOLCHAIN_OUT_DIR}/x86_64-nacl/lib/32 | 39 LogExecute rm -fr x86_64-nacl/lib*/{gconv,libgfortran*} |
78 LogExecute rm -fr ${TOOLCHAIN_OUT_DIR}/x86_64-nacl/lib*/{gconv,libgfortran*} | 40 # These headers gome from the 'gcc' package |
| 41 LogExecute rm -fr x86_64-nacl/include/c++/ |
| 42 # These scripts come from the 'binutils' package |
| 43 LogExecute rm -fr x86_64-nacl/lib/ldscripts/ |
79 | 44 |
80 # Resolve all symlinks as nacl_io does not support symlinks. | 45 # Resolve all symlinks as nacl_io does not support symlinks. |
81 for i in $(find mingn -type l); do | 46 for i in $(find . -type l); do |
82 if [ ! -d ${i} ]; then | 47 if [ ! -d ${i} ]; then |
83 cp ${i} ${i}.tmp | 48 cp ${i} ${i}.tmp |
84 rm ${i} | 49 rm ${i} |
85 mv ${i}.tmp ${i} | 50 mv ${i}.tmp ${i} |
86 fi | 51 fi |
87 done | 52 done |
88 | 53 |
89 # Create a directory for additional libraries. | 54 # Remove shared objects which are symlinked after we resolve them. |
90 for arch in i686 x86_64; do | 55 find . -name '*.so.*.*' -exec rm -f {} \; |
91 local usr_lib_dir=${TOOLCHAIN_OUT_DIR}/${arch}-nacl/usr/lib | |
92 local usr_lib_ports=${NACL_TOOLCHAIN_ROOT}/${arch}-nacl/usr/lib | |
93 | 56 |
94 mkdir -p ${usr_lib_dir} | 57 MakeDir lib |
95 mkdir -p ${usr_lib_dir}/debug | 58 # Copy core libraries |
| 59 LogExecute cp -r ${NACL_SDK_LIB}/*.a lib/ |
| 60 LogExecute cp -r ${NACL_SDK_LIB}/*.o lib/ |
96 | 61 |
97 # Copy libz, libncurses, libnacl-spawn, and libcli_main. | 62 # Copy SDK libs |
98 if ! cp -f \ | 63 LogExecute cp -r ${NACL_SDK_LIBDIR}/*.a lib/ |
99 ${usr_lib_ports}/libz.so* \ | 64 LogExecute rm -fr lib/libgtest.*a |
100 ${usr_lib_ports}/libncurses.so* \ | 65 LogExecute rm -fr lib/libgmock.*a |
101 ${usr_lib_ports}/libcli_main.a \ | |
102 ${usr_lib_ports}/libnacl_spawn.* \ | |
103 ${usr_lib_dir}; then | |
104 # They may not exist when we are building only for a single arch. | |
105 if [ ${NACL_ARCH} = ${arch} ]; then | |
106 echo "Failed to copy ${usr_lib_ports}" | |
107 exit 1 | |
108 fi | |
109 fi | |
110 | |
111 local arch_alt=${arch} | |
112 if [ ${arch_alt} = "i686" ]; then | |
113 arch_alt="x86_32" | |
114 local ld_format="elf32-i386-nacl" | |
115 else | |
116 local ld_format="elf64-x86-64-nacl" | |
117 fi | |
118 | |
119 # Merge libraries made from native_client_sdk so that you do not | |
120 # need to specify -L option for them. | |
121 cp ${NACL_SDK_ROOT}/lib/glibc_${arch_alt}/Release/* ${usr_lib_dir} | |
122 # But also copy the debug ones. | |
123 cp ${NACL_SDK_ROOT}/lib/glibc_${arch_alt}/Debug/* ${usr_lib_dir}/debug | |
124 | |
125 # Create libmingn.so ldscripts. | |
126 cat <<EOF > ${TOOLCHAIN_OUT_DIR}/${arch}-nacl/usr/lib/libmingn.so | |
127 OUTPUT_FORMAT(${ld_format}) | |
128 GROUP(-lcli_main -lnacl_spawn -lppapi_simple -lnacl_io -lppapi -lstdc++ -lm) | |
129 EXTERN(PSUserMainGet) | |
130 EOF | |
131 done | |
132 | 66 |
133 # Copy in SDK includes. | 67 # Copy in SDK includes. |
134 LogExecute cp -r ${NACL_SDK_ROOT}/include mingn/ | 68 LogExecute cp -r ${NACL_SDK_ROOT}/include ./ |
135 | 69 LogExecute rm -fr include/gtest |
136 # Remove shared objects which are symlinked after we resolve them. | 70 LogExecute rm -fr include/gmock |
137 find mingn -name '*.so.*.*' -exec rm -f {} \; | |
138 | |
139 # Modify GCC's specs file. E.g., | |
140 # /path/to/nacl_sdk/pepper_canary/toolchain/linux_x86_glibc | |
141 # => /mingn/toolchain/nacl_x86_glibc. | |
142 sed -i.bak 's@/\S*/pepper_[^/]*/toolchain/[^/]*_x86_glibc@/mingn/toolchain/nac
l_x86_glibc@g' \ | |
143 ${TOOLCHAIN_OUT_DIR}/lib/gcc/x86_64-nacl/4.4.3/specs | |
144 | |
145 CreateMingnPackage lib all | |
146 } | 71 } |
OLD | NEW |