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
1 change: 0 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ for (const func of Query.search('function')) {
- `scripts/`: Build and interface generation tools

**Entry Points**:
- `core.ts`: Global imports and initialization
- `weaver/Weaver.ts`: Main weaver utilities
- `LaraJoinPoint.ts`: Base join point implementation
Comment thread
lm-sousa marked this conversation as resolved.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ant-lara-2.0-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

# Daily at midnight
schedule:
- cron: '0 0 * * *'
- cron: '0 0 1 * *'
Comment thread
lm-sousa marked this conversation as resolved.
jobs:
build:

Expand All @@ -23,7 +23,7 @@ jobs:

steps:

- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Because of scheduled runs, by default run on default branch
with:
ref: lara-2.0-legacy
Expand Down
46 changes: 30 additions & 16 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- .github/workflows/copilot-setup-steps.yml

env:
LARA_FRAMEWORK_BRANCH: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
# The job MUST be called `copilot-setup-steps`
Expand All @@ -41,54 +41,68 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current
dependency-graph: generate-and-submit

- name: Checkout lara-framework
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: lara-framework

- name: Determine repository refs
id: repo-refs
shell: bash
env:
BRANCH_NAME: ${{ env.LARA_FRAMEWORK_BRANCH }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
BASE_BRANCH: ${{ github.base_ref }}
run: |
set -euo pipefail

# For each dependency repository, determine which branch to checkout.
# Priority order:
# 1. A branch with the same name as the current branch
# 2. If this is a PR, the target branch (base_ref)
# 3. The default branch of the repository

determine_ref() {
local prefix=$1
local repo=$2
local url="https://github.com/${repo}.git"

# Get the default branch
local default_branch
default_branch=$(git ls-remote --symref "$url" HEAD | awk '/^ref:/ {print $2}' | sed 's@refs/heads/@@')
echo "${prefix}_default=${default_branch}" >> "$GITHUB_OUTPUT"
echo "Default branch for ${repo} is '${default_branch}'"

if git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}" >/dev/null; then
echo "${prefix}_match=true" >> "$GITHUB_OUTPUT"
echo "${prefix}_ref=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
echo "Branch '${BRANCH_NAME}' exists in ${repo}"
local ref_to_use=""

# Priority 1: Same branch name
if [ -n "$(git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}")" ]; then
ref_to_use="${BRANCH_NAME}"
echo "Using matching branch '${BRANCH_NAME}' in ${repo}"
# Priority 2: PR target branch (if this is a PR)
elif [ -n "${BASE_BRANCH}" ] && [ -n "$(git ls-remote --heads "$url" "refs/heads/${BASE_BRANCH}")" ]; then
ref_to_use="${BASE_BRANCH}"
echo "Using PR target branch '${BASE_BRANCH}' in ${repo}"
# Priority 3: Default branch
else
echo "${prefix}_match=false" >> "$GITHUB_OUTPUT"
echo "${prefix}_ref=${default_branch}" >> "$GITHUB_OUTPUT"
echo "Branch '${BRANCH_NAME}' not found in ${repo}. Falling back to '${default_branch}'."
ref_to_use="${default_branch}"
echo "Using default branch '${default_branch}' for ${repo}"
fi

echo "${prefix}_ref=${ref_to_use}" >> "$GITHUB_OUTPUT"
}

determine_ref "specs" "specs-feup/specs-java-libs"

- name: Echo checks
run: |
echo "Lara-Framework branch: ${{ env.LARA_FRAMEWORK_BRANCH }}"
echo "Matching branch found (specs-java-libs): ${{ steps.repo-refs.outputs.specs_match }}"
echo "Lara branch: ${{ env.BRANCH_NAME }}"
echo "PR target branch (if any): ${{ github.base_ref }}"
echo "Specs-java-libs ref: ${{ steps.repo-refs.outputs.specs_ref }}"
echo "Specs-java-libs default fallback: ${{ steps.repo-refs.outputs.specs_default }}"
echo "Pull request base_ref (if any): ${{ github.base_ref }}"
echo "Specs-java-libs default: ${{ steps.repo-refs.outputs.specs_default }}"

- name: Checkout specs-java-libs
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: specs-feup/specs-java-libs
path: specs-java-libs
Expand Down
73 changes: 55 additions & 18 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ permissions:
env:
JAVA_VERSION: 17
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
# Setting default branch to staging assuming PRs will be done against the staging versions of the repository
# main versions will just receive what comes from the staging
DEFAULT_BRANCH: ${{ github.base_ref || 'staging' }}
#SPECS_JAVA_LIBS_BRANCH: ${{ 'master' }}
#LARA_FRAMEWORK_BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
build-java:
name: Build Java
runs-on: ubuntu-latest

outputs:
branch-exists-specs-java-libs: ${{ steps.Branch-specs-java-libs.outputs.value }}
specs_ref: ${{ steps.repo-refs.outputs.specs_ref }}

steps:
- name: Setup Java
Expand All @@ -47,27 +42,70 @@ jobs:
dependency-graph: generate-and-submit

- name: Checkout lara-framework
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: lara-framework

- name: Check if branch exists on specs-java-libs
id: Branch-specs-java-libs
run: echo "value=$(git ls-remote --heads https://github.com/specs-feup/specs-java-libs.git refs/heads/${{ env.BRANCH_NAME }} | wc -l)" >> $GITHUB_OUTPUT
- name: Determine repository refs
id: repo-refs
shell: bash
env:
BRANCH_NAME: ${{ env.BRANCH_NAME }}
BASE_BRANCH: ${{ github.base_ref }}
run: |
set -euo pipefail

# For each dependency repository, determine which branch to checkout.
# Priority order:
# 1. A branch with the same name as the current branch
# 2. If this is a PR, the target branch (base_ref)
# 3. The default branch of the repository

determine_ref() {
local prefix=$1
local repo=$2
local url="https://github.com/${repo}.git"

# Get the default branch
local default_branch
default_branch=$(git ls-remote --symref "$url" HEAD | awk '/^ref:/ {print $2}' | sed 's@refs/heads/@@')
echo "${prefix}_default=${default_branch}" >> "$GITHUB_OUTPUT"
echo "Default branch for ${repo} is '${default_branch}'"

local ref_to_use=""

# Priority 1: Same branch name
if [ -n "$(git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}")" ]; then
ref_to_use="${BRANCH_NAME}"
echo "Using matching branch '${BRANCH_NAME}' in ${repo}"
# Priority 2: PR target branch (if this is a PR)
elif [ -n "${BASE_BRANCH}" ] && [ -n "$(git ls-remote --heads "$url" "refs/heads/${BASE_BRANCH}")" ]; then
ref_to_use="${BASE_BRANCH}"
echo "Using PR target branch '${BASE_BRANCH}' in ${repo}"
# Priority 3: Default branch
else
ref_to_use="${default_branch}"
echo "Using default branch '${default_branch}' for ${repo}"
fi

echo "${prefix}_ref=${ref_to_use}" >> "$GITHUB_OUTPUT"
}

determine_ref "specs" "specs-feup/specs-java-libs"

- name: Echo checks
run: |
echo "Branch-specs-java-libs: ${{ steps.Branch-specs-java-libs.outputs.value }}"
echo "Branch name: ${{ env.BRANCH_NAME }}"
echo "Default branch: ${{ env.DEFAULT_BRANCH }}"
echo "Branch base_ref: ${{ github.base_ref }}"
echo "Lara branch: ${{ env.BRANCH_NAME }}"
echo "PR target branch (if any): ${{ github.base_ref }}"
echo "Specs-java-libs ref: ${{ steps.repo-refs.outputs.specs_ref }}"
echo "Specs-java-libs default: ${{ steps.repo-refs.outputs.specs_default }}"

- name: Checkout specs-java-libs
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: specs-feup/specs-java-libs
path: specs-java-libs
ref: ${{ steps.Branch-specs-java-libs.outputs.value == '1' && env.BRANCH_NAME || env.DEFAULT_BRANCH }}
ref: ${{ steps.repo-refs.outputs.specs_ref }}

# Setting up gradle multi-project would be helpful
- name: Build and test LanguageSpecification
Expand Down Expand Up @@ -126,7 +164,6 @@ jobs:
strategy:
fail-fast: false
matrix:
#node-version: ['latest', '22.x', '20.x']
node-version: ['22.x', '20.x']
os: [ubuntu-latest, windows-latest, macos-latest]

Expand All @@ -146,7 +183,7 @@ jobs:
registry-url: 'https://registry.npmjs.org/'

- name: Checkout lara-framework
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: lara-framework

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public DefaultWeaver() {
public boolean begin(List<File> sources, File output, DataStore args) {

this.args = args;
root = new DWorkspace();
root = new DWorkspace(this);
for (File source : sources) {
if (source.isDirectory()) {
root.addFolder(source);
Expand Down Expand Up @@ -140,10 +140,6 @@ public String getName() {
return "LaraI";
}

public static DefaultWeaver getDefaultWeaver() {
return (DefaultWeaver) getThreadLocalWeaver();
}

public DataStore getArgs() {
return args;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
package org.lara.interpreter.weaver.defaultweaver.joinpoints;

import java.io.File;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFile;

public class DWFile extends AFile {

private final File file;

public DWFile(File f) {
public DWFile(File f, DefaultWeaver weaver) {
super(weaver);
file = f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFolder;

public class DWFolder extends AFolder {
Expand All @@ -24,7 +25,8 @@ public class DWFolder extends AFolder {
private final List<DWFile> files;
private final String path;

public DWFolder(File source) {
public DWFolder(File source, DefaultWeaver weaver) {
super(weaver);
path = source.getAbsolutePath();
files = new ArrayList<>();
createFiles(source);
Expand All @@ -36,7 +38,7 @@ public void createFiles(File folder) {
if (f.isDirectory() && getFilesRecursively) {
createFiles(f);
} else if (f.getName().endsWith(".c")) {
files.add(new DWFile(f));
files.add(new DWFile(f, getWeaverEngine()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
*/
package org.lara.interpreter.weaver.defaultweaver.joinpoints;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFunction;
import org.lara.interpreter.weaver.interf.JoinPoint;

public class DWFunction extends AFunction {

private final String name;

public DWFunction(String element) {
public DWFunction(String element, DefaultWeaver weaver) {
super(weaver);
name = element;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.Map;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AWorkspace;

import pt.up.fe.specs.util.SpecsIo;
Expand All @@ -32,14 +33,15 @@ public class DWorkspace extends AWorkspace {

private final Map<File, DWFolder> folders;

public DWorkspace() {
public DWorkspace(DefaultWeaver weaver) {
super(weaver);
folders = new HashMap<>();
}

public void addFolder(File dir) {
File canonicalFile = SpecsIo.getCanonicalFile(dir.getAbsoluteFile());
if (!folders.containsKey(canonicalFile)) {
folders.put(canonicalFile, new DWFolder(canonicalFile));
folders.put(canonicalFile, new DWFolder(canonicalFile, getWeaverEngine()));
}
}

Expand Down
1 change: 0 additions & 1 deletion LARAI/src/org/lara/interpreter/cli/CLIOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
public enum CLIOption implements WeaverOption {

help("h", "print this message", LaraiKeys.SHOW_HELP),
version("v", "print version information and exit", null),
debug("d", "show all process information", LaraiKeys.DEBUG_MODE),
argv("av", OptionArguments.ONE_ARG, "arguments",
"arguments for the main aspect. Supports passing a .properties file with the arguments",
Expand Down
8 changes: 0 additions & 8 deletions LARAI/src/org/lara/interpreter/cli/JOptionsInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import pt.up.fe.specs.util.SpecsEnums;
import pt.up.fe.specs.util.SpecsLogs;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand All @@ -44,8 +43,6 @@ public class JOptionsInterface {

}

private static final EnumSet<CLIOption> IGNORE_SET = EnumSet.of(CLIOption.version);

public static DataStore getDataStore(String name, Properties properties) {

DataStore data = DataStore.newInstance(name);
Expand All @@ -59,11 +56,6 @@ public static DataStore getDataStore(String name, Properties properties) {
continue;
}

// Just ignore
if (JOptionsInterface.IGNORE_SET.contains(option)) {
continue;
}

DataKey<?> datakey = JOptionsInterface.CONVERSION_MAP.get(option);
// New key that forgot to be added
if (datakey == null) {
Expand Down
Loading