Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions G/GridLABD/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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 = "GridLABD"
version = v"5.3.0"

# Collection of sources required to complete build
sources = [
GitSource("https://github.com/gridlab-d/gridlab-d.git", "1b2e463d3c149e999a2c5f04213477f545e01dc6"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/gridlab-d/

git submodule update --init

atomic_patch ../patches/apple-soname.patch
atomic_patch -p0 ../patches/gldcore-platform-unistd.patch
atomic_patch -p0 ../patches/gldcore-exec-wait.patch

mkdir cmake-build && cd cmake-build

if [[ ${target} == *apple* ]]; then
cmake -S ${WORKSPACE}/srcdir/gridlab-d -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Darwin
else
cmake -S ${WORKSPACE}/srcdir/gridlab-d -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_BUILD_TYPE=Release
fi

cmake --build . -j${nproc} --target install

install_license ${WORKSPACE}/srcdir/gridlab-d/LICENSE
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
# platforms = [
# # Platform("i686", "Linux"; libc="glibc"),
# # Platform("x86_64", "Linux"; libc="glibc"),
# # Platform("aarch64", "Linux"; libc="glibc"),
# # Platform("armv6l", "Linux"; call_abi="eabihf", libc="glibc"),
# # Platform("armv7l", "Linux"; call_abi="eabihf", libc="glibc"),
# # Platform("powerpc64le", "Linux"; libc="glibc"),
# # Platform("riscv64", "Linux"; libc="glibc"),
# Platform("i686", "Linux"; libc="musl"),
# Platform("x86_64", "Linux"; libc="musl"),
# Platform("aarch64", "Linux"; libc="musl"),
# Platform("armv6l", "Linux"; call_abi="eabihf", libc="musl"),
# Platform("armv7l", "Linux"; call_abi="eabihf", libc="musl"),
# Platform("x86_64", "macOS"),
# # Platform("aarch64", "macOS"),
# # Platform("x86_64", "FreeBSD"),
# # Platform("aarch64", "FreeBSD"),
# Platform("i686", "Windows"),
# Platform("x86_64", "Windows"),
# ]

# The products that we will ensure are always built
products = [
ExecutableProduct("gridlabd", :gridlabd)
]

# Dependencies that must be installed before this package can be built
dependencies = Dependency[]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version = v"9.1.0")
28 changes: 28 additions & 0 deletions G/GridLABD/bundled/patches/apple-soname.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -109,6 +109,13 @@

# Compiler/Linker flags for all build types
add_compile_options(${FORCE_ERROR} ${DISABLED_OPTIMIZATIONS})
+
+# Detect MacOSX
+if (APPLE OR "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+ set(MACOSX TRUE)
+else ()
+ set(MACOSX FALSE)
+endif ()

## Set up platform specific library linking and platform identification
if (WIN32 OR MSYS OR MINGW OR CYGWIN)
@@ -127,9 +134,10 @@
add_compile_options(-static-libgcc -static-libstdc++ -static)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -static")
-elseif (APPLE)
+elseif (MACOSX)
set(OS_SPECIFIC_LIBRARIES ${CMAKE_DL_LIBS})
set(FOUND_MACOS yes CACHE INTERNAL "Tell script generator we're MacOS")
+ string(REPLACE "-soname" "-install_name" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
else ()
set(OS_SPECIFIC_LIBRARIES ${CMAKE_DL_LIBS})
endif ()
10 changes: 10 additions & 0 deletions G/GridLABD/bundled/patches/gldcore-exec-wait.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- gldcore/exec.cpp
+++ gldcore/exec.cpp
@@ -96,6 +96,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <cerrno>
11 changes: 11 additions & 0 deletions G/GridLABD/bundled/patches/gldcore-platform-unistd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- gldcore/platform.h
+++ gldcore/platform.h
@@ -30,7 +30,7 @@
#else
#define __WORDSIZE__ __WORDSIZE
#endif
- #include <sys/unistd.h>
+ #include <unistd.h>
#if __WORDSIZE__ == 64
#define X64
#define int64 long long /**< standard 64-bit integers on 64-bit machines */