Skip to content

Commit

Permalink
Setting up common build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlconlin committed Jun 14, 2016
1 parent c66d274 commit c7ff2a3
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "commonCMakeScripts"]
path = commonCMakeScripts
url = git@github.com:njoy/commonCMakeScripts.git
[submodule "Catch"]
path = Catch
url = git@github.com:njoy/Catch.git
[submodule "easyloggingpp"]
path = easyloggingpp
url = git@github.com:njoy/easyloggingpp.git
Empty file added API.hpp.in
Empty file.
21 changes: 21 additions & 0 deletions API/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if(${verbose_traversal})
message(STATUS "Entered API directory")
endif(${verbose_traversal})

set(headers "")
list(APPEND headers
)

foreach(header ${headers})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${header}.hpp.in"
"${nuclearData_HEADER_DIR}/API/${header}.hpp"
COPYONLY
)
endforeach(header)

set(nuclearData_src "${nuclearData_src}" PARENT_SCOPE)

if(${verbose_traversal})
message(STATUS "Exiting API directory")
endif(${verbose_traversal})
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required( VERSION 3.2 )

set(projectName "ENDFtk")
set(projectVersion "0.1.0")

if(NOT DEFINED commonCMakeScripts_path)
set(commonCMakeScripts_path "${CMAKE_SOURCE_DIR}/commonCMakeScripts")
endif(NOT DEFINED commonCMakeScripts_path)

include(subprojects.cmake)
include(${commonCMakeScripts_path}/objectOriented.cmake)

# Initialize a variable for collecting utility implementation components
list(APPEND ${projectName}_src) # (empty list)
list(APPEND ${projectName}_src_headers) # (empty list)
list(APPEND ${projectName}_bin_headers) # (empty list)

set(headers "")
list(APPEND headers
"ENDFtk"
)

foreach(header ${headers})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${header}.hpp.in"
"${ENDFtk_HEADER_DIR}/${header}.hpp"
COPYONLY
)
endforeach(header)

include(${commonCMakeScripts_path}/assemble.cmake)
include(${commonCMakeScripts_path}/terminus.cmake)
1 change: 1 addition & 0 deletions Catch
Submodule Catch added at 055a62
15 changes: 15 additions & 0 deletions ENDFtk.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef ENDFTK_HPP
#define ENDFTK_HPP

#include "easylogging++.h"

namespace ENDFtk {

/* faux forward declaration of nested namespaces */
namespace API{}
namespace implementation{}

} // namespace ENDFtk

#endif // ENDFTK_HPP

10 changes: 10 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright (c) 2016, Los Alamos National Security, LLC
All rights reserved.
Copyright 2016. Los Alamos National Security, LLC. This software was produced under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National Laboratory (LANL), which is operated by Los Alamos National Security, LLC for the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL.

Additionally, redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of Los Alamos National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions commonCMakeScripts
Submodule commonCMakeScripts added at 08f0c7
1 change: 1 addition & 0 deletions easyloggingpp
Submodule easyloggingpp added at 75abf2
170 changes: 170 additions & 0 deletions fetchDependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#! /usr/bin/env python

'''
A handy python script for working with component-based projects
using submodules. This script is written a subset of python compatible
with both Python 2 (version 2.6 or later) and Python 3 (any), so you
shouldn't need to worry about which python version you're using.
Within the NJOY21 scheme, each project repository composes a submodule
for each of the project's (first-order) dependencies. This can lead to
low-level projects (logging, testing, etc) being cloned many times when
cloning recursively. This inflates the time required to clone the project,
bloats the source directory, and the buffer-busting wave of terminal
output just gives a false impression of the complexity of the project.
In addition, submodules have the peculiarity of being associated with
a particular commit rather than a particular branch. As a result,
when a project is updated, any other project depending upon it must also
be updated to benefit. This can amount to considerable overhead when
working on low-level projects.
This script addresses both problems. Subproject repositories are cloned
only once and follow the same composition scheme assumed by the CMake
configuration script. After cloning, the subproject repository is updated
to the development branch.
The latter behavior may be disabled by invoking the script with the
--no_update flag.
'''

try:
import argparse
import subprocess
import os

isWindows = (os.name == "nt")

