s/--init/--update/

This commit is contained in:
Radovan Bast 2015-05-23 13:50:50 +02:00
parent d0c5daf0ae
commit 7f197b6199
3 changed files with 27 additions and 20 deletions

View File

@ -1,23 +1,28 @@
[![Build Status](https://travis-ci.org/scisoft/autocmake.svg?branch=master)](https://travis-ci.org/scisoft/autocmake/builds) [![Build Status](https://travis-ci.org/scisoft/autocmake.svg?branch=master)](https://travis-ci.org/scisoft/autocmake/builds)
# Autocmake # Autocmake
A CMake plugin composer. A CMake plugin composer.
## Projects using Autocmake ## Projects using Autocmake
- [Numgrid](https://github.com/rbast/numgrid) - [Numgrid](https://github.com/rbast/numgrid)
## Bootstrapping a new project ## Bootstrapping a new project
Bootstrap a Autocmake infrastructure out of "nothing": Download the ``bootstrap.py`` and execute it to fetch other infrastructure files
which will be needed to build the project:
mkdir cmake # does not have to be called "cmake" - take the name you prefer mkdir cmake # does not have to be called "cmake" - take the name you prefer
cd cmake cd cmake
wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py
python bootstrap.py --init python bootstrap.py --update
This downloads and creates the following files: This creates (or updates) the following files (an existing ``autocmake.cfg`` is
not overwritten by the script):
cmake/ cmake/
├── bootstrap.py # no need to edit ├── bootstrap.py # no need to edit
@ -29,10 +34,11 @@ This downloads and creates the following files:
If you use version control, then now is a good moment to status/diff/add If you use version control, then now is a good moment to status/diff/add
the newly created files. the newly created files.
## Creating the CMake infrastructure ## Creating the CMake infrastructure
Then edit ``autocmake.cfg`` and run the ``bootstrap.py`` script which Then edit ``autocmake.cfg`` and run the ``bootstrap.py`` script which
creates ``CMakeLists.txt`` and ``setup.py`` in the path specified (here ".."): creates ``CMakeLists.txt`` and ``setup.py`` in the build path:
python bootstrap.py .. python bootstrap.py ..
@ -55,6 +61,7 @@ the project:
cd build cd build
make make
## Customizing the CMake modules ## Customizing the CMake modules
The CMake modules can be customized directly inside ``modules/`` but this is The CMake modules can be customized directly inside ``modules/`` but this is

View File

@ -4,7 +4,6 @@ import os
import sys import sys
import urllib import urllib
import shutil import shutil
import tempfile
from collections import OrderedDict from collections import OrderedDict
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
@ -244,22 +243,18 @@ def main(argv):
Main function. Main function.
""" """
if len(argv) != 2: if len(argv) != 2:
sys.stderr.write("\nYou can bootstrap a project in two steps.\n") sys.stderr.write("\nYou can bootstrap a project in two steps.\n\n")
sys.stderr.write("First step is typically done only once.\n") sys.stderr.write("Step 1: Update or create infrastructure files\n")
sys.stderr.write("Second step can be repeated many time without re-running the first step.\n\n") sys.stderr.write(" which will be needed to configure and build the project:\n")
sys.stderr.write("Step 1:\n") sys.stderr.write(" $ %s --update\n\n" % argv[0])
sys.stderr.write("Create an example autocmake.cfg and other infrastructure files\n") sys.stderr.write("Step 2: Create CMakeLists.txt and setup.py in PROJECT_ROOT:\n")
sys.stderr.write("which will be needed to configure and build the project:\n") sys.stderr.write(" $ %s <PROJECT_ROOT>\n" % argv[0])
sys.stderr.write("$ %s --init\n\n" % argv[0]) sys.stderr.write(" example:\n")
sys.stderr.write("Step 2:\n") sys.stderr.write(" $ %s ..\n" % argv[0])
sys.stderr.write("Create CMakeLists.txt and setup.py in PROJECT_ROOT:\n")
sys.stderr.write("$ %s PROJECT_ROOT\n" % argv[0])
sys.stderr.write("example:\n")
sys.stderr.write("$ %s ..\n" % argv[0])
sys.exit(-1) sys.exit(-1)
if argv[1] == '--init': if argv[1] == '--update':
# empty project, create infrastructure files # update infrastructure files
if not os.path.isfile('autocmake.cfg'): if not os.path.isfile('autocmake.cfg'):
print('- fetching example autocmake.cfg') print('- fetching example autocmake.cfg')
fetch_url( fetch_url(
@ -276,6 +271,11 @@ def main(argv):
src='https://github.com/docopt/docopt/raw/master/docopt.py', src='https://github.com/docopt/docopt/raw/master/docopt.py',
dst='lib/docopt.py' dst='lib/docopt.py'
) )
print('- fetching bootstrap.py')
fetch_url(
src='%s/raw/master/bootstrap.py' % AUTOCMAKE_GITHUB_URL,
dst='bootstrap.py'
)
sys.exit(0) sys.exit(0)
project_root = argv[1] project_root = argv[1]

View File

@ -16,7 +16,7 @@ def exe(command):
def test_cxx(): def test_cxx():
os.chdir(os.path.join(HERE, 'cxx', 'cmake')) os.chdir(os.path.join(HERE, 'cxx', 'cmake'))
stdout, stderr = exe('wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py') stdout, stderr = exe('wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py')
stdout, stderr = exe('python bootstrap.py --init') stdout, stderr = exe('python bootstrap.py --update')
stdout, stderr = exe('python bootstrap.py ..') stdout, stderr = exe('python bootstrap.py ..')
os.chdir(os.path.join(HERE, 'cxx')) os.chdir(os.path.join(HERE, 'cxx'))
stdout, stderr = exe('python setup.py --cxx=g++') stdout, stderr = exe('python setup.py --cxx=g++')