Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: ports/ninja/nacl.patch

Issue 1417223003: Switch from using 'nacl_main' to 'main' entry point (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/ninja/build.sh ('k') | ports/openssh/build.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff --git a/configure.py b/configure.py 1 diff --git a/configure.py b/configure.py
2 --- a/configure.py 2 --- a/configure.py
3 +++ b/configure.py 3 +++ b/configure.py
4 @@ -28,7 +28,9 @@ import string 4 @@ -28,7 +28,9 @@ import string
5 import subprocess 5 import subprocess
6 import sys 6 import sys
7 7
8 -sys.path.insert(0, 'misc') 8 -sys.path.insert(0, 'misc')
9 +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 9 +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
10 +sys.path.insert(0, os.path.join(SCRIPT_DIR, 'misc')) 10 +sys.path.insert(0, os.path.join(SCRIPT_DIR, 'misc'))
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return os.path.join('$builddir', filename) 56 return os.path.join('$builddir', filename)
57 def doc(filename): 57 def doc(filename):
58 @@ -263,6 +270,7 @@ def binary(name): 58 @@ -263,6 +270,7 @@ def binary(name):
59 return name 59 return name
60 60
61 n.variable('builddir', 'build') 61 n.variable('builddir', 'build')
62 +n.variable('srcdir', os.path.relpath(SCRIPT_DIR, os.getcwd())) 62 +n.variable('srcdir', os.path.relpath(SCRIPT_DIR, os.getcwd()))
63 n.variable('cxx', CXX) 63 n.variable('cxx', CXX)
64 if platform.is_msvc(): 64 if platform.is_msvc():
65 n.variable('ar', 'link') 65 n.variable('ar', 'link')
66 @@ -354,9 +362,12 @@ def shell_escape(str): 66 @@ -326,6 +334,8 @@ if platform.is_mingw():
67 ldflags.append('-static')
68 elif platform.is_solaris():
69 cflags.remove('-fvisibility=hidden')
70 +elif platform.is_nacl():
71 + cflags.remove('-fvisibility=hidden')
72 elif platform.is_msvc():
73 pass
74 else:
75 @@ -354,9 +364,12 @@ def shell_escape(str):
67 76
68 if 'CFLAGS' in configure_env: 77 if 'CFLAGS' in configure_env:
69 cflags.append(configure_env['CFLAGS']) 78 cflags.append(configure_env['CFLAGS'])
70 -n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags)) 79 -n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags))
71 if 'LDFLAGS' in configure_env: 80 if 'LDFLAGS' in configure_env:
72 ldflags.append(configure_env['LDFLAGS']) 81 ldflags.append(configure_env['LDFLAGS'])
73 +if 'LIBS' in configure_env: 82 +if 'LIBS' in configure_env:
74 + libs.append(configure_env['LIBS']) 83 + libs.append(configure_env['LIBS'])
75 + 84 +
76 +n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags)) 85 +n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags))
77 n.variable('ldflags', ' '.join(shell_escape(flag) for flag in ldflags)) 86 n.variable('ldflags', ' '.join(shell_escape(flag) for flag in ldflags))
78 n.newline() 87 n.newline()
79 88
80 @@ -403,10 +414,10 @@ objs = [] 89 @@ -403,10 +416,10 @@ objs = []
81 if platform.supports_ninja_browse(): 90 if platform.supports_ninja_browse():
82 n.comment('browse_py.h is used to inline browse.py.') 91 n.comment('browse_py.h is used to inline browse.py.')
83 n.rule('inline', 92 n.rule('inline',
84 - command='src/inline.sh $varname < $in > $out', 93 - command='src/inline.sh $varname < $in > $out',
85 + command='$srcdir/src/inline.sh $varname < $in > $out', 94 + command='$srcdir/src/inline.sh $varname < $in > $out',
86 description='INLINE $out') 95 description='INLINE $out')
87 n.build(built('browse_py.h'), 'inline', src('browse.py'), 96 n.build(built('browse_py.h'), 'inline', src('browse.py'),
88 - implicit='src/inline.sh', 97 - implicit='src/inline.sh',
89 + implicit=src('inline.sh'), 98 + implicit=src('inline.sh'),
90 variables=[('varname', 'kBrowsePy')]) 99 variables=[('varname', 'kBrowsePy')])
91 n.newline() 100 n.newline()
92 101
93 @@ -469,10 +480,11 @@ else: 102 @@ -469,10 +482,11 @@ else:
94 ninja_lib = n.build(built('libninja.a'), 'ar', objs) 103 ninja_lib = n.build(built('libninja.a'), 'ar', objs)
95 n.newline() 104 n.newline()
96 105
97 +# TODO(bradnelson): Upstream this fix. 106 +# TODO(bradnelson): Upstream this fix.
98 if platform.is_msvc(): 107 if platform.is_msvc():
99 - libs.append('ninja.lib') 108 - libs.append('ninja.lib')
100 + libs.insert(0, 'ninja.lib') 109 + libs.insert(0, 'ninja.lib')
101 else: 110 else:
102 - libs.append('-lninja') 111 - libs.append('-lninja')
103 + libs.insert(0, '-lninja') 112 + libs.insert(0, '-lninja')
104 113
105 all_targets = [] 114 all_targets = []
106 115
107 @@ -583,7 +595,7 @@ if not host.is_mingw(): 116 @@ -583,7 +597,7 @@ if not host.is_mingw():
108 options.with_python, 117 options.with_python,
109 generator=True) 118 generator=True)
110 n.build('build.ninja', 'configure', 119 n.build('build.ninja', 'configure',
111 - implicit=['configure.py', os.path.normpath('misc/ninja_syntax.py')] ) 120 - implicit=['configure.py', os.path.normpath('misc/ninja_syntax.py')] )
112 + implicit=['$srcdir/configure.py', os.path.normpath('$srcdir/misc/ni nja_syntax.py')]) 121 + implicit=['$srcdir/configure.py', os.path.normpath('$srcdir/misc/ni nja_syntax.py')])
113 n.newline() 122 n.newline()
114 123
115 n.default(ninja) 124 n.default(ninja)
116 diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc 125 diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc
117 --- a/src/disk_interface_test.cc 126 --- a/src/disk_interface_test.cc
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 +++ b/src/manifest_parser_perftest.cc 172 +++ b/src/manifest_parser_perftest.cc
164 @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) { 173 @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) {
165 } 174 }
166 175
167 if (chdir(kManifestDir) < 0) 176 if (chdir(kManifestDir) < 0)
168 - Fatal("chdir: %s", strerror(errno)); 177 - Fatal("chdir: %s", strerror(errno));
169 + Fatal("chdir %s: %s", kManifestDir, strerror(errno)); 178 + Fatal("chdir %s: %s", kManifestDir, strerror(errno));
170 179
171 const int kNumRepetitions = 5; 180 const int kNumRepetitions = 5;
172 vector<int> times; 181 vector<int> times;
173 diff --git a/src/ninja.cc b/src/ninja.cc
174 --- a/src/ninja.cc
175 +++ b/src/ninja.cc
176 @@ -42,6 +42,11 @@
177 #include "util.h"
178 #include "version.h"
179
180 +#if defined(__native_client__)
181 +# include "nacl_main.h"
182 +# define main nacl_main
183 +#endif
184 +
185 #ifdef _MSC_VER
186 // Defined in msvc_helper_main-win32.cc.
187 int MSVCHelperMain(int argc, char** argv);
188 diff --git a/src/ninja_test.cc b/src/ninja_test.cc 182 diff --git a/src/ninja_test.cc b/src/ninja_test.cc
189 --- a/src/ninja_test.cc 183 --- a/src/ninja_test.cc
190 +++ b/src/ninja_test.cc 184 +++ b/src/ninja_test.cc
191 @@ -14,6 +14,7 @@ 185 @@ -14,6 +14,7 @@
192 186
193 #include <stdarg.h> 187 #include <stdarg.h>
194 #include <stdio.h> 188 #include <stdio.h>
195 +#include <stdlib.h> 189 +#include <stdlib.h>
196 190
197 #ifdef _WIN32 191 #ifdef _WIN32
198 #include "getopt.h" 192 #include "getopt.h"
199 @@ -21,6 +22,14 @@ 193 @@ -21,6 +22,13 @@
200 #include <getopt.h> 194 #include <getopt.h>
201 #endif 195 #endif
202 196
203 +#if defined(__native_client__) 197 +#if defined(__native_client__)
198 +#include <nacl_io/nacl_io.h>
204 +#include <sys/stat.h> 199 +#include <sys/stat.h>
205 +#include <sys/mount.h> 200 +#include <sys/mount.h>
206 +#include "nacl_main.h" 201 +#include <unistd.h>
207 +#include "nacl_io/nacl_io.h"
208 +#define main nacl_main
209 +#endif 202 +#endif
210 + 203 +
211 #include "test.h" 204 #include "test.h"
212 #include "line_printer.h" 205 #include "line_printer.h"
213 206
214 @@ -123,6 +132,16 @@ bool testing::Test::Check(bool condition, const char* file, int line, 207 @@ -123,6 +131,16 @@ bool testing::Test::Check(bool condition, const char* file, int line,
215 } 208 }
216 209
217 int main(int argc, char **argv) { 210 int main(int argc, char **argv) {
218 +#ifdef __native_client__ 211 +#ifdef __native_client__
219 + // ninja tests require fcntl() and other functions which are not 212 + // ninja tests require fcntl() and other functions which are not
220 + // available under sel_ldr, so we configure nacl_io and run the tests 213 + // available under sel_ldr, so we configure nacl_io and run the tests
221 + // in a memfs. 214 + // in a memfs.
222 + nacl_io_init(); 215 + nacl_io_init();
223 + umount("/"); 216 + umount("/");
224 + mount("", "/", "memfs", 0, NULL); 217 + mount("", "/", "memfs", 0, NULL);
225 + mkdir("/tmp", 0777); 218 + mkdir("/tmp", 0777);
226 + chdir("/"); 219 + chdir("/");
227 +#endif 220 +#endif
228 int tests_started = 0; 221 int tests_started = 0;
229 222
230 const char* test_filter = "*"; 223 const char* test_filter = "*";
231 @@ -152,5 +171,8 @@ int main(int argc, char **argv) { 224 @@ -152,5 +170,8 @@ int main(int argc, char **argv) {
232 } 225 }
233 226
234 printer.PrintOnNewLine(passed ? "passed\n" : "failed\n"); 227 printer.PrintOnNewLine(passed ? "passed\n" : "failed\n");
235 +#ifdef __native_client__ 228 +#ifdef __native_client__
236 + nacl_io_uninit(); 229 + nacl_io_uninit();
237 +#endif 230 +#endif
238 return passed ? EXIT_SUCCESS : EXIT_FAILURE; 231 return passed ? EXIT_SUCCESS : EXIT_FAILURE;
239 } 232 }
240 diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc 233 diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc
241 --- a/src/subprocess-posix.cc 234 --- a/src/subprocess-posix.cc
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 +#ifdef __native_client__ 440 +#ifdef __native_client__
448 +int getloadavg(double loadavg[], int nelem) { 441 +int getloadavg(double loadavg[], int nelem) {
449 + errno = ENOSYS; 442 + errno = ENOSYS;
450 + return -1; 443 + return -1;
451 +} 444 +}
452 +#endif 445 +#endif
453 + 446 +
454 void Fatal(const char* msg, ...) { 447 void Fatal(const char* msg, ...) {
455 va_list ap; 448 va_list ap;
456 fprintf(stderr, "ninja: fatal: "); 449 fprintf(stderr, "ninja: fatal: ");
OLDNEW
« no previous file with comments | « ports/ninja/build.sh ('k') | ports/openssh/build.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698