# Copyright (c) 2013, 2021, Oracle and/or its affiliates.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.

# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation.  The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License, version 2.0, for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA

def configure(conf):
  conf.env.append_unique("CPPPATH", conf.env.my_inc)
  conf.env.append_unique("CPPPATH", conf.env.ndb_inc)
  conf.env.append_unique("CPPPATH", conf.env.ndb_inc + "/ndbapi")
  conf.env.append_unique("CPPPATH", "../common/include")
  conf.env.append_unique("CPPPATH", "../ndb/include")
  conf.env.append_unique('CXXFLAGS', ["-Wall"])
  conf.env.append_unique("LIBPATH", conf.env.my_lib)
  conf.recurse("test")

def build(ctx):  
  obj = ctx.new_task_gen("cxx", "shlib", "node_addon")
  obj.target = "ndb_adapter"
  obj.rpath = ctx.env.my_lib
  obj.lib = [ "ndbclient" , "mysqlclient"]
  
  obj.source = \
  "ndb/src/node_module.cpp " +\
  \
  "common/src/async_common.cpp " +\
  "common/src/unified_debug.cpp " +\
  "common/src/common_v8_values.cpp " +\
  \
  "ndb/src/Record.cpp " +\
  "ndb/src/DBOperationHelper.cpp " +\
  "ndb/src/IndexBoundHelper.cpp " +\
  "ndb/src/DBDictionaryImpl.cpp " +\
  "ndb/src/Record_wrapper.cpp " +\
  "ndb/src/Ndb_init_wrapper.cpp " +\
  "ndb/src/Ndb_util_wrapper.cpp " +\
  "ndb/src/Ndb_cluster_connection_wrapper.cpp " + \
  "ndb/src/Ndb_wrapper.cpp " +\
  "ndb/src/NdbError_wrapper.cpp " +\
  "ndb/src/NdbInterpretedCode_wrapper.cpp " +\
  "ndb/src/NdbScanFilter_wrapper.cpp " +\
  "ndb/src/AsyncNdbContext.cpp " +\
  "ndb/src/AsyncNdbContext_wrapper.cpp " +\
  "ndb/src/NdbTypeEncoders.cpp " +\
  "ndb/src/NdbRecordObject.cpp " +\
  "ndb/src/ColumnProxy.cpp " +\
  "ndb/src/ColumnHandler.cpp " +\
  "ndb/src/ValueObject.cpp " +\
  "ndb/src/EncoderCharset.cpp " +\
  "ndb/src/DBSessionImpl.cpp " +\
  "ndb/src/DBSessionImpl_wrapper.cpp " +\
  "ndb/src/DBTransactionContext.cpp " +\
  "ndb/src/DBTransactionContext_wrapper.cpp " +\
  "ndb/src/DBOperationSet.cpp " +\
  "ndb/src/DBOperationSet_wrapper.cpp " +\
  "ndb/src/ScanOperation.cpp " +\
  "ndb/src/ScanOperation_wrapper.cpp " +\
  "ndb/src/BlobHandler.cpp " +\
  "ndb/src/KeyOperation.cpp " +\
  \
  "ndb/src/mysqlclient_wrapper.cpp " +\
  ""
  
  ctx.recurse("test")
