Skip to content

Commit

Permalink
[OpenLSTO] Add Builder (#3428)
Browse files Browse the repository at this point in the history
* First makefile try

* patch, fPIC

* fopenmp, experimental plats

* dlext

* Missed a spot

* Filter apple, cleanup makefile

* Fix LSM building hopefully

* Correct flag names, remove filter

* Build LSM_3D, fix some more includes

* [OpenLSTO] Use GCC everywhere, it's needed for OpenMP

* add LibraryProducts

* Move all to default position

* I think 1.6 is fine

Co-authored-by: Mosè Giordano <[email protected]>
  • Loading branch information
Will Kimmerer and giordano authored Aug 10, 2021
1 parent 2c35740 commit 06328a2
Show file tree
Hide file tree
Showing 5 changed files with 785 additions and 0 deletions.
56 changes: 56 additions & 0 deletions O/OpenLSTO/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "OpenLSTO"
version = v"1.0"

# Collection of sources required to complete build
sources = [
GitSource("https://github.com/M2DOLab/OpenLSTO.git", "853b9cc433b84c60cd1318a36f9a1d0e6cf65877"),
DirectorySource("./bundled")
]

# Bash recipe for building across all platforms
# New makefiles added, the patches fix some weird include issues mostly.
# There is likely a better way to fix them, or upstream the fixes.
script = raw"""
cp makefile_FEA $WORKSPACE/srcdir/OpenLSTO/M2DO_FEA/makefile
cp makefile_LSM $WORKSPACE/srcdir/OpenLSTO/M2DO_LSM/makefile
cp makefile_3D_LSM $WORKSPACE/srcdir/OpenLSTO/M2DO_3D_LSM/makefile
# At the moment we need GCC to build with OpenMP
export CXX=g++
cd $WORKSPACE/srcdir/OpenLSTO
atomic_patch -p1 ../patches/include_and_eigenpath.patch
cd $WORKSPACE/srcdir/OpenLSTO/M2DO_FEA
make -j${nproc}
make install
cd ../M2DO_LSM
mkdir bin
make -j${nproc}
make install
cd ../M2DO_3D_LSM
make -j${nproc}
make install
install_license ${WORKSPACE}/srcdir/OpenLSTO/LICENSE
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = expand_cxxstring_abis(supported_platforms(; experimental=true); skip=p->false)

# The products that we will ensure are always built
products = [
LibraryProduct("m2do_fea", :m2do_fea),
LibraryProduct("m2do_lsm", :m2do_lsm),
LibraryProduct("m2do_3d_lsm", :m2do_3d_lsm)
]

# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("Eigen_jll"),
Dependency("CompilerSupportLibraries_jll")
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"6", julia_compat="1.6")
39 changes: 39 additions & 0 deletions O/OpenLSTO/bundled/makefile_3D_LSM
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- makefile -*-

CXXFLAGS = -std=c++14 -Wall -fopenmp -w -O3 -fPIC
LDFLAGS = -shared -fopenmp

LSM_DIR = .

# CHANGE TO the directory where you want your .o files stored
OBJ_DIR := $(LSM_DIR)

# Include directories
INCLUDES := -I$(includedir) -I$(includedir)/eigen3 -I$(LSM_DIR)

SRC_FILES := $(wildcard $(LSM_DIR)/*.cpp)

OBJ_FILES := $(patsubst $(LSM_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))

# Make commands for each individual object file
###############################################################################
# Add your own makes here
###############################################################################
# List of targets for executables you write

m2do_3d_lsm.$(dlext): $(OBJ_FILES)
$(CXX) $(LDFLAGS) $(INCLUDES) -o $@ $(OBJ_FILES)

$(OBJ_DIR)/%.o: $(LSM_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<

.PHONY: clean install all

install: m2do_3d_lsm.$(dlext)
install -d $(libdir)
install -m 644 m2do_3d_lsm.$(dlext) $(libdir)
install -m 644 *.h $(includedir)
clean:
rm -f m2do_3d_lsm.$(dlext) $(OBJ_FILES)

all: m2do_3d_lsm.$(dlext)
49 changes: 49 additions & 0 deletions O/OpenLSTO/bundled/makefile_FEA
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- makefile -*-

CXXFLAGS = -std=c++14 -Wall -fopenmp -w -O3 -fPIC -fopenmp
LDFLAGS = -shared -fopenmp
# CHANGE TO directory where FEA and LSM include folders are
# parent directory for FEA files
# parent directory for FEA files

FEA_DIR = .
#LSM_DIR = ./M2DO_LSM/

# CHANGE TO the directory where you want your .o files stored
OBJ_DIR := $(FEA_DIR)/bin

# Include directories
FEA_INCL = $(FEA_DIR)/include
#LSM_INCL = $(LSM_DIR)/include
INCLUDES = -I$(FEA_INCL) -I$(includedir)/eigen3 #-I$(LSM_INCL)

SRC_DIR := $(FEA_DIR)/src
# List of .o files
# Comment out uncessary object files (if needed)
SRC_FILES := $(filter-out $(SRC_DIR)/utility_functions.cpp, $(wildcard $(SRC_DIR)/*.cpp))

OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))
# Compile all the M2DO FEA object files

# Make commands for each individual object file
###############################################################################
# Add your own makes here
###############################################################################
# List of targets for executables you write

all: m2do_fea.$(dlext)

m2do_fea.$(dlext): $(OBJ_FILES)
$(CXX) $(LDFLAGS) $(INCLUDES) -o $@ $(OBJ_FILES)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<

install: m2do_fea.$(dlext)
install -d $(libdir)
install -m 644 m2do_fea.$(dlext) $(libdir)
install -m 644 include/*.h $(includedir)
clean:
rm -f m2do_fea.$(dlext) $(OBJ_FILES)

.PHONY: clean install all
41 changes: 41 additions & 0 deletions O/OpenLSTO/bundled/makefile_LSM
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- makefile -*-

CXXFLAGS = -std=c++14 -Wall -fopenmp -w -O3 -fPIC -fopenmp
LDFLAGS = -shared -fopenmp

LSM_DIR = .

# CHANGE TO the directory where you want your .o files stored
OBJ_DIR := $(LSM_DIR)/bin

# Include directories
LSM_INCL = $(LSM_DIR)/include
INCLUDES = -I$(includedir)/eigen3 -I$(LSM_INCL)

SRC_DIR := $(LSM_DIR)/src
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp)

OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))

# Make commands for each individual object file
###############################################################################
# Add your own makes here
###############################################################################
# List of targets for executables you write

all: m2do_lsm.$(dlext)

m2do_lsm.$(dlext): $(OBJ_FILES)
$(CXX) $(LDFLAGS) $(INCLUDES) -o $@ $(OBJ_FILES)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<

install: m2do_lsm.$(dlext)
install -d $(libdir)
install -m 644 m2do_lsm.$(dlext) $(libdir)
install -m 644 include/*.h $(includedir)
clean:
rm -f m2do_lsm.$(dlext) $(OBJ_FILES)

all: m2do_lsm.$(dlext)
Loading

0 comments on commit 06328a2

Please sign in to comment.