Skip to content

Commit

Permalink
added some help and implemented -o and -ai flags, relnotes and versio…
Browse files Browse the repository at this point in the history
…n bump
  • Loading branch information
arnognulf authored and Thomas Eriksson committed Jan 17, 2012
1 parent bff791f commit 3de49ee
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 19 deletions.
55 changes: 38 additions & 17 deletions contexo/cmdline/ctx2make.py
Expand Up @@ -17,8 +17,6 @@

# TODO:
# * change output dir to absolute path, -o argument?
# * translate msys/cygwin path to ntpath
# * -ai additional includes ?
#


Expand Down Expand Up @@ -59,18 +57,21 @@
def main(argv):
exearg = False
buildTests = False
exe = str()
assignCC = True
buildItems = list()
envFile = ""
viewDir = ""
bcFile = ""
addInc = ""
outputDir = ""

linkHeaders = True

nextArgIsEnv = False
nextArgIsBC = False
nextArgIsViewDir = False
nextArgIsAdditionalIncludes = False
nextArgIsOutputDir = False
parsedAllOptions = False
firstArg = True

Expand All @@ -80,9 +81,22 @@ def main(argv):
continue
if arg == '-h':
print >>sys.stderr, 'help:'
print >>sys.stderr, '-l, symlink all headers to one directory and use that for include path'
print >>sys.stderr, '-b <BCFILE>, .bc file to use'
print >>sys.stderr, '-o <DIR>, output dir for Makefile, Makefile.cfg, Makefile.inc'
print >>sys.stderr, '-ai <DIR>, additional includes'
print >>sys.stderr, '-v <DIR>, override autodetection of view dir'
print >>sys.stderr, '-e <ENVFILE>, envfile'
print >>sys.stderr, '-nocc, disable setting the CC and CXX variables (use with scan-build)'
print >>sys.stderr, '-t, build tests'
sys.exit(1)
if nextArgIsOutputDir:
outputDir = arg
outputDir = outputDir.replace('\\','/')
if len(outputDir) > 0:
if outputDir[-1] != '/':
outputDir = outputDir + '/'
nextArgIsOutputDir = False
continue
if nextArgIsEnv:
envFile = arg
nextArgIsEnv = False
Expand All @@ -95,6 +109,13 @@ def main(argv):
bcFile = arg
nextArgIsBC = False
continue
if nextArgIsAdditionalIncludes:
if len(addInc) > 0:
print >>sys.stderr, 'only one \'-ai\' argument allowed'
sys.exit(1)
addInc = arg
nextArgIsAdditionalIncludes = False
continue
if not parsedAllOptions:
if arg == '-t':
buildTests = True
Expand Down Expand Up @@ -127,7 +148,7 @@ def main(argv):
sys.exit(1)
argDict = dict()

genMakefile(viewDir = viewDir, envFile = envFile, bcFile = bcFile, buildItems = buildItems, buildTests = buildTests, linkHeaders = linkHeaders, assignCC = assignCC)
genMakefile(outputDir = outputDir, viewDir = viewDir, envFile = envFile, bcFile = bcFile, buildItems = buildItems, buildTests = buildTests, linkHeaders = linkHeaders, assignCC = assignCC, addInc = addInc)

