From 40a4808074c2daa0f2f83faf22aa7e8a77f8fb22 Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Mon, 12 Jan 2015 17:36:37 -0500 Subject: Strip tabs from od's output /bin/od on Solaris and AIX both generate tabs. --- src/inline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inline.sh b/src/inline.sh index 5acc17b..fa282fa 100755 --- a/src/inline.sh +++ b/src/inline.sh @@ -20,6 +20,6 @@ varname="$1" echo "const char $varname[] =" -od -t x1 -A n -v | sed -e 's| ||g; s|..|\\x&|g; s|^|"|; s|$|"|' +od -t x1 -A n -v | sed -e 's|[ \t]||g; s|..|\\x&|g; s|^|"|; s|$|"|' echo ";" -- cgit v1.2.1 From da4e98b715c3e7cdf8bcc26f49868772daae7ff5 Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Mon, 12 Jan 2015 20:47:55 -0500 Subject: Start AIX port --- configure.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index b8d7096..f9ea8eb 100755 --- a/configure.py +++ b/configure.py @@ -58,11 +58,13 @@ class Platform(object): self._platform = 'bitrig' elif self._platform.startswith('netbsd'): self._platform = 'netbsd' + elif self._platform.startswith('aix'): + self._platform = 'aix' @staticmethod def known_platforms(): return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5', - 'mingw', 'msvc', 'gnukfreebsd', 'bitrig', 'netbsd'] + 'mingw', 'msvc', 'gnukfreebsd', 'bitrig', 'netbsd', 'aix'] def platform(self): return self._platform @@ -89,6 +91,9 @@ class Platform(object): def is_solaris(self): return self._platform == 'solaris' + def is_aix(self): + return self._platform == 'aix' + def uses_usr_local(self): return self._platform in ('freebsd', 'openbsd', 'bitrig') @@ -96,7 +101,9 @@ class Platform(object): return self._platform in ('linux', 'openbsd', 'bitrig') def supports_ninja_browse(self): - return not self.is_windows() and not self.is_solaris() + return (not self.is_windows() + and not self.is_solaris() + and not self.is_aix()) class Bootstrap: @@ -345,6 +352,8 @@ if platform.is_mingw(): ldflags.append('-static') elif platform.is_solaris(): cflags.remove('-fvisibility=hidden') +elif platform.is_aix(): + cflags.remove('-fvisibility=hidden') elif platform.is_msvc(): pass else: -- cgit v1.2.1 From 164e7f9494a7a9b9c6ec38b4cd4700bdb2aec1c5 Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Mon, 12 Jan 2015 19:13:39 -0500 Subject: Fix AIX compilation error related to printf macros On AIX, inttypes.h gets indirectly included by build_log.h. It's easiest just to ask for the printf format macros right away. --- src/build_log.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/build_log.cc b/src/build_log.cc index 589c6da..8a52514 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -12,6 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On AIX, inttypes.h gets indirectly included by build_log.h. +// It's easiest just to ask for the printf format macros right away. +#ifndef _WIN32 +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#endif + #include "build_log.h" #include @@ -19,9 +27,6 @@ #include #ifndef _WIN32 -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif #include #include #endif -- cgit v1.2.1 From 94c10a6a18ceadf78d27245ce389610c67a7cf2e Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Mon, 12 Jan 2015 20:48:07 -0500 Subject: Implement GetLoadAverage on AIX using libperfstat --- configure.py | 3 +++ src/util.cc | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/configure.py b/configure.py index f9ea8eb..fcea72a 100755 --- a/configure.py +++ b/configure.py @@ -505,6 +505,9 @@ if platform.is_msvc(): else: libs.append('-lninja') +if platform.is_aix(): + libs.append('-lperfstat') + all_targets = [] n.comment('Main executable is library plus main() function.') diff --git a/src/util.cc b/src/util.cc index aa47f2f..d150fe2 100644 --- a/src/util.cc +++ b/src/util.cc @@ -45,6 +45,8 @@ #elif defined(__SVR4) && defined(__sun) #include #include +#elif defined(_AIX) +#include #elif defined(linux) || defined(__GLIBC__) #include #endif @@ -573,6 +575,16 @@ double GetLoadAverage() { return posix_compatible_load; } +#elif defined(_AIX) +double GetLoadAverage() { + perfstat_cpu_total_t cpu_stats; + if (perfstat_cpu_total(NULL, &cpu_stats, sizeof(cpu_stats), 1) < 0) { + return -0.0f; + } + + // Calculation taken from comment in libperfstats.h + return double(cpu_stats.loadavg[0]) / double(1 << SBITS); +} #else double GetLoadAverage() { double loadavg[3] = { 0.0f, 0.0f, 0.0f }; -- cgit v1.2.1 From cdab57de00ab7ce157f1fdd601ce242588fcadce Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Mon, 12 Jan 2015 20:53:14 -0500 Subject: Fix getopt for AIX AIX supplies getopt but not getopt_long. We can't use the embedded getopt implementation, since the constness of its arguments doesn't match the AIX system routine. --- configure.py | 2 ++ src/getopt.c | 2 ++ src/getopt.h | 2 ++ src/ninja.cc | 3 +++ src/ninja_test.cc | 3 +++ 5 files changed, 12 insertions(+) diff --git a/configure.py b/configure.py index fcea72a..611030f 100755 --- a/configure.py +++ b/configure.py @@ -494,6 +494,8 @@ if platform.is_windows(): objs += cc('getopt') else: objs += cxx('subprocess-posix') +if platform.is_aix(): + objs += cc('getopt') if platform.is_msvc(): ninja_lib = n.build(built('ninja.lib'), 'ar', objs) else: diff --git a/src/getopt.c b/src/getopt.c index 3350fb9..0c2ef35 100644 --- a/src/getopt.c +++ b/src/getopt.c @@ -385,11 +385,13 @@ getopt_internal (int argc, char **argv, char *shortopts, return optopt; } +#ifndef _AIX int getopt (int argc, char **argv, char *optstring) { return getopt_internal (argc, argv, optstring, NULL, NULL, 0); } +#endif int getopt_long (int argc, char **argv, const char *shortopts, diff --git a/src/getopt.h b/src/getopt.h index b4247fb..965dc29 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -39,7 +39,9 @@ extern "C" extern int optopt; /* function prototypes */ +#ifndef _AIX int getopt (int argc, char **argv, char *optstring); +#endif int getopt_long (int argc, char **argv, const char *shortopts, const GETOPT_LONG_OPTION_T * longopts, int *longind); int getopt_long_only (int argc, char **argv, const char *shortopts, diff --git a/src/ninja.cc b/src/ninja.cc index a3d963f..f71f6dc 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -22,6 +22,9 @@ #include "getopt.h" #include #include +#elif defined(_AIX) +#include "getopt.h" +#include #else #include #include diff --git a/src/ninja_test.cc b/src/ninja_test.cc index 54d8784..11087b6 100644 --- a/src/ninja_test.cc +++ b/src/ninja_test.cc @@ -17,6 +17,9 @@ #ifdef _WIN32 #include "getopt.h" +#elif defined(_AIX) +#include "getopt.h" +#include #else #include #endif -- cgit v1.2.1 From aa14d6e067c6491555150c1f40de1388c3491124 Mon Sep 17 00:00:00 2001 From: Mike Seplowitz Date: Wed, 21 Oct 2015 18:37:50 -0400 Subject: Separate bootstrapped build from final build AIX does not support rebuilding ninja in-place from the bootstrapped ninja. --- .gitignore | 1 + configure.py | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index f7fc044..5a85203 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ TAGS /build /build.ninja /ninja +/ninja.bootstrap /build_log_perftest /canon_perftest /depfile_parser_perftest diff --git a/configure.py b/configure.py index 611030f..1a6d51c 100755 --- a/configure.py +++ b/configure.py @@ -105,6 +105,8 @@ class Platform(object): and not self.is_solaris() and not self.is_aix()) + def can_rebuild_in_place(self): + return not (self.is_windows() or self.is_aix()) class Bootstrap: """API shim for ninja_syntax.Writer that instead runs the commands. @@ -639,17 +641,28 @@ n.build('all', 'phony', all_targets) n.close() print('wrote %s.' % BUILD_FILENAME) -verbose = '' -if options.verbose: - verbose = ' -v' - if options.bootstrap: print('bootstrap complete. rebuilding...') - if platform.is_windows(): - bootstrap_exe = 'ninja.bootstrap.exe' + + rebuild_args = [] + + if platform.can_rebuild_in_place(): + rebuild_args.append('./ninja') + else: + if platform.is_windows(): + bootstrap_exe = 'ninja.bootstrap.exe' + final_exe = 'ninja.exe' + else: + bootstrap_exe = './ninja.bootstrap' + final_exe = './ninja' + if os.path.exists(bootstrap_exe): os.unlink(bootstrap_exe) - os.rename('ninja.exe', bootstrap_exe) - subprocess.check_call('ninja.bootstrap.exe%s' % verbose, shell=True) - else: - subprocess.check_call('./ninja%s' % verbose, shell=True) + os.rename(final_exe, bootstrap_exe) + + rebuild_args.append(bootstrap_exe) + + if options.verbose: + rebuild_args.append('-v') + + subprocess.check_call(rebuild_args) -- cgit v1.2.1