summaryrefslogtreecommitdiff
path: root/xnt/build
diff options
context:
space:
mode:
authorkennyballou <kballou@onyx.boisestate.edu>2013-01-21 18:16:57 -0700
committerkennyballou <kballou@onyx.boisestate.edu>2013-01-21 18:16:57 -0700
commit170d169baff41b5643650f79ddc8209dae6dce6c (patch)
tree1b1a01fd479c844e6a181ccac3b37314e71d6760 /xnt/build
parent9b7f8a34ae8a79ec4b099140a7536976cf6a510e (diff)
parent14f2fef895ce38c53bbe629fd2449ba02c9dac07 (diff)
downloadxnt-170d169baff41b5643650f79ddc8209dae6dce6c.tar.gz
xnt-170d169baff41b5643650f79ddc8209dae6dce6c.tar.xz
Merge branch 'refactor_build_modules'
Conflicts: .gitignore
Diffstat (limited to 'xnt/build')
-rw-r--r--xnt/build/ant.py30
-rw-r--r--xnt/build/cc.py73
-rw-r--r--xnt/build/make.py17
-rw-r--r--xnt/build/nant.py30
4 files changed, 88 insertions, 62 deletions
diff --git a/xnt/build/ant.py b/xnt/build/ant.py
deleted file mode 100644
index 46de16b..0000000
--- a/xnt/build/ant.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-
-# Xnt -- A Wrapper Build Tool
-# Copyright (C) 2012 Kenny Ballou
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import os
-import subprocess
-
-def ant(path="", target=""):
- cmd = ["ant", target]
- if path and os.path.exists(path):
- oldPath = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(path))
- result = subprocess.call(cmd)
- if oldPath:
- os.chdir(oldPath)
- return result
diff --git a/xnt/build/cc.py b/xnt/build/cc.py
new file mode 100644
index 0000000..e4592ca
--- /dev/null
+++ b/xnt/build/cc.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+
+# Xnt -- A Wrapper Build Tool
+# Copyright (C) 2012 Kenny Ballou
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Common Compilers
+"""
+
+import os
+import logging
+import sys
+from xnt.tasks import call
+
+logger = logging.getLogger(__name__)
+
+def gcc(src, flags=[]):
+ """gcc compiler, non-named output file"""
+ return _gcc(src, flags)
+
+def gpp(src, flags=[]):
+ """g++ compiler, non-named output file"""
+ return _gcc(src, flags, "g++")
+
+def gcc_o(src, o, flags=[]):
+ """gcc compiler, with output file"""
+ return _gcc_o(src, o, flags)
+
+def gpp_o(src, o, flags=[]):
+ """g++ compiler, with output file"""
+ return _gcc_o(src, o, flags, "g++")
+
+def javac(src, flags=[]):
+ """Javac: compile Java programs"""
+ logger.info("Compiling %s", src)
+ cmd = __generateCommand(src, flags, "javac")
+ return __compile(cmd)
+
+def _gcc(src, flags=[], compiler="gcc"):
+ logger.info("Compiling %s", src)
+ return __compile(__generateCommand(src, flags, compiler))
+
+def _gcc_o(src, o, flags=[], compiler="gcc"):
+ logger.info("Compiling %s to %s", src, o)
+ cmd = __generateCommand(src, flags, compiler)
+ cmd.append("-o")
+ cmd.append(o)
+ return __compile(cmd)
+
+def __generateCommand(src, flags=[], compiler="gcc"):
+ cmd = [compiler, src]
+ for f in flags:
+ cmd.append(f)
+ return cmd
+
+def __compile(cmd):
+ return call(cmd)
+
+def __is_newer(a, b):
+ return os.path.getmtime(a) > os.path.getmtime(b)
diff --git a/xnt/build/make.py b/xnt/build/make.py
index 1fa0f3f..a9339a4 100644
--- a/xnt/build/make.py
+++ b/xnt/build/make.py
@@ -18,13 +18,26 @@
import os
import subprocess
+import logging
+
+
+def ant(path="", target=""):
+ cmd = ["ant", target]
+ return __run_in(path, lambda: subprocess.call(cmd))
def make(path="", target=""):
cmd = ["make", target]
+ return __run_in(path, lambda: subprocess.call(cmd))
+
+def nant(path="", target=""):
+ cmd = ["nant", target]
+ return __run_in(path, lambda: subprocess.call(cmd))
+
+def __run_in(path, f):
+ oldPath = os.path.abspath(os.getcwd())
if path and os.path.exists(path):
- oldPath = os.path.abspath(os.getcwd())
os.chdir(os.path.abspath(path))
- result = subprocess.call(cmd)
+ result = f()
if oldPath:
os.chdir(oldPath)
return result
diff --git a/xnt/build/nant.py b/xnt/build/nant.py
deleted file mode 100644
index 0d35c90..0000000
--- a/xnt/build/nant.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-
-# Xnt -- A Wrapper Build Tool
-# Copyright (C) 2012 Kenny Ballou
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import os
-import subprocess
-
-def nant(path="", target=""):
- cmd = ["nant", target]
- if path and os.path.exists(path):
- oldPath = os.path.abspath(os.getcwd())
- os.chdir(os.path.abspath(path))
- result = subprocess.call(cmd)
- if oldPath:
- os.chdir(oldPath)
- return result