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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use C modules together with generated headers #3384

Open
markushedvall opened this issue Feb 17, 2023 · 1 comment
Open

Unable to use C modules together with generated headers #3384

markushedvall opened this issue Feb 17, 2023 · 1 comment
Labels

Comments

@markushedvall
Copy link

markushedvall commented Feb 17, 2023

Xmake Version

v2.7.6 20230213

Operating System Version and Architecture

Ubuntu 22.04.1 LTS

Describe Bug

I'm unable to use C modules in a project that uses generated headers, getting a "no such file or directory" error during "generating.module.deps".

Expected Behavior

Project generates code and compiles successfully

Project Configuration

This can easily be reproduced by adding a mpp file to xmake/tests/projects/c /protobuf.

hello.mpp

#include <iostream>
#include "test.pb.h"
#include "subdir/test2.pb.h"

using namespace std;

int main(int argc, char** argv)
{
    cout << "hello world!" << endl;
    return 0;
}

and in xmake.lua add the file to the test target and change language to c 20:

add_rules("mode.debug", "mode.release")
add_requires("protobuf-cpp")

target("test")
    set_kind("binary")
    set_languages("c  20")
    add_packages("protobuf-cpp")
    add_rules("protobuf.cpp")
    add_files("src/*.cpp")
    add_files("src/**.proto", {proto_rootdir = "src"})
    add_files("src/*.mpp")

When running xmake I get the following:

$ xmake
[  0%]: generating.module.deps src/main.cpp
error: src/main.cpp:2:10: fatal error: test.pb.h: No such file or directory
    2 | #include "test.pb.h"
      |          ^~~~~~~~~~~
compilation terminated.

Additional Information and Error Logs

No response

@markushedvall markushedvall changed the title Unable to use C modules depending on generated headers Unable to use C modules together with generated headers Feb 17, 2023
@waruqi waruqi added this to the v2.7.7 milestone Feb 19, 2023
@waruqi
Copy link
Member

waruqi commented Feb 20, 2023

The rule implementation of c modules does currently conflict with some other build rules. This is because the task of performing module dependency graph scans is performed before the processing task of protobuf.

I will try to fix it later, but it may take some time.

related issue: #3292

@waruqi waruqi modified the milestones: v2.7.7, v2.7.8 Feb 22, 2023
@waruqi waruqi modified the milestones: v2.7.8, v2.7.9 Apr 5, 2023
@waruqi waruqi removed this from the v2.7.9 milestone May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants