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

xmake 使用 GN 构建依赖时,is_debug 字段类型错误 #5100

Closed
Ariaszzzhc opened this issue May 14, 2024 · 7 comments
Closed

xmake 使用 GN 构建依赖时,is_debug 字段类型错误 #5100

Ariaszzzhc opened this issue May 14, 2024 · 7 comments
Labels
Milestone

Comments

@Ariaszzzhc
Copy link

Xmake Version

v2.9.1+20240422

Operating System Version and Architecture

macOS Sonoma 14.4.1

Describe Bug

尝试 xmake 使用 gn 构建自己代码库中的 v8 时,无论怎么设置 is_debug 这个配置,最后在 gn 中拿到的是 string 类型的 is_debug,导致 v8 无法构建

Expected Behavior

is_debug 应该为 boolean 类型

Project Configuration

package("v8")
    set_sourcedir(path.join(os.scriptdir(), "v8"))
    add_deps("depot_tools")

    if is_plat("linux", "bsd") then
        add_syslinks("pthread", "dl")
    elseif is_plat("windows") then
        add_syslinks("user32", "winmm", "advapi32", "dbghelp", "shlwapi")
    end

    add_links("v8_monolith",
              "v8_initializers",
              "v8_init",
              "v8_compiler",
              "v8_compiler_opt",
              "v8_cppgc_shared",
              "v8_bigint",
              "v8_snapshot",
              "v8_base_without_compiler",
              "v8_libplatform",
              "v8_libbase",
              "torque_base",
              "torque_generated_definitions",
              "cppgc_base",
              "torque_ls_base")

    on_install("linux", "macosx", "windows", function (package)
        import("core.base.global")

        -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
        local envs = {}
        local proxy = global.get("proxy")
        if proxy then
            envs.HTTP_PROXY = proxy
            envs.HTTPS_PROXY = proxy
            envs.ALL_PROXY = proxy
        end
        io.writefile(".gclient", [=[solutions = [
  {
    "name": ".",
    "url": "https://github.com/v8/v8.git",
    "deps_file": "DEPS",
    "managed": False,
    "custom_deps": {},
  }]]=])
        if package:is_plat("windows") then
            envs.DEPOT_TOOLS_WIN_TOOLCAHIN = "0"
        end
        local gclient = is_host("windows") and "gclient.bat" or "gclient"
        os.vrunv(gclient, {"sync", "-v"}, {envs = envs})
        local configs = {
            is_official_build = false,
            is_component_build = false,
            is_debug = false,
            is_shared_library = false,
            symbol_level = 0,
            treat_warnings_as_errors = false,
            use_custom_libcxx = false,
            v8_static_library = true,
            v8_monolithic = true,
            v8_use_external_startup_data = false,
            v8_enable_test_features = false,
            v8_enable_i18n_support = false}

        if package:is_plat("windows") then
            configs.extra_cflags = {"/MD"}
            configs.is_clang = false
        end
        import("package.tools.gn").build(package, configs, {buildir = "out.gn"})
        os.cp("include", package:installdir())
        os.trycp("out.gn/obj/*.a", package:installdir("lib"))
        os.trycp("out.gn/obj/*.lib", package:installdir("lib"))
        os.trycp("out.gn/obj/*.dll", package:installdir("bin"))
    end)

    on_test(function (package)
        assert(package:has_cxxfuncs("v8::V8::InitializePlatform(0)", {configs = {languages = "c++17"}, includes = "v8.h"}))
    end)
package_end()

Additional Information and Error Logs

checking for gn ... /Users/arias/.xmake/packages/d/depot_tools/2024.2.29/91b8d80b780346beb473954d283dbd40/gn
/Users/arias/.xmake/packages/d/depot_tools/2024.2.29/91b8d80b780346beb473954d283dbd40/gn gen out.gn "--args=v8_use_external_startup_data=false is_shared_library=false is_official_build=false use_custom_libcxx=false treat_warnings_as_errors=false target_cpu=\"arm64\" target_os=\"mac\" extra_ldflags=[\"-lstdc++\"] cc=\"/opt/homebrew/Cellar/llvm/18.1.5/bin/clang\" is_debug=\"false\" is_component_build=false symbol_level=0 v8_static_library=true cxx=\"/opt/homebrew/Cellar/llvm/18.1.5/bin/clang\" v8_enable_i18n_support=false v8_enable_test_features=false v8_monolithic=true"
ERROR at //build/config/BUILDCONFIG.gn:173:24: Left side of && operator is not a boolean.
  is_component_build = is_debug && current_os != "ios"
                       ^-------