logging.basicConfig(format = '%(asctime)s %(levelname)-8s %(message)s',
datefmt='%H:%M:%S',
Expand Down Expand Up @@ -291,7 +312,7 @@ def get_view_dir(args_view):
view_dir = posixpath.abspath('')
return view_dir

def genMakefile(viewDir = str(), envFile = str(), bcFile = str(), buildItems = list(), buildTests = False, linkHeaders = False, assignCC = False):
def genMakefile(outputDir = str(), viewDir = str(), envFile = str(), bcFile = str(), buildItems = list(), buildTests = False, linkHeaders = False, assignCC = False, addInc = str()):
launch_path = posixpath.abspath('.')
view_dir = get_view_dir(viewDir)
obj_dir = view_dir + os.sep + '.ctx/obj'
Expand Down Expand Up @@ -323,7 +344,7 @@ def genMakefile(viewDir = str(), envFile = str(), bcFile = str(), buildItems = l
dest = 'output' + os.sep + 'linkheaders'
linkIncludes(includes, dest, view_dir)

writeMakefile(librarySources = librarySources, includes = includes, linkHeaders = linkHeaders, bc = bc, viewDir = view_dir, assignCC = assignCC)
writeMakefile(librarySources = librarySources, includes = includes, linkHeaders = linkHeaders, bc = bc, viewDir = view_dir, assignCC = assignCC, addInc = addInc)

if envFile != "":
switchEnvironment(oldEnv, False)
Expand All @@ -336,8 +357,7 @@ def linkIncludes(includes, dest, viewDir):
linkFile.write("/* Autogenerated by Contexo\n * changes to this file WILL BE LOST\n */\n")
linkFile.write("#include \"../../" + includeFile + "\"\n\n")
linkFile.close()
def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = False, bc = None, viewDir = str(), assignCC = False):
# TODO: hardcoded for now
def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = False, bc = None, viewDir = str(), assignCC = False, addInc = str()):
libPrefix = bc.getCompiler().cdef['LIBPREFIX']
libSuffix = bc.getCompiler().cdef['LIBSUFFIX']
objSuffix = bc.getCompiler().cdef['OBJSUFFIX']
Expand Down Expand Up @@ -376,8 +396,8 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
subCxxFileSuffix = subBCObject.getCompiler().cdef['CXXFILESUFFIX']

break
if not posixpath.isfile("Makefile.inc"):
incmakefile = open("Makefile.inc", 'w')
if not posixpath.isfile(outputDir + "Makefile.inc"):
incmakefile = open(outputDir + "Makefile.inc", 'w')
incmakefile.write("### inc_all is built after all other projects is built\n")
incmakefile.write("### add dependencies for inc_all to add further build steps\n")
incmakefile.write("inc_all: $(LIBS)\n")
Expand All @@ -388,7 +408,7 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
incmakefile.close()

# Start writing to the file - using default settings for now
makefile = open("Makefile", 'w')
makefile = open(outputDir + "Makefile", 'w')

# File header
makefile.write("#############################################\n")
Expand All @@ -400,8 +420,8 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
makefile.write("endif\n")

# config settings
if not posixpath.isfile("Makefile.cfg"):
cfgmakefile = open("Makefile.cfg", 'w')
if not posixpath.isfile(outputDir + "Makefile.cfg"):
cfgmakefile = open(outputDir + "Makefile.cfg", 'w')
cfgmakefile.write("### Compiler settings\n")
if assignCC:
cfgmakefile.write("CC=" + bc.getCompiler().cdef['CC'].replace('\\','/') + "\n")
Expand All @@ -427,6 +447,7 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
cfgmakefile.write("HDRDIR=$(OUTPUT)/inc\n")
cfgmakefile.write("LINKHEADERS=$(OUTPUT)/linkheaders\n")
cfgmakefile.write("DEPDIR=$(OUTPUT)/makedeps\n")
cfgmakefile.write("ADDINC=" + addInc + "\n")
cfgmakefile.write("\n")