def smart_clone( cloned_repositories,
update_to_development ):
'''
A happy recursive function to clone components once, only once, and
with the expected composition
'''
import re

start_list_pattern = re.compile('\s*list\(\s*APPEND\s*subprojects.*\n',
re.IGNORECASE)

comment_line_pattern = re.compile('\s*\#.*')
subprojects = list()

if (os.path.exists("subprojects.cmake")):
with open("subprojects.cmake", "r") as f:

hasContent = False
for line in f:
if (start_list_pattern.match(line) != None):
hasContent = True
break

if (not hasContent): return

for line in f:
if (not comment_line_pattern.match(line)):
line = line.replace('"', '')
closing_position = line.find(')')
line = line[:closing_position].strip()
if (line != ""):
subprojects.append(line)
if (closing_position != -1):
break

for subproject in subprojects:
if (not (subproject in cloned_repositories)):
print("")
print("----------------------------------------")
print("Fetching " + subproject + "...")
print("----------------------------------------")
print("")
if isWindows:
subprocess.Popen(["powershell",
"git",
"submodule",
"update",
"-q",
"--init",
"--",
subproject])

else:
subprocess.call(["git",
"submodule",
"update",
"--init",
"--",
subproject])

os.chdir(subproject)
print("")
if (update_to_development):
print("Updating to deploy-ready branch...")
print("")
if isWindows:
subprocess.Popen(["powershell",
"git",
"pull",
"-q",
"origin",
"master"])
else:
subprocess.call(["git",
"pull",
"origin",
"master"])
cloned_repositories.add(subproject)
smart_clone( cloned_repositories,
update_to_development )
os.chdir("..")

# end smart_clone function

parser = argparse.ArgumentParser()
parser.add_argument('--no_update', action='store_true')
update_to_development = not parser.parse_args().no_update
cloned_repositories = set()

print("")
print("----------------------------------------")
print("Fetching commonCMakeScripts...")
print("----------------------------------------")
print("")
if isWindows:
subprocess.Popen(["powershell",
"git",
"submodule",
"update",
"-q",
"--init",
"--",
"commonCMakeScripts"])
else:
subprocess.call(["git",
"submodule",
"update",
"--init",
"--",
"commonCMakeScripts"])
print("")
if (update_to_development):
print("Updating to deploy-ready branch...")
print("")
os.chdir("commonCMakeScripts")
if isWindows:
subprocess.Popen(["powershell",
"git",
"pull",
"-q",
"origin",
"master"])
else:
subprocess.call(["git",
"pull",
"origin",
"master"])
os.chdir("..")

smart_clone( cloned_repositories, update_to_development )
except:
import pdb
pdb.set_trace()
Empty file added implementation.hpp.in
Empty file.
39 changes: 39 additions & 0 deletions implementation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(${verbose_traversal})
message(STATUS "Entered implementation directory")
endif(${verbose_traversal})

set(header_only_subdirs "")
list(APPEND header_only_subdirs
)

set(subdirs "")
list(APPEND subdirs
${header_only_subdirs}
)

foreach (subdir ${header_only_subdirs})
if(NOT(EXISTS "${nuclearData_HEADER_DIR}/implementation/${subdir}"))
file(MAKE_DIRECTORY "${nuclearData_HEADER_DIR}/implementation/${subdir}")
endif(NOT(EXISTS "${nuclearData_HEADER_DIR}/implementation/${subdir}"))
endforeach (subdir)

set(headers "")
list(APPEND headers
${subdirs}
)

foreach(header ${headers})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${header}.hpp.in"
"${nuclearData_HEADER_DIR}/implementation/${header}.hpp"
COPYONLY
)
endforeach(header)

foreach (subdir ${subdirs})
add_subdirectory( ${subdir} )
endforeach (subdir)

if(${verbose_traversal})
message(STATUS "Exiting implementation directory")
endif(${verbose_traversal})
3 changes: 3 additions & 0 deletions src/ENDFtk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "ENDFtk.hpp"

SHARE_EASYLOGGINGPP(el::setupLogging())
5 changes: 5 additions & 0 deletions subprojects.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(subprojects "")
list(APPEND subprojects
"easyloggingpp"
"Catch"
)

0 comments on commit c7ff2a3

Please sign in to comment.