Type is "string" instead.
error: execv(/Users/arias/.xmake/packages/d/depot_tools/2024.2.29/91b8d80b780346beb473954d283dbd40/gn gen out.gn "--args=v8_use_external_startup_data=false is_shared_library=false is_official_build=false use_custom_libcxx=false treat_warnings_as_errors=false target_cpu=\"arm64\" target_os=\"mac\" extra_ldflags=[\"-lstdc++\"] cc=\"/opt/homebrew/Cellar/llvm/18.1.5/bin/clang\" is_debug=\"false\" is_component_build=false symbol_level=0 v8_static_library=true cxx=\"/opt/homebrew/Cellar/llvm/18.1.5/bin/clang\" v8_enable_i18n_support=false v8_enable_test_features=false v8_monolithic=true") failed(1)
  => install v8 latest .. failed
error: install failed!
@Ariaszzzhc Ariaszzzhc added the bug label May 14, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: xmake When using GN to build dependencies, the is_debug field type is wrong

@Ariaszzzhc
Copy link
Author

Ariaszzzhc commented May 14, 2024

function _get_configs(package, configs, opt)
configs = configs or {}
if not package:is_plat("windows") then
configs.cc = package:build_getenv("cc")
configs.cxx = package:build_getenv("cxx")
end
if package:is_plat("macosx") then
configs.extra_ldflags = {"-lstdc++"}
local xcode = toolchain.load("xcode", {plat = package:plat(), arch = package:arch()})
configs.xcode_sysroot = xcode:config("xcode_sysroot")
end
if package:is_plat("linux") then
configs.target_os = "linux"
elseif package:is_plat("macosx") then
configs.target_os = "mac"
elseif package:is_plat("windows") then
configs.target_os = "win"
elseif package:is_plat("iphoneos") then
configs.target_os = "ios"
elseif package:is_plat("android") then
configs.target_os = "android"
end
if package:is_arch("x86", "i386") then
configs.target_cpu = "x86"
elseif package:is_arch("x64", "x86_64") then
configs.target_cpu = "x64"
elseif package:is_arch("arm64", "arm64-v8a") then
configs.target_cpu = "arm64"
elseif package:is_arch("arm.*") then
configs.target_cpu = "arm"
end
configs.is_debug = package:is_debug() and "true" or "false"
return configs
end

在这个文件69行中可以看到,最后 GN 会无视用户输入的 is_debug 属性,强行使用 string 类型的 is_debug 属性进行覆盖

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


function _get_configs(package, configs, opt)
configs = configs or {}
if not package:is_plat("windows") then
configs.cc = package:build_getenv("cc")
configs.cxx = package:build_getenv("cxx")
end
if package:is_plat("macosx") then
configs.extra_ldflags = {"-lstdc++"}
local xcode = toolchain.load("xcode", {plat = package:plat(), arch = package:arch()})
configs.xcode_sysroot = xcode:config("xcode_sysroot")
end
if package:is_plat("linux") then
configs.target_os = "linux"
elseif package:is_plat("macosx") then
configs.target_os = "mac"
elseif package:is_plat("windows") then
configs.target_os = "win"
elseif package:is_plat("iphoneos") then
configs.target_os = "ios"
elseif package:is_plat("android") then
configs.target_os = "android"
end
if package:is_arch("x86", "i386") then
configs.target_cpu = "x86"
elseif package:is_arch("x64", "x86_64") then
configs.target_cpu = "x64"
elseif package:is_arch("arm64", "arm64-v8a") then
configs.target_cpu = "arm64"
elseif package:is_arch("arm.*") then
configs.target_cpu = "arm"
end
configs.is_debug = package:is_debug() and "true" or "false"
return configs
end

As you can see in this file, in the end GN will ignore the is_debug attribute entered by the user and force the use of the string type is_debug attribute to overwrite it.

waruqi added a commit that referenced this issue May 15, 2024
@waruqi
Copy link
Member

waruqi commented May 15, 2024

改了,再试试,xmake update -s dev

@waruqi waruqi added this to the v2.9.2 milestone May 15, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Changed, try again, xmake update -s dev

@Ariaszzzhc
Copy link
Author

已解决,感谢!

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Solved, thank you!

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

3 participants