cfgmakefile.write("EXPORT_CMD=cp\n")
Expand Down Expand Up @@ -531,15 +552,15 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
makefile.write("$(CYGPREFIX)$(OBJDIR)/" + posixpath.basename(basePath) + objSuffix + ": $(CYGPREFIX)" + sourceDependencyName + "\n")
makefile.write("\tRAW_SRC=$@;SRC_NOPREFIX=$${FOO#/};DRIVE=$${SRC_NOPREFIX%%/*};UNC_SRC=$${DRIVE}:/$${SRC_NOPREFIX#*/};")
makefile.write("OUTPUT=\"$<\";export CYGWIN=nodosfilewarning;SOURCEFILE=\"$*\";OBJFILE=\"$${SOURCEFILE%.*}\"" + objSuffix + ";makedepend -f-")
makefile.write(" -I" + privIncPathForSourceFile(sourceDependencyName) + " -I\"$(LINKHEADERS)\" $< 2>/dev/null | sed \"s,.*:,\\$$(OBJDIR)/$${SOURCEFILE##*/}" + objSuffix + ":,\" > $(DEPDIR)/$${OUTPUT##*/}.d\n")
makefile.write(" -I" + privIncPathForSourceFile(sourceDependencyName) + " -I\"$(ADDINC)\" -I\"$(LINKHEADERS)\" $< 2>/dev/null | sed \"s,.*:,\\$$(OBJDIR)/$${SOURCEFILE##*/}" + objSuffix + ":,\" > $(DEPDIR)/$${OUTPUT##*/}.d\n")
# -e '/^C:/d'
if sourceDependencyName.count("/sub_bc/") > 0:
if sourceDependencyName[-len(subCxxFileSuffix):] == subCxxFileSuffix:
subCommandLine = "\t" + subCcCommandLine
else:
subCommandLine = "\t" + subCxxCommandLine

subCommandLine = subCommandLine.replace("%INCPATHS", subIncPrefix + privIncPathForSourceFile(sourceDependencyName) + subIncSuffix + " " + subIncPrefix + "$(LINKHEADERS)" + subIncSuffix)
subCommandLine = subCommandLine.replace("%INCPATHS", subIncPrefix + addInc + subIncSuffix + " " + subIncPrefix + privIncPathForSourceFile(sourceDependencyName) + subIncSuffix + " " + subIncPrefix + "$(LINKHEADERS)" + subIncSuffix)
subCommandLine = subCommandLine.replace('%CPPDEFINES','$(SUB_PREP_DEFS)')
makefile.write(subCommandLine)
else:
Expand All @@ -548,7 +569,7 @@ def writeMakefile(librarySources = dict(), includes = list(), linkHeaders = Fals
else:
commandLine = "\t" + ccCommandLine

commandLine = commandLine.replace("%INCPATHS", incPrefix + privIncPathForSourceFile(sourceDependencyName) + incSuffix + " " + incPrefix + "$(LINKHEADERS)" + incSuffix)
commandLine = commandLine.replace("%INCPATHS", incPrefix + addInc + incSuffix + " " + incPrefix + privIncPathForSourceFile(sourceDependencyName) + incSuffix + " " + incPrefix + "$(LINKHEADERS)" + incSuffix)
commandLine = commandLine.replace("%CPPDEFINES","$(PREP_DEFS)")
makefile.write(commandLine)
makefile.write("\n")
Expand Down
4 changes: 2 additions & 2 deletions contexo/ctx_sysinfo.py
Expand Up @@ -17,8 +17,8 @@
#

CTX_VER_MAJOR = 0
CTX_VER_MINOR_1 = 16
CTX_VER_MINOR_2 = 10
CTX_VER_MINOR_1 = 17
CTX_VER_MINOR_2 = 0
CTX_VER_STATE = ''
CTX_DISPLAYVERSION = '%d.%d.%d %s'%(CTX_VER_MAJOR, CTX_VER_MINOR_1, CTX_VER_MINOR_2, CTX_VER_STATE)
CTX_LICENSE = 'licesed under GPLv2 ( http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt )'
Expand Down
17 changes: 17 additions & 0 deletions releasenotes.txt
@@ -1,3 +1,20 @@
Contexo 0.17.0
Feature: added the 'ctx2make' command.
This is basically a replacement for ctx+genmake, but designed to be much faster.
ctx2make is designed to be compatible with Windows, however, it has some external dependencies:

The following cygwin packages must be installed
make
makedepend
C:\cygwin\bin - must be added at the end of user environment variable PATH.

If the dependencies above are fulfilled, Makefiles produced with ctx2make can be built with
* MSys GNU make
* GNU make from rvct
* Cygwin GNU make
* Eclipse
* Netbeans

Contexo 0.16.10
Feature: genmake.py updates to correctly use CPPFLAGS [gustafp]

Expand Down

0 comments on commit 3de49ee

Please sign in to comment.