Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: require mutter 42 #1496

Merged
merged 8 commits into from Feb 21, 2023
Merged

Conversation

bobby285271
Copy link
Member

@bobby285271 bobby285271 commented Nov 12, 2022

A quick look at launchpad gala is kept on 6.3.1 in elementary OS 6.1, not sure if we want to do this now okay it looks like we want to do this after Odin Horus is out but anyway here is an attempt to remove support for mutter 3.36, 3.38, 40, 41.

It is unclear to me how this is done previously, here is the script I used, so for the 2nd, 3rd, 4th, 5th commits, if you spot any issues (except the manually updated meson.build), it is likely an issue of my script :-)

Yeah I developed an bad habit of executing C++ files directly as shell script before I retired from competitive programming, so yes you can run this as a shell script :-)

#if 0
    g++ -std=c++17 -O2 -Wall -lm "$0" && ./a.out HAS_MUTTER42 $1
    rm ./a.out
    exit
#endif

// WARNING:
//
// I wrote this program in a competitive programming
// way, i.e. very bad code quality and it assumes your
// input is totally valid. But "should works".
//
// Also, YOU NEED TO convert all `#elif` blocks to
// `#if` blocks before running this because this program
// DOES NOT TAKE CARE OF IT.
//
// Place the vala flag you wish to clean up in line 2 (of this file).
// Usage: ./main.cpp <file_location>

#include <bits/stdc++.h>
using namespace std;

const string if_prefix = "#if ";
const string else_prefix = "#else";
const string endif_prefix = "#endif";

bool starts_with(string a, string b)
{
    return a.substr(0, b.size()) == b;
}

bool is_related(string a, string b)
{
    return a.substr(if_prefix.size(), b.size()) == b;
}

struct if_block
{
    bool rm_first;
    bool rm_second;
    bool rm_stat;
    bool is_else_seen;
};

int main(int argc, char **argv)
{
    std::cout << "I assume you know what you are doing :-)\n";
    assert(argc == 3);
    string vala_flag = argv[1];
    string file_location = argv[2];

    string cp_cmd = "cp " + file_location + " " + file_location + ".in";
    system(cp_cmd.c_str());

    ifstream file(file_location + ".in");
    assert(file);
    ofstream ofile(file_location);

    stack<if_block> blocks;
    if_block b;
    b.rm_first = false;
    b.rm_second = false;
    b.is_else_seen = false;
    b.rm_stat = true;
    blocks.push(b);

    string line;
    while (getline(file, line))
    {
        assert(blocks.size() > 0);
        b = blocks.top();
        if (starts_with(line, endif_prefix))
        {
            if (b.rm_stat == false)
            {
                ofile << line << endl;
            }
            blocks.pop();
            continue;
        }
        if (starts_with(line, else_prefix))
        {
            if (b.rm_stat == false)
            {
                ofile << line << endl;
            }
            blocks.pop();
            b.is_else_seen = true;
            blocks.push(b);
            continue;
        }
        if (!starts_with(line, if_prefix))
        {
            if (b.is_else_seen == false)
            {
                if (b.rm_first == false)
                {
                    ofile << line << endl;
                }
            }
            else
            {
                if (b.rm_second == false)
                {
                    ofile << line << endl;
                }
            }
            continue;
        }
        if_block a;
        a.is_else_seen = false;
        if ((b.is_else_seen == false && b.rm_first == true) ||
            (b.is_else_seen == true && b.rm_second == true))
        {
            a.rm_first = true;
            a.rm_second = true;
            a.rm_stat = true;
        }
        else if ((!is_related(line, vala_flag)) && (!is_related(line, "!" + vala_flag)))
        {
            a.rm_stat = false;
            a.rm_first = false;
            a.rm_second = false;
        }
        else
        {
            a.rm_stat = true;
            if (is_related(line, vala_flag))
            {
                a.rm_first = false;
                a.rm_second = true;
            }
            else
            {
                a.rm_first = true;
                a.rm_second = false;
            }
        }
        blocks.push(a);
        if (a.rm_stat == false)
        {
            ofile << line << endl;
        }
    }
    file.close();
    assert(blocks.size() == 1);
    string rm_cmd = "rm " + file_location + ".in";
    system(rm_cmd.c_str());
}

The "vapi: Remove unused files" commit is done in a manual way, you may notice that this PR has 1000+ lines of additions, this is likely because vapi/mutter-cogl-10.vapi is updated from a symbolic link to an actual file (and the old "actual file" vapi/mutter-cogl-6.vapi is removed). But anyway feel free to request changes or force push this PR if you spot random things are messed up.

This also includes an removal of the vapi/mutter-cogl.vapi file, I guess that is probably for even older (< 3.36) mutter? 馃

Compiles against 42 and 43 and briefly tested both.

@tintou
Copy link
Member

tintou commented Nov 12, 2022

We can only remove the support once elementary Odin is out

@danirabbit
Copy link
Member

It looks like Gala already can't really be released on OS 6, so I think it's okay to drop support for anything before horus/jammy

@bobby285271 bobby285271 marked this pull request as draft January 6, 2023 01:22
@bobby285271 bobby285271 marked this pull request as ready for review January 6, 2023 01:57
@lenemter lenemter requested a review from tintou February 19, 2023 04:07
This is a trivial change that (hopefully) shouldn't change any behavior.
We want to clean up the code base with script but
the script does not take care of `elif` blocks yet,
luckily we don't have many `elif` blocks so we simply
take care of them before we run the script.
Changes are generated by scripts except meson.build
See the related pull request for more info
Changes are generated by scripts except meson.build
See the related pull request for more info
Changes are generated by scripts except meson.build
See the related pull request for more info
Changes are generated by scripts except meson.build
See the related pull request for more info
Since we require mutter 42, (hopefully) these files are no
longer needed. Note that this also removes mutter-cogl.vapi,
which is already not needed when bumping mutter requirement
to 3.36.
Copy link
Member

@lenemter lenemter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'll merge this since OS 7 is out.

@lenemter lenemter merged commit 6ab0825 into elementary:master Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants