# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2025, The OpenROAD Authors load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_python//python:defs.bzl", "py_library") load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc") load("//bazel:tcl_encode_or.bzl", "tcl_encode") load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc") load("//test:regression.bzl", "messages_txt") package( default_visibility = ["//:__subpackages__"], features = ["layering_check"], ) # Headers owned by :gpl but also consumed by :ui and GPL tests. Keep them # visible only to //src/gpl and its tests. cc_library( name = "gpl_private_hdrs", hdrs = [ "src/fft.h", "src/fftBackend.h", "src/nesterovBase.h", "src/nesterovPlace.h", "src/placerBase.h", "src/point.h", "src/routeBase.h", ], includes = ["src"], visibility = [ "//src/gpl/test:__pkg__", "//visibility:private", ], deps = [ # TODO: we use headers provided by :gpl, but that reveals cyclic dep #":gpl", "//src/odb/src/db", "//src/utl", "@boost.random", "@boost.unordered", ], ) cc_library( name = "gpl", srcs = [ "src/AbstractGraphics.cpp", "src/backendContext.h", "src/clockBase.cpp", "src/clockBase.h", "src/densityGradient.cpp", "src/densityGradientBackend.h", "src/fft.cpp", "src/fftsg.cpp", "src/fftsg2d.cpp", "src/gpu/deviceState.h", "src/gpu/nesterovDeviceContext.h", "src/gpu/regionDensityField.h", "src/graphicsNone.cpp", "src/hpwl.cpp", "src/hpwlBackend.h", "src/initialPlace.cpp", "src/initialPlace.h", "src/mbff.cpp", "src/nesterovBase.cpp", "src/nesterovPlace.cpp", "src/placerBase.cpp", "src/replace.cpp", "src/routeBase.cpp", "src/solver.cpp", "src/solver.h", "src/timingBase.cpp", "src/timingBase.h", "src/wirelengthGradient.cpp", "src/wirelengthGradientBackend.h", ], hdrs = [ "include/gpl/Replace.h", "src/AbstractGraphics.h", "src/graphicsNone.h", "src/mbff.h", ], copts = [ "-fopenmp", ], includes = [ "include", ], deps = [ ":gpl_private_hdrs", "//src/dbSta", "//src/dbSta:dbNetwork", "//src/grt", "//src/odb/src/db", "//src/rsz", "//src/sta:opensta_lib", "//src/utl", "@abseil-cpp//absl/container:inlined_vector", "@boost.polygon", "@boost.random", "@boost.scope_exit", "@coin-or-lemon//:lemon", "@eigen", "@openmp", "@or-tools//ortools/linear_solver", "@or-tools//ortools/linear_solver:linear_solver_base", "@or-tools//ortools/sat:cp_model", "@or-tools//ortools/util:sorted_interval_list", ], ) cc_library( name = "ui", srcs = [ "src/MakeReplace.cpp", "src/graphicsImpl.cpp", "src/graphicsImpl.h", ":swig", ":tcl", ], hdrs = [ "include/gpl/MakeReplace.h", ], copts = [ "-Wno-missing-braces", # from TCL swigging ], includes = [ "include", "src", ], deps = [ ":gpl", ":gpl_private_hdrs", "//:ord", "//src/gui", "//src/odb/src/db", "//src/sta:opensta_lib", "//src/utl", "@boost.stacktrace", "@tcl_lang//:tcl", ], ) # This target compiles the SWIG C++ wrapper into a shared library (.so) # that Python can load dynamically. cc_binary( name = "_gpl.so", srcs = [ ":swig-py", ], defines = [PYTHON_STABLE_API_DEFINE], includes = ["src"], linkopts = PYTHON_EXTENSION_LINKOPTS, linkshared = True, deps = [ "//src/gpl", "//src/odb/src/db", "//src/utl", "@boost.stacktrace", "@rules_python//python/cc:current_py_cc_headers", ], ) # This packages the SWIG-generated Python wrapper (gpl.py) and the # compiled C++ extension (_gpl.so) together. py_library( name = "gpl_py", srcs = [":swig-py"], # Use the .py output from the swig-py rule # The data attribute makes the .so file available at runtime. data = [":_gpl.so"], # This allows imports relative to the workspace root. imports = ["."], visibility = ["//visibility:public"], ) tcl_encode( name = "tcl", srcs = [ "src/replace.tcl", ], char_array_name = "gpl_tcl_inits", namespace = "gpl", visibility = ["//visibility:public"], ) tcl_wrap_cc( name = "swig", srcs = [ "src/replace.i", "//:error_swig", "//:options_swig", ], module = "gpl", namespace_prefix = "gpl", root_swig_src = "src/replace.i", swig_includes = [ "src/gpl/src", ], visibility = ["//visibility:public"], deps = [ "//src/odb:swig", ], ) python_wrap_cc( name = "swig-py", srcs = [ "include/gpl/Replace.h", "src/replace-py.i", "//:error_swig-py", ], module = "gpl", root_swig_src = "src/replace-py.i", swig_includes = [ "include", "src", ], visibility = ["//:__subpackages__"], ) filegroup( name = "doc_files", srcs = [ "README.md", "src/replace.tcl", ], visibility = ["//src/gpl/test:__pkg__"], ) messages_txt( visibility = [ "//docs:__pkg__", "//src/gpl/test:__pkg__", ], )