Skip to content
Merged
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
72 changes: 72 additions & 0 deletions .github/workflows/local-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Local Test (act)

# This workflow is designed to be run locally with act (nektos/act)
# It only targets Ubuntu since act does not support macOS runners

on:
workflow_dispatch:
push:
branches: [ modprod2026 ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
julia-version: ['1.10', '1.11', '1.12']
name: Build parser (Julia ${{ matrix.julia-version }})
steps:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'

- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v4

- name: Install build dependencies
run: |
apt-get update
apt-get install -y build-essential autoconf automake libtool m4 pkg-config

- name: Configure and build parser library
run: |
which gcc
gcc --version
cd lib/parser
autoconf
./configure
make
cd ../build/lib
tar -czvf ubuntu-julia-${{ matrix.julia-version }}-library.tar.gz *
mv ubuntu-julia-${{ matrix.julia-version }}-library.tar.gz '${{ github.workspace }}/'.

- name: Build Julia package
run: |
julia --compiled-modules=no --color=yes --project -e '
import Pkg
Pkg.Registry.add("General")
Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JKRT/OpenModelicaRegistry.git"))
Pkg.build(verbose=true)
Pkg.instantiate()
Pkg.resolve()
'

- name: Test
run: |
julia --color=yes --project -e '
import Pkg
Pkg.add(Pkg.PackageSpec(url="https://github.com/OpenModelica/Absyn.jl.git", rev="master"))
Pkg.test("Absyn")
Pkg.test("OMParser")
'

- name: Upload library
uses: actions/upload-artifact@v4
with:
name: parser-library-julia-${{ matrix.julia-version }}
path: ${{ github.workspace }}/ubuntu-julia-${{ matrix.julia-version }}-library.tar.gz
17 changes: 9 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
- { os: windows-latest, shell: 'msys2 {0}' }
- { os: ubuntu-latest, shell: bash }
- { os: macos-latest, shell: bash }
julia-version: ['1.10', '1.11', '1.12']
defaults:
run:
shell: ${{ matrix.sys.shell }}
name: building OMParser.jl/lib/parser
name: Build parser (${{ matrix.sys.os }}, Julia ${{ matrix.julia-version }})
steps:
- uses: actions/setup-java@v4
with:
Expand All @@ -26,7 +27,7 @@ jobs:
- name: setup julia environment
uses: julia-actions/setup-julia@v2
with:
version: "1.10.0"
version: ${{ matrix.julia-version }}
- name: setup msys2 environment
uses: msys2/setup-msys2@v2
with:
Expand All @@ -50,7 +51,7 @@ jobs:
brew install pkg-config
brew install libtool

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: configure the library and build
run: |
which gcc
Expand All @@ -60,8 +61,8 @@ jobs:
./configure
make
cd ../build/lib
tar -czvf ${{matrix.sys.os}}-library.tar.gz *
mv ${{matrix.sys.os}}-library.tar.gz '${{github.workspace}}/'.
tar -czvf ${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz *
mv ${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz '${{ github.workspace }}/'.

- name: Build
# Always use bash to avoid having to escape quotes for Windows
Expand All @@ -72,7 +73,7 @@ jobs:
run: julia --color=yes --project -e 'import Pkg; Pkg.add(Pkg.PackageSpec(url="https://github.com/OpenModelica/Absyn.jl.git", rev="master")); Pkg.test("Absyn"); Pkg.test("OMParser")'

- name: upload library
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: parser-library
path: ${{github.workspace}}/${{matrix.sys.os}}-library.tar.gz
name: parser-library-${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}
path: ${{ github.workspace }}/${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz
30 changes: 15 additions & 15 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: building OMParser.jl/lib/parser

runs-on: ${{ matrix.sys.os }}
strategy:
matrix:
sys:
- { os: windows-latest, shell: 'msys2 {0}' }
- { os: ubuntu-latest, shell: bash }
- { os: macos-latest, shell: bash }
julia-version: ['1.10', '1.11', '1.12']

defaults:
run:
shell: ${{ matrix.sys.shell }}

name: Build parser (${{ matrix.sys.os }}, Julia ${{ matrix.julia-version }})

steps:

- name: setup julia environment
uses: julia-actions/setup-julia@v1
uses: julia-actions/setup-julia@v2
with:
version: "1.10.0"
version: ${{ matrix.julia-version }}

- name: setup msys2 environment
uses: msys2/setup-msys2@v2
Expand All @@ -58,7 +59,7 @@ jobs:
brew install pkg-config
brew install libtool

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: configure the library and build
run: |
Expand All @@ -69,25 +70,24 @@ jobs:
./configure
make
cd ../build/lib
tar -czvf ${{matrix.sys.os}}-library.tar.gz *
mv ${{matrix.sys.os}}-library.tar.gz '${{github.workspace}}/'.
tar -czvf ${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz *
mv ${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz '${{ github.workspace }}/'.

- name: Run the testsuite
run: julia --color=yes --project -e 'import Pkg; Pkg.add(Pkg.PackageSpec(url="https://github.com/OpenModelica/Absyn.jl.git", rev="master")); Pkg.test("Absyn"); Pkg.test("OMParser")'
- name: Run the testsuite
run: julia --color=yes --project -e 'import Pkg; Pkg.add(Pkg.PackageSpec(url="https://github.com/OpenModelica/Absyn.jl.git", rev="master")); Pkg.test("Absyn"); Pkg.test("OMParser")'

- name: upload library
uses: actions/upload-artifact@v3

uses: actions/upload-artifact@v4
with:
name: parser-library
path: ${{github.workspace}}/${{matrix.sys.os}}-library.tar.gz
name: parser-library-${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}
path: ${{ github.workspace }}/${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz

- name: "Perform Release"
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{github.events.inputs.myInput}}${{matrix.sys.os}}"
automatic_release_tag: "${{ github.event.inputs.myInput }}-${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}"
draft: false
prerelease: true
files: |
${{matrix.sys.os}}-library.tar.gz
${{ matrix.sys.os }}-julia-${{ matrix.julia-version }}-library.tar.gz
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,3 @@ sed -i.bak 's/ db/ # db/g' /etc/nsswitch.conf
````

Then start MSYS2 MinGW terminal and then follow the instructions for Linux/Mac.








71 changes: 56 additions & 15 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#= Build script for the OpenModelica parser. Currently it is for windows only. =#
#= Build script for the OpenModelica parser. =#
@info "Building OpenModelicaParser A Modelica Parser in Julia"
import ZipFile
import Tar
Expand All @@ -15,7 +15,7 @@ if ! ("Absyn" in keys(pkgs))
end

function extractTar(libraryString; URL)
@info "Downloading Linux so file..."
@info "Downloading shared library from: $URL"
HTTP.download(URL, PATH_TO_EXT)
println(pwd())
cd(PATH_TO_EXT)
Expand Down Expand Up @@ -48,22 +48,63 @@ using HTTP
#=Extern path=#
PATH_TO_EXT = realpath("$(pwd())/../lib/ext")

#= Determine Julia version for library selection =#
const JULIA_MAJOR_MINOR = "$(VERSION.major).$(VERSION.minor)"
@info "Detected Julia version: $JULIA_MAJOR_MINOR"

@static if v"1.10.0" > VERSION
throw("Building OMParser with precompiled shared libraries is currently only supported for Julia version 1.10 or greater. For prior versions of Julia please download and extract the libraries available at https://github.com/OpenModelica/OMParser.jl/releases or build the libraries in the lib subdirectory.")
end

@static if Sys.iswindows()
#= Download the shared libraries (DLLS for Windows) =#
extractTar("windows-latest-library";
URL="https://github.com/OpenModelica/OMParser.jl/releases/download/Latest-windows-latest/windows-latest-library.tar.gz")
elseif Sys.islinux()
extractTar("ubuntu-latest-library";
URL="https://github.com/OpenModelica/OMParser.jl/releases/download/Latest-ubuntu-latest/ubuntu-latest-library.tar.gz")
elseif Sys.isapple()
extractTar("macos-latest-library";
URL="https://github.com/OpenModelica/OMParser.jl/releases/download/Latest-macos-latest/macos-latest-library.tar.gz")
else#= Throw error for other variants =#
@error "Non Linux/Windows systems are currently not supported"
throw("Unsupported system error")
#= Check if local build already exists (from configure/make) =#
function checkLocalBuildExists()
local build_path = realpath("$(pwd())/../lib/build/lib")
if isdir(build_path)
local lib_files = filter(f -> endswith(f, ".so") || endswith(f, ".dll") || endswith(f, ".dylib"),
readdir(build_path; join=true))
if !isempty(lib_files)
@info "Local build already exists at $build_path, skipping download"
return true
end
#= Check subdirectories (platform-specific) =#
for subdir in readdir(build_path)
local subpath = joinpath(build_path, subdir)
if isdir(subpath)
local sub_files = filter(f -> occursin("libomparse-julia", f), readdir(subpath))
if !isempty(sub_files)
@info "Local build already exists at $subpath, skipping download"
return true
end
end
end
end
return false
end

#= Construct platform and Julia version specific library names =#
function getLibraryURL(os_name::String)
local lib_name = "$(os_name)-julia-$(JULIA_MAJOR_MINOR)-library"
local release_tag = "Latest-$(os_name)-julia-$(JULIA_MAJOR_MINOR)"
local url = "https://github.com/OpenModelica/OMParser.jl/releases/download/$(release_tag)/$(lib_name).tar.gz"
return (lib_name, url)
end

#= Only download if local build does not exist =#
if !checkLocalBuildExists()
@static if Sys.iswindows()
#= Download the shared libraries (DLLS for Windows) =#
local (lib_name, url) = getLibraryURL("windows-latest")
extractTar(lib_name; URL=url)
elseif Sys.islinux()
local (lib_name, url) = getLibraryURL("ubuntu-latest")
extractTar(lib_name; URL=url)
elseif Sys.isapple()
local (lib_name, url) = getLibraryURL("macos-latest")
extractTar(lib_name; URL=url)
else
@error "Non Linux/Windows/macOS systems are currently not supported"
throw("Unsupported system error")
end
else
@info "Using locally built parser library"
end
Loading